// File: /workspace/github_cpp_makefile_star2_O2/grogers0[P]dots_and_boxes/BasicMoveDeciders.cpp
// Function: Board::decide_move_nocheap()
Edge Board::decide_move_nocheap()
{
    std::vector<Edge> take_square_moves, give_square_moves, other_moves;

    std::for_each(edge_begin(), edge_end(), [&] (Edge edge)
            {
                if (!this->is_move_valid(edge))
                    return;
                bool take_square = false, give_square = false;
                this->for_each_adjacent_node(edge, [&] (const Node &node)
                    {
                        switch (this->degree(node)) {
                            case 3: take_square = true; break;
                            case 2: give_square = true; break;
                        }
                    });
                if (take_square) {
                    take_square_moves.push_back(edge);
                } else if (give_square) {
                    give_square_moves.push_back(edge);
                } else {
                    other_moves.push_back(edge);
                }
            });

    if (!take_square_moves.empty()) {
        return take_square_moves.front();
    } else {
        int r = 0;

        int fd = open("/dev/urandom", O_RDONLY);
        read(fd, &r, sizeof(r));
        close(fd);

        if (!other_moves.empty()) {
            return other_moves[r % other_moves.size()];
        } else {
            assert(!give_square_moves.empty());
            return give_square_moves[r % give_square_moves.size()];
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdi, %r13
xorps %xmm0, %xmm0
leaq 0x90(%rsp), %rax
andq $0x0, 0x10(%rax)
leaq 0x70(%rsp), %rcx
andq $0x0, 0x10(%rcx)
movaps %xmm0, (%rax)
movaps %xmm0, (%rcx)
leaq 0x50(%rsp), %rdx
movaps %xmm0, (%rdx)
andq $0x0, 0x10(%rdx)
movl (%rdi), %esi
movl 0x4(%rdi), %edi
shlq $0x20, %rsi
movq %rax, 0x38(%rsp)
movq %rcx, 0x40(%rsp)
movq %rdx, 0x48(%rsp)
leaq 0x20(%rsp), %r14
movq %rsi, (%r14)
movl %edi, 0x8(%r14)
xorl %ebp, %ebp
movq %rsp, %r12
xorl %eax, %eax
testb $0x1, %al
sete %cl
cmpw $-0x2, %ax
setae %al
testb %cl, %al
jne 0x3e9f
movl 0x20(%rsp), %ebx
movl %ebx, 0x4(%rsp)
movq %r13, %rdi
movl %ebx, %esi
callq 0x26a4
testb %al, %al
je 0x3e8d
movb %bpl, 0x3(%rsp)
movb %bpl, 0x2(%rsp)
movq %r13, 0x8(%rsp)
leaq 0x3(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x2(%rsp), %rax
movq %rax, 0x18(%rsp)
testb $0x1, %bl
jne 0x3e1a
movswl %bx, %r15d
movl %r15d, %eax
shrl $0x8, %eax
sarl $0x8, %r15d
testw %ax, %ax
jle 0x3df8
movsbl %bl, %eax
shrl %eax
movb %al, (%rsp)
leal -0x1(%r15), %eax
movb %al, 0x1(%rsp)
leaq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x3f94
cmpl %r15d, 0x4(%r13)
jle 0x3e5e
movsbl %bl, %eax
shrl %eax
movb %al, (%rsp)
movb %r15b, 0x1(%rsp)
leaq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x3f94
jmp 0x3e5e
movsbl %bl, %r15d
movl %r15d, %eax
shrl %eax
sarl %r15d
testw %ax, %ax
jle 0x3e43
leal -0x1(%r15), %eax
movb %al, (%rsp)
movb %bh, 0x1(%rsp)
leaq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x3f94
cmpl %r15d, (%r13)
jle 0x3e5e
movb %r15b, (%rsp)
movb %bh, 0x1(%rsp)
leaq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x3f94
movb 0x2(%rsp), %al
notb %al
movzbl %al, %eax
andl $0x1, %eax
cmpb $0x0, 0x3(%rsp)
leaq 0x10(,%rax,8), %rax
pushq $0x8
popq %rcx
cmovneq %rcx, %rax
movq 0x30(%rsp,%rax), %rdi
leaq 0x4(%rsp), %rsi
callq 0x405a
movq %r14, %rdi
callq 0x3ff2
movzwl 0x20(%rsp), %eax
jmp 0x3d72
movq 0x90(%rsp), %rax
cmpq 0x98(%rsp), %rax
je 0x3eb5
movl (%rax), %ebx
jmp 0x3f14
andl $0x0, 0x30(%rsp)
leaq 0x1457(%rip), %rdi      # 0x5318
xorl %esi, %esi
xorl %eax, %eax
callq 0x2170
movl %eax, %ebx
leaq 0x30(%rsp), %rsi
pushq $0x4
popq %rdx
movl %eax, %edi
callq 0x22a0
movl %ebx, %edi
callq 0x23c0
movq 0x50(%rsp), %rcx
movq 0x58(%rsp), %rsi
cmpq %rsi, %rcx
jne 0x3f00
movq 0x70(%rsp), %rcx
movq 0x78(%rsp), %rsi
cmpq %rsi, %rcx
je 0x3f49
movslq 0x30(%rsp), %rax
subq %rcx, %rsi
sarq $0x2, %rsi
xorl %edx, %edx
divq %rsi
movl (%rcx,%rdx,4), %ebx
leaq 0x50(%rsp), %rdi
callq 0x3fbe
leaq 0x70(%rsp), %rdi
callq 0x3fbe
leaq 0x90(%rsp), %rdi
callq 0x3fbe
movl %ebx, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x13d5(%rip), %rdi      # 0x5325
leaq 0x13e9(%rip), %rsi      # 0x5340
leaq 0x13f8(%rip), %rcx      # 0x5356
pushq $0x56
popq %rdx
callq 0x2130
jmp 0x3f68
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x3fbe
leaq 0x70(%rsp), %rdi
callq 0x3fbe
leaq 0x90(%rsp), %rdi
callq 0x3fbe
movq %rbx, %rdi
callq 0x2350