#include <time.h>
#include <stdio.h>

int main(void) { 
	int x;
	int n = 32768;
	//for(; scanf("%d",&x) > 0 && x != 42; printf("%d\n", x));
	printf("Wait for %d lines with 32768 pixels each...\n", n);
    time_t     start = time(0);
    for(x = 0; x < n; ++ x) {
	__asm(
"	movl	$0x7FFF0000,%eax;"
"	movl	$0x00007FFF,%ecx;"
"	addw	%ax,%ax;"
"	subl	%eax,%ecx;"
"	sbbl	%ebx,%ebx;"
"	subw	%ax,%cx;"
"	sbbw	%bx,%bx;"
"	xorl	%ebx,%ecx;"
"	addw	%bx,%cx;"
"	subl	%ebx,%ecx;"
"	orl	$0x000010001,%ebx;"
"	andl	$0x07FFF7FFF,%ebx;"
"	movl	%ecx,%edx;"
"	rorl	$16,%edx;"
"	movl	%edx,%edi;"
"	addw	%cx,%dx;"
"	subl	%ecx,%edx;"
"	sbbl	%esi,%esi;"
"	subw	%cx,%dx;"
"	sbbw	%si,%si;"
"	movswl	%si,%esi;"
"	andl	%esi,%ecx;"
"	notl	%esi;"
"	andl	%esi,%edi;"
"	orl	%edi,%ecx;"
"	movl	%ecx,%edx;"
"	shll	$16,%ecx;"
"	movw	%dx,%cx;"
"	shrw	$1,%dx;"
"	notw	%si;"
"Step:;"
//"	movl	%edx,%edi;"
"	shldl	$16,%edx,%edi;"
"	addw	%di,%dx;"
"	cmpw	%dx,%cx;"
"	sbbl	%edi,%edi;"
"	andw	%cx,%di;"
"	subw	%di,%dx;"
"	sarl	$16,%edi;"
"	orl	%esi,%edi;"
"	andl	%ebx,%edi;"
"	addl	%edi,%eax;"
"	andl	$0x7FFF7FFF,%eax;"
"	subl	$0x00010000,%ecx;"
"	jns	Step;");
	}
    time_t     finish = time(0) - start;
    struct tm  tstruct;
    char       buf[80];
    tstruct = *localtime(&finish);
    strftime(buf, sizeof(buf), "Elapsed time is %S seconds", &tstruct);
    printf("%s\n", buf);
	return 0;
}