// File: /workspace/github_cpp_makefile_star2_O1/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, %r10d
imulq $0x28f5c29, %r10, %rbx  # imm = 0x28F5C29
shrq $0x20, %rbx
imull $0x64, %ebx, %eax
movl %edx, %r11d
subl %eax, %r11d
movl %ecx, %ebp
movl %ebp, %eax
movzwl %bp, %r14d
movl %r14d, %r15d
shll $0x4, %r15d
movzwl 0x8(%rdi,%r15), %ebp
cmpw %bp, %r14w
jne 0x282d8
shll $0x4, %r10d
addq %rdi, %r10
cmpw %cx, %ax
je 0x28316
movzwl %cx, %r14d
shll $0x4, %r14d
movzwl 0x8(%rdi,%r14), %ecx
movw %ax, 0x8(%rdi,%r14)
cmpw %ax, %cx
jne 0x282fd
movzwl (%r10), %ecx
cmpw $-0x1, %cx
je 0x28364
movl %ecx, %r14d
movl %r14d, %ebp
movzwl %r14w, %r15d
movl %r15d, %r14d
shll $0x4, %r14d
movzwl 0x8(%rdi,%r14), %r14d
cmpw %r14w, %r15w
jne 0x28323
cmpw %cx, %bp
je 0x2835b
movzwl %cx, %r14d
shll $0x4, %r14d
movzwl 0x8(%rdi,%r14), %ecx
movw %bp, 0x8(%rdi,%r14)
cmpw %bp, %cx
jne 0x28342
cmpw %ax, %bp
je 0x2841c
movl %ebx, %ecx
imulq $0x4b0, %rcx, %rcx      # imm = 0x4B0
addq %rcx, %rsi
leaq (%r11,%r11,2), %rcx
leaq (%rsi,%rcx,4), %rcx
addq $0xc, %rcx
movzwl 0x2(%r10), %esi
cmpw $-0x1, %si
je 0x283d1
movl %esi, %ebx
movl %ebx, %r11d
movzwl %bx, %ebp
movl %ebp, %ebx
shll $0x4, %ebx
movzwl 0x8(%rdi,%rbx), %ebx
cmpw %bx, %bp
jne 0x28389
cmpw %si, %r11w
je 0x283bb
movzwl %si, %ebx
shll $0x4, %ebx
movzwl 0x8(%rdi,%rbx), %esi
movw %r11w, 0x8(%rdi,%rbx)
cmpw %r11w, %si
jne 0x283a4
cmpw %ax, %r11w
jne 0x283d1
movsbl 0x5(%rcx), %eax
imull $-0x64, %eax, %eax
addl %eax, %edx
movb $0x1, %cl
jmp 0x2846d
movzwl 0x4(%r10), %esi
cmpw $-0x1, %si
je 0x28420
movl %esi, %ebx
movl %ebx, %r11d
movzwl %bx, %ebp
movl %ebp, %ebx
shll $0x4, %ebx
movzwl 0x8(%rdi,%rbx), %ebx
cmpw %bx, %bp
jne 0x283de
cmpw %si, %r11w
je 0x28410
movzwl %si, %ebx
shll $0x4, %ebx
movzwl 0x8(%rdi,%rbx), %esi
movw %r11w, 0x8(%rdi,%rbx)
cmpw %r11w, %si
jne 0x283f9
cmpw %ax, %r11w
jne 0x28420
movsbl 0x6(%rcx), %eax
subl %eax, %edx
xorl %ecx, %ecx
jmp 0x2846d
movzwl 0x6(%r10), %ecx
cmpw $-0x1, %cx
je 0x2847f
movl %ecx, %r10d
movl %r10d, %esi
movzwl %r10w, %r11d
movl %r11d, %r10d
shll $0x4, %r10d
movzwl 0x8(%rdi,%r10), %r10d
cmpw %r10w, %r11w
jne 0x2842e
cmpw %cx, %si
je 0x28466
movzwl %cx, %r10d
shll $0x4, %r10d
movzwl 0x8(%rdi,%r10), %ecx
movw %si, 0x8(%rdi,%r10)
cmpw %si, %cx
jne 0x2844d
movb $0x1, %cl
cmpw %ax, %si
jne 0x2847f
movw %dx, (%r8)
movb %cl, (%r9)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0x3180