// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/src/engine.c
// Function: clipinsidebox
int clipinsidebox(int x, int y, short wallnum, int walldist)
{
	walltype *wal;
	int x1, y1, x2, y2, r;

	r = (walldist<<1);
	wal = &wall[wallnum];     x1 = wal->x+walldist-x; y1 = wal->y+walldist-y;
	wal = &wall[wal->point2]; x2 = wal->x+walldist-x; y2 = wal->y+walldist-y;

	if ((x1 < 0) && (x2 < 0)) return(0);
	if ((y1 < 0) && (y2 < 0)) return(0);
	if ((x1 >= r) && (x2 >= r)) return(0);
	if ((y1 >= r) && (y2 >= r)) return(0);

	x2 -= x1; y2 -= y1;
	if (x2*(walldist-y1) >= y2*(walldist-x1))  //Front
	{
		if (x2 > 0) x2 *= (0-y1); else x2 *= (r-y1);
		if (y2 > 0) y2 *= (r-x1); else y2 *= (0-x1);
		return(x2 < y2);
	}
	if (x2 > 0) x2 *= (r-y1); else x2 *= (0-y1);
	if (y2 > 0) y2 *= (0-x1); else y2 *= (r-x1);
	return((x2 >= y2)<<1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movw %dx, %ax
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movw %ax, -0xe(%rbp)
movl %ecx, -0x14(%rbp)
movl -0x14(%rbp), %eax
shll %eax
movl %eax, -0x34(%rbp)
movswq -0xe(%rbp), %rcx
leaq 0x1a6a98(%rip), %rax    # 0x1f55b0
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
addl -0x14(%rbp), %eax
subl -0x8(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rax
movl 0x4(%rax), %eax
addl -0x14(%rbp), %eax
subl -0xc(%rbp), %eax
movl %eax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movswq 0x8(%rax), %rcx
leaq 0x1a6a5e(%rip), %rax    # 0x1f55b0
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
addl -0x14(%rbp), %eax
subl -0x8(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x20(%rbp), %rax
movl 0x4(%rax), %eax
addl -0x14(%rbp), %eax
subl -0xc(%rbp), %eax
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x24(%rbp)
jge 0x4eb94
cmpl $0x0, -0x2c(%rbp)
jge 0x4eb94
movl $0x0, -0x4(%rbp)
jmp 0x4ecc0
cmpl $0x0, -0x28(%rbp)
jge 0x4ebac
cmpl $0x0, -0x30(%rbp)
jge 0x4ebac
movl $0x0, -0x4(%rbp)
jmp 0x4ecc0
movl -0x24(%rbp), %eax
cmpl -0x34(%rbp), %eax
jl 0x4ebc8
movl -0x2c(%rbp), %eax
cmpl -0x34(%rbp), %eax
jl 0x4ebc8
movl $0x0, -0x4(%rbp)
jmp 0x4ecc0
movl -0x28(%rbp), %eax
cmpl -0x34(%rbp), %eax
jl 0x4ebe4
movl -0x30(%rbp), %eax
cmpl -0x34(%rbp), %eax
jl 0x4ebe4
movl $0x0, -0x4(%rbp)
jmp 0x4ecc0
movl -0x24(%rbp), %ecx
movl -0x2c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x2c(%rbp)
movl -0x28(%rbp), %ecx
movl -0x30(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x30(%rbp)
movl -0x2c(%rbp), %eax
movl -0x14(%rbp), %ecx
subl -0x28(%rbp), %ecx
imull %ecx, %eax
movl -0x30(%rbp), %ecx
movl -0x14(%rbp), %edx
subl -0x24(%rbp), %edx
imull %edx, %ecx
cmpl %ecx, %eax
jl 0x4ec6b
cmpl $0x0, -0x2c(%rbp)
jle 0x4ec2a
xorl %eax, %eax
subl -0x28(%rbp), %eax
imull -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x4ec37
movl -0x34(%rbp), %eax
subl -0x28(%rbp), %eax
imull -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x30(%rbp)
jle 0x4ec4c
movl -0x34(%rbp), %eax
subl -0x24(%rbp), %eax
imull -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0x4ec58
xorl %eax, %eax
subl -0x24(%rbp), %eax
imull -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x30(%rbp), %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
jmp 0x4ecc0
cmpl $0x0, -0x2c(%rbp)
jle 0x4ec80
movl -0x34(%rbp), %eax
subl -0x28(%rbp), %eax
imull -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x4ec8c
xorl %eax, %eax
subl -0x28(%rbp), %eax
imull -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x30(%rbp)
jle 0x4eca0
xorl %eax, %eax
subl -0x24(%rbp), %eax
imull -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0x4ecad
movl -0x34(%rbp), %eax
subl -0x24(%rbp), %eax
imull -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x30(%rbp), %eax
setge %al
andb $0x1, %al
movzbl %al, %eax
shll %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)