// File: Alcaro[P]bridges/solver.cpp
// Function: (anonymous namespace)::solver<((anonymous namespace)::op_t)3>::assign()
void assign()
	{
		for (int y=0;y<map.height;y++)
		for (int x=0;x<map.width;x++)
		{
			uint16_t flags = possibilities[y*100+x];
			
			uint8_t nright = !(flags&0x0001) + !(flags&0x0011) + !(flags&0x0111);
			uint8_t ndown  = !(flags&0x0008) + !(flags&0x0088) + !(flags&0x0888);
//printf("IX=%.3i FL=%.4X BR=%i BD=%i\n",y*100+x,flags,nright,ndown);
			
			while (map.map[y][x].bridges[0] != nright) map.toggle(x, y, 0);
			while (map.map[y][x].bridges[3] != ndown)  map.toggle(x, y, 3);
		}
		
#ifndef STDOUT_ERROR
		if (!map.finished())
		{
			puts("ERROR: solver returned bad solution");
			puts(map.serialize());
#ifdef ARLIB_TEST
			assert(false);
#else
			abort();
#endif
		}
#endif
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0xc(%rbp)
movq -0x30(%rbp), %rcx
movl -0xc(%rbp), %eax
movq (%rcx), %rcx
cmpl 0x4(%rcx), %eax
jge 0x5525c
movl $0x0, -0x10(%rbp)
movq -0x30(%rbp), %rcx
movl -0x10(%rbp), %eax
movq (%rcx), %rcx
cmpl (%rcx), %eax
jge 0x5524c
movq -0x30(%rbp), %rax
movq 0x4e28(%rax), %rax
imull $0x64, -0xc(%rbp), %ecx
addl -0x10(%rbp), %ecx
movslq %ecx, %rcx
movw (%rax,%rcx,2), %ax
movw %ax, -0x12(%rbp)
movzwl -0x12(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movzwl -0x12(%rbp), %ecx
andl $0x11, %ecx
cmpl $0x0, %ecx
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
addl %ecx, %eax
movzwl -0x12(%rbp), %ecx
andl $0x111, %ecx            # imm = 0x111
cmpl $0x0, %ecx
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
addl %ecx, %eax
movb %al, -0x13(%rbp)
movzwl -0x12(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movzwl -0x12(%rbp), %ecx
andl $0x88, %ecx
cmpl $0x0, %ecx
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
addl %ecx, %eax
movzwl -0x12(%rbp), %ecx
andl $0x888, %ecx            # imm = 0x888
cmpl $0x0, %ecx
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
addl %ecx, %eax
movb %al, -0x14(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
addq $0xc, %rax
movslq -0xc(%rbp), %rcx
imulq $0x4b0, %rcx, %rcx      # imm = 0x4B0
addq %rcx, %rax
movslq -0x10(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movzbl 0x8(%rax), %eax
movzbl -0x13(%rbp), %ecx
cmpl %ecx, %eax
je 0x551f1
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movl -0x10(%rbp), %esi
movl -0xc(%rbp), %edx
xorl %ecx, %ecx
callq 0x4f0b0
jmp 0x551ab
jmp 0x551f3
movq -0x30(%rbp), %rax
movq (%rax), %rax
addq $0xc, %rax
movslq -0xc(%rbp), %rcx
imulq $0x4b0, %rcx, %rcx      # imm = 0x4B0
addq %rcx, %rax
movslq -0x10(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movzbl 0xb(%rax), %eax
movzbl -0x14(%rbp), %ecx
cmpl %ecx, %eax
je 0x5523c
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movl -0x10(%rbp), %esi
movl -0xc(%rbp), %edx
movl $0x3, %ecx
callq 0x4f0b0
jmp 0x551f3
jmp 0x5523e
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x550e5
jmp 0x5524e
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x550cb
movq -0x30(%rbp), %rax
movq (%rax), %rdi
callq 0x4f4a0
testb $0x1, %al
jne 0x552a7
leaq 0x11bc1(%rip), %rdi     # 0x66e34
callq 0x4580
movq -0x30(%rbp), %rax
movq (%rax), %rsi
leaq -0x28(%rbp), %rdi
callq 0x4f7f0
leaq -0x28(%rbp), %rdi
callq 0x5660
movq %rax, %rdi
callq 0x4580
leaq -0x28(%rbp), %rdi
callq 0x5870
callq 0x4180
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)