// File: /workspace/github_cpp_makefile_star2_O3/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 $0x38, %rsp
movl %ecx, %ebx
movl %edx, %ebp
movl %esi, %r14d
movl %edi, %r12d
movl $0x4, %edi
movl %ecx, %eax
orl %edx, %eax
js 0xff50
movl $0x96, %eax
cmpl %eax, %ebp
setge %cl
cmpl %eax, %ebx
setge %al
orb %cl, %al
jne 0xff50
movslq %ebp, %rax
movslq %ebx, %rcx
imulq $0x4b0, %rax, %rax      # imm = 0x4B0
leaq 0x5e5f0(%rip), %rdx     # 0x6e4f0
addq %rax, %rdx
cmpq $0x0, (%rdx,%rcx,8)
je 0xff50
movl %r8d, %r15d
leaq -0x2b51(%rip), %r8      # 0xd3c3
movl %r12d, %edi
movl %r14d, %esi
movl %ebp, %edx
movl %ebx, %ecx
callq 0xf6ac
movl %r15d, %r8d
movl $0x4, %edi
testb %al, %al
je 0xff50
movl %r12d, %eax
subl %ebp, %eax
imull %eax, %eax
movl %r14d, %ecx
subl %ebx, %ecx
imull %ecx, %ecx
addl %eax, %ecx
xorl %eax, %eax
cmpl $0x41, %ecx
setb %al
leal 0x4(,%rax,2), %edi
xorl %edx, %edx
movl %ebp, %eax
subl %r12d, %eax
setne %dl
movl %eax, %ecx
sarl $0x1f, %ecx
orl %ecx, %edx
movl %edx, 0x10(%rsp)
movl %eax, %edx
negl %edx
cmovsl %eax, %edx
addl %edx, %edx
xorl %esi, %esi
movl %ebx, %eax
subl %r14d, %eax
setne %sil
movl %eax, %ecx
sarl $0x1f, %ecx
orl %ecx, %esi
movl %esi, 0xc(%rsp)
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
addl %ecx, %ecx
movl %edx, 0x8(%rsp)
movl %ecx, 0x4(%rsp)
cmpl %ecx, %edx
movl %ebx, 0x34(%rsp)
movl %ebp, 0x30(%rsp)
jge 0x100d5
movl %r14d, %r15d
subl %ebx, %r15d
je 0x101fe
movl 0x4(%rsp), %eax
sarl %eax
movl 0x8(%rsp), %r13d
subl %eax, %r13d
movsbl %r8b, %eax
movl %eax, 0x14(%rsp)
movslq %r14d, %r14
movslq 0xc(%rsp), %rcx
addq %rcx, %r14
leaq 0x11367(%rip), %rax     # 0x21340
leaq (%rax,%r14,4), %rbp
movq %rcx, 0x28(%rsp)
leaq (,%rcx,4), %rax
movq %rax, 0x20(%rsp)
movq 0x10fe2(%rip), %rbx     # 0x20fd8
testl %r13d, %r13d
js 0x10016
cmpl $0x0, 0xc(%rsp)
jg 0x1000c
testl %r13d, %r13d
jne 0x1000c
xorl %r13d, %r13d
jmp 0x10016
addl 0x10(%rsp), %r12d
subl 0x4(%rsp), %r13d
movl $0x1, %ecx
movl %r12d, %eax
orl %r14d, %eax
js 0x1005d
cmpq $0x95, %r14
jg 0x1005d
cmpl $0x95, %r12d
jg 0x1005d
movslq %r12d, %rax
imulq $0x258, %rax, %rax      # imm = 0x258
movl (%rbp,%rax), %eax
addl $-0x2, %eax
cmpl $0xa, %eax
ja 0x1005b
movl $0x7fd, %ecx            # imm = 0x7FD
btl %eax, %ecx
movl $0x1, %eax
cmovbl %eax, %edi
movl %edi, %ecx
movq (%rbx), %rdi
movl %ecx, 0x18(%rsp)
movl %ecx, %eax
shll $0x8, %eax
movzwl %ax, %esi
xorl %edx, %edx
callq 0x5150
movq (%rbx), %rdi
movl 0x5e168(%rip), %eax     # 0x6e1e4
movl %r14d, %esi
subl %eax, %esi
addl $0xf, %esi
movl %r12d, 0x1c(%rsp)
subl 0x5e150(%rip), %r12d    # 0x6e1e0
addl $0x18, %r12d
movl %r12d, %edx
callq 0x5280
cmpl $-0x1, %eax
je 0x100ad
movq (%rbx), %rdi
movl 0x14(%rsp), %esi
callq 0x50a0
addl 0x8(%rsp), %r13d
addq 0x20(%rsp), %rbp
addq 0x28(%rsp), %r14
movl 0x18(%rsp), %edi
addl 0xc(%rsp), %r15d
movl 0x1c(%rsp), %r12d
jne 0xfff6
jmp 0x101fe
movl %r12d, %r15d
subl %ebp, %r15d
je 0x101fe
movl 0x8(%rsp), %eax
sarl %eax
movl 0x4(%rsp), %r13d
subl %eax, %r13d
movsbl %r8b, %eax
movl %eax, 0x14(%rsp)
movslq %r12d, %r12
movslq 0x10(%rsp), %rcx
addq %rcx, %r12
imulq $0x258, %r12, %rax      # imm = 0x258
leaq 0x11230(%rip), %rbp     # 0x21340
addq %rax, %rbp
movq %rcx, 0x28(%rsp)
imulq $0x258, %rcx, %rax      # imm = 0x258
movq %rax, 0x20(%rsp)
movq 0x10ead(%rip), %rbx     # 0x20fd8
testl %r13d, %r13d
js 0x1014b
cmpl $0x0, 0x10(%rsp)
jg 0x10141
testl %r13d, %r13d
jne 0x10141
xorl %r13d, %r13d
jmp 0x1014b
addl 0xc(%rsp), %r14d
subl 0x8(%rsp), %r13d
movl $0x1, %ecx
movl %r14d, %eax
orl %r12d, %eax
js 0x1018b
cmpq $0x95, %r12
jg 0x1018b
cmpl $0x95, %r14d
jg 0x1018b
movslq %r14d, %rax
movl (%rbp,%rax,4), %eax
addl $-0x2, %eax
cmpl $0xa, %eax
ja 0x10189
movl $0x7fd, %ecx            # imm = 0x7FD
btl %eax, %ecx
movl $0x1, %eax
cmovbl %eax, %edi
movl %edi, %ecx
movq (%rbx), %rdi
movl %ecx, 0x18(%rsp)
movl %ecx, %eax
shll $0x8, %eax
movzwl %ax, %esi
xorl %edx, %edx
callq 0x5150
movq (%rbx), %rdi
movl %r14d, 0x1c(%rsp)
subl 0x5e034(%rip), %r14d    # 0x6e1e4
addl $0xf, %r14d
movl 0x5e026(%rip), %eax     # 0x6e1e0
movl %r12d, %edx
subl %eax, %edx
addl $0x18, %edx
movl %r14d, %esi
callq 0x5280
cmpl $-0x1, %eax
je 0x101db
movq (%rbx), %rdi
movl 0x14(%rsp), %esi
callq 0x50a0
addl 0x4(%rsp), %r13d
addq 0x20(%rsp), %rbp
addq 0x28(%rsp), %r12
movl 0x18(%rsp), %edi
addl 0x10(%rsp), %r15d
movl 0x1c(%rsp), %r14d
jne 0x1012b
movl 0x30(%rsp), %esi
decl %esi
movl 0x34(%rsp), %edi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x51a0