// File: essarrdee[P]mutantaliens/mutantaliens.cpp
// Function: los_exists(int, int, int, int, bool (*)(int, int))
bool los_exists(int x1, int y1, int x2, int y2, bool (*opacity_test)(int,int))
{
    // if x1 == x2 or y1 == y2, then it does not matter what we set here
    int delta_x(x2 - x1);
    signed char ix((delta_x > 0) - (delta_x < 0));
    delta_x = std::abs(delta_x) << 1;
 
    int delta_y(y2 - y1);
    signed char iy((delta_y > 0) - (delta_y < 0));
    delta_y = std::abs(delta_y) << 1;
 
    if (delta_x >= delta_y)
    {
        // error may go below zero
        int error(delta_y - (delta_x >> 1));
 
        while (x1 != x2)
        {
            if (error >= 0)
            {
                if (error || (ix > 0))
                {
                    y1 += iy;
                    error -= delta_x;
                }
                // else do nothing
            }
            // else do nothing
 
            x1 += ix;
            error += delta_y;
			if (x1 != x2)//(x1 != x2 && y1 != y2)
			{
				if (opacity_test(x1, y1)) return false;
			}
        }
    }
    else
    {
        // error may go below zero
        int error(delta_x - (delta_y >> 1));
 
        while (y1 != y2)
        {
            if (error >= 0)
            {
                if (error || (iy > 0))
                {
                    x1 += ix;
                    error -= delta_y;
                }
                // else do nothing
            }
            // else do nothing
 
            y1 += iy;
            error += delta_x;
 
            if (y1 != y2)//(x1 != x2 && y1 != y2)
			{
				if (opacity_test(x1, y1)) return false;
			}
        }
    }
	return true;
}

// Assembly:
subq $0x38, %rsp
movl %edi, 0x30(%rsp)
movl %esi, 0x2c(%rsp)
movl %edx, 0x28(%rsp)
movl %ecx, 0x24(%rsp)
movq %r8, 0x18(%rsp)
movl 0x28(%rsp), %eax
subl 0x30(%rsp), %eax
movl %eax, 0x14(%rsp)
cmpl $0x0, 0x14(%rsp)
setg %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, 0x14(%rsp)
setl %cl
andb $0x1, %cl
movzbl %cl, %ecx
subl %ecx, %eax
movb %al, 0x13(%rsp)
movl 0x14(%rsp), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
shll %eax
movl %eax, 0x14(%rsp)
movl 0x24(%rsp), %eax
subl 0x2c(%rsp), %eax
movl %eax, 0xc(%rsp)
cmpl $0x0, 0xc(%rsp)
setg %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, 0xc(%rsp)
setl %cl
andb $0x1, %cl
movzbl %cl, %ecx
subl %ecx, %eax
movb %al, 0xb(%rsp)
movl 0xc(%rsp), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
shll %eax
movl %eax, 0xc(%rsp)
movl 0x14(%rsp), %eax
cmpl 0xc(%rsp), %eax
jl 0x16480
movl 0xc(%rsp), %eax
movl 0x14(%rsp), %ecx
sarl %ecx
subl %ecx, %eax
movl %eax, 0x4(%rsp)
movl 0x30(%rsp), %eax
cmpl 0x28(%rsp), %eax
je 0x1647b
cmpl $0x0, 0x4(%rsp)
jl 0x16432
cmpl $0x0, 0x4(%rsp)
jne 0x16415
movsbl 0x13(%rsp), %eax
cmpl $0x0, %eax
jle 0x16430
movsbl 0xb(%rsp), %eax
addl 0x2c(%rsp), %eax
movl %eax, 0x2c(%rsp)
movl 0x14(%rsp), %ecx
movl 0x4(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x4(%rsp)
jmp 0x16432
movsbl 0x13(%rsp), %eax
addl 0x30(%rsp), %eax
movl %eax, 0x30(%rsp)
movl 0xc(%rsp), %eax
addl 0x4(%rsp), %eax
movl %eax, 0x4(%rsp)
movl 0x30(%rsp), %eax
cmpl 0x28(%rsp), %eax
je 0x16476
movq 0x18(%rsp), %rax
movl 0x30(%rsp), %edi
movl 0x2c(%rsp), %esi
callq *%rax
testb $0x1, %al
jne 0x1646a
jmp 0x16474
movb $0x0, 0x37(%rsp)
jmp 0x16512
jmp 0x16476
jmp 0x163f3
jmp 0x1650d
movl 0x14(%rsp), %eax
movl 0xc(%rsp), %ecx
sarl %ecx
subl %ecx, %eax
movl %eax, (%rsp)
movl 0x2c(%rsp), %eax
cmpl 0x24(%rsp), %eax
je 0x1650b
cmpl $0x0, (%rsp)
jl 0x164ca
cmpl $0x0, (%rsp)
jne 0x164af
movsbl 0xb(%rsp), %eax
cmpl $0x0, %eax
jle 0x164c8
movsbl 0x13(%rsp), %eax
addl 0x30(%rsp), %eax
movl %eax, 0x30(%rsp)
movl 0xc(%rsp), %ecx
movl (%rsp), %eax
subl %ecx, %eax
movl %eax, (%rsp)
jmp 0x164ca
movsbl 0xb(%rsp), %eax
addl 0x2c(%rsp), %eax
movl %eax, 0x2c(%rsp)
movl 0x14(%rsp), %eax
addl (%rsp), %eax
movl %eax, (%rsp)
movl 0x2c(%rsp), %eax
cmpl 0x24(%rsp), %eax
je 0x16509
movq 0x18(%rsp), %rax
movl 0x30(%rsp), %edi
movl 0x2c(%rsp), %esi
callq *%rax
testb $0x1, %al
jne 0x16500
jmp 0x16507
movb $0x0, 0x37(%rsp)
jmp 0x16512
jmp 0x16509
jmp 0x1648f
jmp 0x1650d
movb $0x1, 0x37(%rsp)
movb 0x37(%rsp), %al
andb $0x1, %al
addq $0x38, %rsp
retq
nopl (%rax)