// File: /workspace/github_cpp_makefile_star2_O2/essarrdee[P]mutantaliens/mutantaliens.cpp
// Function: draw_line(int, int, int, int, char)
void draw_line(int x1, int y1, int x2, int y2, char ch)
{
    // if x1 == x2 or y1 == y2, then it does not matter what we set here
	int col = COLOR_BLUE;
	if(on_map(x2,y2))
	{
		if(map_occupants[x2][y2] != NULL && sym_los_in_range(x1,y1,x2,y2,blocks_shots))
		{
			col = COLOR_CYAN;
		}
	}
    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 (blocks_shots(x1,y1)) {col = COLOR_RED;}
			draw_ch(x1,y1,ch,col);
        }
    }
    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 (blocks_shots(x1,y1)) {col = COLOR_RED;}
			draw_ch(x1,y1,ch,col);
        }
    }
	move(y2,x2-1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %ebx
movl %edx, %ebp
movl %esi, %r14d
movl %edi, %r15d
pushq $0x4
popq %r12
movl %ecx, %eax
orl %edx, %eax
js 0xc9bb
movl $0x96, %eax
cmpl %eax, %ebp
setge %cl
cmpl %eax, %ebx
setge %al
orb %cl, %al
jne 0xc9bb
movslq %ebp, %rax
movslq %ebx, %rcx
imulq $0x4b0, %rax, %rax      # imm = 0x4B0
leaq 0x5eb66(%rip), %rdx     # 0x6b4f0
addq %rax, %rdx
cmpq $0x0, (%rdx,%rcx,8)
je 0xc9bb
movl %r8d, %r12d
leaq -0x1d97(%rip), %r8      # 0xac07
movl %r15d, %edi
movl %r14d, %esi
movl %ebp, %edx
movl %ebx, %ecx
callq 0x112e7
movl %r12d, %r8d
movzbl %al, %eax
leal 0x4(,%rax,2), %r12d
xorl %edx, %edx
movl %ebp, 0xc(%rsp)
subl %r15d, %ebp
setne %dl
movl %ebp, %ecx
sarl $0x1f, %ecx
orl %ecx, %edx
movl %edx, 0x8(%rsp)
movl %ebp, %ecx
negl %ecx
cmovsl %ebp, %ecx
addl %ecx, %ecx
xorl %ebp, %ebp
movl %ebx, 0x10(%rsp)
movl %ebx, %eax
movl %ecx, %ebx
subl %r14d, %eax
setne %bpl
movl %eax, %ecx
sarl $0x1f, %ecx
orl %ecx, %ebp
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
addl %ecx, %ecx
cmpl %ecx, %ebx
movl %ecx, %r13d
movl %ebx, 0x14(%rsp)
jge 0xca69
movl %ecx, %eax
sarl %eax
subl %eax, %ebx
movsbl %r8b, %eax
movl %eax, 0x4(%rsp)
cmpl %r14d, 0x10(%rsp)
je 0xcacc
testl %ebx, %ebx
js 0xca37
testl %ebp, %ebp
jg 0xca30
testl %ebx, %ebx
jne 0xca30
xorl %ebx, %ebx
jmp 0xca37
addl 0x8(%rsp), %r15d
subl %ecx, %ebx
addl %ebp, %r14d
addl 0x14(%rsp), %ebx
movl %r15d, %edi
movl %r14d, %esi
callq 0xac07
testb %al, %al
pushq $0x1
popq %rax
cmovnel %eax, %r12d
movl %r15d, %edi
movl %r14d, %esi
movl 0x4(%rsp), %edx
movl %r12d, %ecx
callq 0x11324
movl %r13d, %ecx
jmp 0xca15
movl %ebx, %eax
sarl %eax
movl %ecx, %ebx
subl %eax, %ebx
movsbl %r8b, %eax
movl %eax, 0x4(%rsp)
cmpl %r15d, 0xc(%rsp)
je 0xcacc
testl %ebx, %ebx
js 0xca9a
cmpl $0x0, 0x8(%rsp)
jg 0xca93
testl %ebx, %ebx
jne 0xca93
xorl %ebx, %ebx
jmp 0xca9a
addl %ebp, %r14d
subl 0x14(%rsp), %ebx
addl 0x8(%rsp), %r15d
addl %ecx, %ebx
movl %r15d, %edi
movl %r14d, %esi
callq 0xac07
testb %al, %al
pushq $0x1
popq %rax
cmovnel %eax, %r12d
movl %r15d, %edi
movl %r14d, %esi
movl 0x4(%rsp), %edx
movl %r12d, %ecx
callq 0x11324
movl %r13d, %ecx
jmp 0xca79
movl 0xc(%rsp), %esi
decl %esi
movl 0x10(%rsp), %edi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x51a0