// File: /workspace/github_cpp_makefile_star2_O2/lotuskip[P]yuxtapa/server/map.cpp
// Function: Map::LOS_between(Coords const&, Coords const&, char, short)
bool Map::LOS_between(const Coords& c1, const Coords& c2, const char maxrad,
	const short calced_rad)
{
	short r = (calced_rad == -1) ? c2.dist_walk(c1) : calced_rad;
	if(r <= maxrad) // close enough
	{
		// Check if there is a LOS between c1 and c2:
		if(r <= 1)
			return true; // seen, done
		// Construct vector from c1 to c2:
		Coords v(c2.x - c1.x, c2.y - c1.y);
		char line, ind;
		if(v.y == -r) line = v.x + r;
		else if(v.x == r) line = 3*r + v.y;
		else if(v.y == r) line = 5*r - v.x;
		else if(v.x == -r) line = 7*r - v.y;
		else /* v.x == -r */ line = 7*r - v.y;
		for(ind = 0; ind < 2*r; ind += 2)
		{
			if(!(data[loslookup[r-2][line*2*r+ind+1]+c1.y]
				[loslookup[r-2][line*2*r+ind]+c1.x].flags & TF_SEETHRU))
				break;
		}
		if(ind == 2*r) // got all the way!
			return true; // seen, done
		// else, need to check the opposite direction, the line from c2 to c1
		// (but only if the line is one of the unsymmetric ones):
		if(calced_rad == -1 && line%r)
			return LOS_between(c2, c1, maxrad, r);
	}
	return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, %r12d
movl %ecx, %r14d
movq %rsi, %rbx
movq %rdi, -0x38(%rbp)
movl %r12d, %r15d
cmpw $-0x1, %r12w
jne 0x12978
movq %rdx, %rdi
movq %rbx, %rsi
movq %rdx, %r15
callq 0x24dd8
movq %r15, %rdx
movl %eax, %r15d
movsbl %r14b, %eax
cmpw %ax, %r15w
jle 0x1298a
xorl %r14d, %r14d
jmp 0x12ac1
movb $0x1, %r14b
cmpw $0x2, %r15w
jl 0x12ac1
movl %eax, -0x30(%rbp)
movswl %r15w, %r13d
movzwl (%rdx), %eax
movq %rdx, -0x40(%rbp)
movzwl 0x2(%rdx), %ecx
subw (%rbx), %ax
subw 0x2(%rbx), %cx
movswl %ax, %esi
movswl %cx, %edx
leaq -0x2c(%rbp), %r14
movq %r14, %rdi
callq 0x24d90
movswl 0x2(%r14), %ecx
movl %ecx, %edx
movzwl (%r14), %eax
addl %r13d, %edx
jne 0x129d8
addl %r13d, %eax
jmp 0x129fe
cmpw %r15w, %ax
jne 0x129e7
leal (%r13,%r13,2), %eax
addl %eax, %ecx
jmp 0x129f4
cmpw %r15w, %cx
jne 0x129f8
leal (%r13,%r13,4), %ecx
subl %eax, %ecx
movl %ecx, %eax
jmp 0x129fe
imull $0x7, %r13d, %eax
subl %ecx, %eax
leal -0x2(%r13), %edx
shlq $0x2, %rdx
movq %r13, -0x48(%rbp)
leal (,%r13,2), %ecx
movsbl %al, %eax
movl %ecx, %edi
movswq 0x2(%rbx), %rsi
imulq $0x18, %rsi, %r8
movq -0x38(%rbp), %rsi
addq 0x8(%rsi), %r8
imull %eax, %edi
movswq (%rbx), %r9
xorl %esi, %esi
leaq 0x14288(%rip), %r10     # 0x26cc0
movsbl %sil, %esi
cmpl %ecx, %esi
jge 0x12a71
movslq (%rdx,%r10), %r11
addq %r10, %r11
leal (%rsi,%rdi), %r14d
movslq %r14d, %r14
movsbq 0x1(%r14,%r11), %r15
imulq $0x18, %r15, %r15
movsbq (%r14,%r11), %r11
shlq $0x2, %r11
addq (%r8,%r15), %r11
testb $0x4, (%r11,%r9,4)
je 0x12a71
addl $0x2, %esi
jmp 0x12a38
cmpl %ecx, %esi
setne %r15b
movb $0x1, %r14b
cmpw $-0x1, %r12w
jne 0x12aaf
cmpl %ecx, %esi
je 0x12aaf
cltd
movq -0x48(%rbp), %r8
idivl %r8d
testl %edx, %edx
je 0x12aac
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq %rbx, %rdx
movl -0x30(%rbp), %ecx
callq 0x1293c
movl %eax, %r14d
xorl %r15d, %r15d
jmp 0x12aaf
movb $0x1, %r15b
leaq -0x2c(%rbp), %rdi
callq 0x24d9e
testb %r15b, %r15b
jne 0x12982
andb $0x1, %r14b
movl %r14d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x2c(%rbp), %rdi
callq 0x24d9e
movq %rbx, %rdi
callq 0x4710
nop