// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/src/engine.c
// Function: raytrace
static int raytrace(int x3, int y3, int *x4, int *y4)
{
	int x1, y1, x2, y2, bot, topu, nintx, ninty, cnt, z, hitwall;
	int x21, y21, x43, y43;

	hitwall = -1;
	for(z=clipnum-1;z>=0;z--)
	{
		x1 = clipit[z].x1; x2 = clipit[z].x2; x21 = x2-x1;
		y1 = clipit[z].y1; y2 = clipit[z].y2; y21 = y2-y1;

		topu = x21*(y3-y1) - (x3-x1)*y21; if (topu <= 0) continue;
		if (x21*(*y4-y1) > (*x4-x1)*y21) continue;
		x43 = *x4-x3; y43 = *y4-y3;
		if (x43*(y1-y3) > (x1-x3)*y43) continue;
		if (x43*(y2-y3) <= (x2-x3)*y43) continue;
		bot = x43*y21 - x21*y43; if (bot == 0) continue;

		cnt = 256;
		do
		{
			cnt--; if (cnt < 0) { *x4 = x3; *y4 = y3; return(z); }
			nintx = x3 + scale(x43,topu,bot);
			ninty = y3 + scale(y43,topu,bot);
			topu--;
		} while (x21*(ninty-y1) <= (nintx-x1)*y21);

		if (klabs(x3-nintx)+klabs(y3-ninty) < klabs(x3-*x4)+klabs(y3-*y4))
			{ *x4 = nintx; *y4 = ninty; hitwall = z; }
	}
	return(hitwall);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl $0xffffffff, -0x4c(%rbp) # imm = 0xFFFFFFFF
movswl 0x41721c(%rip), %eax    # 0x46c580
subl $0x1, %eax
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x48(%rbp)
jl 0x555b2
movslq -0x48(%rbp), %rcx
leaq 0x417211(%rip), %rax    # 0x46c590
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x24(%rbp)
movslq -0x48(%rbp), %rcx
leaq 0x4171fa(%rip), %rax    # 0x46c590
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
subl -0x24(%rbp), %eax
movl %eax, -0x50(%rbp)
movslq -0x48(%rbp), %rcx
leaq 0x4171d9(%rip), %rax    # 0x46c590
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x28(%rbp)
movslq -0x48(%rbp), %rcx
leaq 0x4171c1(%rip), %rax    # 0x46c590
shlq $0x4, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
subl -0x28(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x50(%rbp), %eax
movl -0xc(%rbp), %ecx
subl -0x28(%rbp), %ecx
imull %ecx, %eax
movl -0x8(%rbp), %ecx
subl -0x24(%rbp), %ecx
imull -0x54(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
jg 0x5540b
jmp 0x555a4
movl -0x50(%rbp), %eax
movq -0x20(%rbp), %rcx
movl (%rcx), %ecx
subl -0x28(%rbp), %ecx
imull %ecx, %eax
movq -0x18(%rbp), %rcx
movl (%rcx), %ecx
subl -0x24(%rbp), %ecx
imull -0x54(%rbp), %ecx
cmpl %ecx, %eax
jle 0x55430
jmp 0x555a4
movq -0x18(%rbp), %rax
movl (%rax), %eax
subl -0x8(%rbp), %eax
movl %eax, -0x58(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
subl -0xc(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x58(%rbp), %eax
movl -0x28(%rbp), %ecx
subl -0xc(%rbp), %ecx
imull %ecx, %eax
movl -0x24(%rbp), %ecx
subl -0x8(%rbp), %ecx
imull -0x5c(%rbp), %ecx
cmpl %ecx, %eax
jle 0x55467
jmp 0x555a4
movl -0x58(%rbp), %eax
movl -0x30(%rbp), %ecx
subl -0xc(%rbp), %ecx
imull %ecx, %eax
movl -0x2c(%rbp), %ecx
subl -0x8(%rbp), %ecx
imull -0x5c(%rbp), %ecx
cmpl %ecx, %eax
jg 0x55486
jmp 0x555a4
movl -0x58(%rbp), %eax
imull -0x54(%rbp), %eax
movl -0x50(%rbp), %ecx
imull -0x5c(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0x554a4
jmp 0x555a4
movl $0x100, -0x44(%rbp)     # imm = 0x100
movl -0x44(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jge 0x554d7
movl -0x8(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl -0xc(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x48(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x555b8
movl -0x8(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x58(%rbp), %edi
movl -0x38(%rbp), %esi
movl -0x34(%rbp), %edx
callq 0x37720
movl %eax, %ecx
movl -0x64(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x3c(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x5c(%rbp), %edi
movl -0x38(%rbp), %esi
movl -0x34(%rbp), %edx
callq 0x37720
movl %eax, %ecx
movl -0x60(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x40(%rbp)
movl -0x38(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x38(%rbp)
movl -0x50(%rbp), %eax
movl -0x40(%rbp), %ecx
subl -0x28(%rbp), %ecx
imull %ecx, %eax
movl -0x3c(%rbp), %ecx
subl -0x24(%rbp), %ecx
imull -0x54(%rbp), %ecx
cmpl %ecx, %eax
jle 0x554ab
movl -0x8(%rbp), %edi
subl -0x3c(%rbp), %edi
callq 0x37610
movl %eax, -0x70(%rbp)
movl -0xc(%rbp), %edi
subl -0x40(%rbp), %edi
callq 0x37610
movl %eax, %ecx
movl -0x70(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x68(%rbp)
movl -0x8(%rbp), %edi
movq -0x18(%rbp), %rax
subl (%rax), %edi
callq 0x37610
movl %eax, -0x6c(%rbp)
movl -0xc(%rbp), %edi
movq -0x20(%rbp), %rax
subl (%rax), %edi
callq 0x37610
movl -0x6c(%rbp), %ecx
movl %eax, %edx
movl -0x68(%rbp), %eax
addl %edx, %ecx
cmpl %ecx, %eax
jge 0x555a2
movl -0x3c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl -0x40(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x48(%rbp), %eax
movl %eax, -0x4c(%rbp)
jmp 0x555a4
movl -0x48(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x5536a
movl -0x4c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)