// File: /workspace/github_cpp_makefile_star2_O3/Alcaro[P]bridges/solver.cpp
// Function: (anonymous namespace)::linker::lookback(gamemap&, unsigned short, unsigned short, unsigned short&, bool&)
void lookback(gamemap& map, uint16_t link, uint16_t orig, uint16_t& topleft, bool& down)
	{
		gamemap::island& here = map.get(link);
		link_t& lhere = links[link];
		orig = root(orig);
		
		if (lhere.links[0] != (uint16_t)-1 && root(lhere.links[0]) == orig)
		{
			topleft = link;
			down = false;
			return;
		}
		
		if (lhere.links[1] != (uint16_t)-1 && root(lhere.links[1]) == orig)
		{
			topleft = link - here.bridgelen[1]*100;
			down = true;
			return;
		}
		
		if (lhere.links[2] != (uint16_t)-1 && root(lhere.links[2]) == orig)
		{
			topleft = link - here.bridgelen[2];
			down = false;
			return;
		}
		
		if (lhere.links[3] != (uint16_t)-1 && root(lhere.links[3]) == orig)
		{
			topleft = link;
			down = true;
			return;
		}
		
		abort(); // unreachable
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %eax
shrl $0x2, %eax
imull $0x147b, %eax, %r11d    # imm = 0x147B
shrl $0x11, %r11d
imull $0x64, %r11d, %eax
movl %edx, %r10d
movl %edx, %ebx
subl %eax, %ebx
movzwl %bx, %ebx
movl %ecx, %ebp
movl %ebp, %eax
movzwl %bp, %r14d
movl %r14d, %r15d
shll $0x4, %r15d
movzwl 0x8(%rdi,%r15), %ebp
cmpw %bp, %r14w
jne 0x288a1
shll $0x4, %r10d
addq %rdi, %r10
cmpw %cx, %ax
je 0x288df
movzwl %cx, %r14d
shll $0x4, %r14d
movzwl 0x8(%rdi,%r14), %ecx
movw %ax, 0x8(%rdi,%r14)
cmpw %ax, %cx
jne 0x288c6
movzwl (%r10), %ecx
cmpw $-0x1, %cx
je 0x2892d
movl %ecx, %r14d
movl %r14d, %ebp
movzwl %r14w, %r15d
movl %r15d, %r14d
shll $0x4, %r14d
movzwl 0x8(%rdi,%r14), %r14d
cmpw %r14w, %r15w
jne 0x288ec
cmpw %cx, %bp
je 0x28924
movzwl %cx, %r14d
shll $0x4, %r14d
movzwl 0x8(%rdi,%r14), %ecx
movw %bp, 0x8(%rdi,%r14)
cmpw %bp, %cx
jne 0x2890b
cmpw %ax, %bp
je 0x289e7
movzwl %r11w, %ecx
imulq $0x4b0, %rcx, %rcx      # imm = 0x4B0
addq %rcx, %rsi
leaq (%rbx,%rbx,2), %rcx
leaq (%rsi,%rcx,4), %rcx
addq $0xc, %rcx
movzwl 0x2(%r10), %esi
cmpw $-0x1, %si
je 0x2899c
movl %esi, %ebx
movl %ebx, %r11d
movzwl %bx, %ebp
movl %ebp, %ebx
shll $0x4, %ebx
movzwl 0x8(%rdi,%rbx), %ebx
cmpw %bx, %bp
jne 0x28954
cmpw %si, %r11w
je 0x28986
movzwl %si, %ebx
shll $0x4, %ebx
movzwl 0x8(%rdi,%rbx), %esi
movw %r11w, 0x8(%rdi,%rbx)
cmpw %r11w, %si
jne 0x2896f
cmpw %ax, %r11w
jne 0x2899c
movsbl 0x5(%rcx), %eax
imull $-0x64, %eax, %eax
addl %eax, %edx
movb $0x1, %cl
jmp 0x28a38
movzwl 0x4(%r10), %esi
cmpw $-0x1, %si
je 0x289eb
movl %esi, %ebx
movl %ebx, %r11d
movzwl %bx, %ebp
movl %ebp, %ebx
shll $0x4, %ebx
movzwl 0x8(%rdi,%rbx), %ebx
cmpw %bx, %bp
jne 0x289a9
cmpw %si, %r11w
je 0x289db
movzwl %si, %ebx
shll $0x4, %ebx
movzwl 0x8(%rdi,%rbx), %esi
movw %r11w, 0x8(%rdi,%rbx)
cmpw %r11w, %si
jne 0x289c4
cmpw %ax, %r11w
jne 0x289eb
movsbl 0x6(%rcx), %eax
subl %eax, %edx
xorl %ecx, %ecx
jmp 0x28a38
movzwl 0x6(%r10), %ecx
cmpw $-0x1, %cx
je 0x28a4a
movl %ecx, %r10d
movl %r10d, %esi
movzwl %r10w, %r11d
movl %r11d, %r10d
shll $0x4, %r10d
movzwl 0x8(%rdi,%r10), %r10d
cmpw %r10w, %r11w
jne 0x289f9
cmpw %cx, %si
je 0x28a31
movzwl %cx, %r10d
shll $0x4, %r10d
movzwl 0x8(%rdi,%r10), %ecx
movw %si, 0x8(%rdi,%r10)
cmpw %si, %cx
jne 0x28a18
movb $0x1, %cl
cmpw %ax, %si
jne 0x28a4a
movw %dx, (%r8)
movb %cl, (%r9)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0x3180
nop