// File: cauimsouza[P]rikudo-solver/src/rikudo_solver/graph.cpp
// Function: Graph::valid(std::vector<int, std::allocator<int>> const&, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int>>> const&, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int>>> const&)
bool Graph::valid(const std::vector<int> &candidate,
                  const std::vector< std::pair<int,int> >& map,
                  const std::vector< std::pair<int,int> >& diamonds)
{    
    for(auto pair : map){
        int ith = pair.first;
        int vertex = pair.second;
        if(candidate[ith] != vertex)    return false;
    }

    for(auto pair : diamonds){
        int u = pair.first;
        int v = pair.second;
        for(int ith = 0; ith < candidate.size(); ith++)
            if(candidate[ith] == u){
                if(ith > 0 && candidate[ith-1] == v)    continue;
                if(ith < candidate.size() - 1 && candidate[ith+1] == v) continue;
                return false;
            }
    }

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0xb010
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
callq 0xb040
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0xb070
testb $0x1, %al
jne 0x68e0
jmp 0x6926
leaq -0x38(%rbp), %rdi
callq 0xb0b0
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x50(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x4c(%rbp), %rsi
callq 0xb0d0
movl (%rax), %eax
cmpl -0x50(%rbp), %eax
je 0x6919
movb $0x0, -0x1(%rbp)
jmp 0x6a49
jmp 0x691b
leaq -0x38(%rbp), %rdi
callq 0xb0f0
jmp 0x68cd
movq -0x28(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0xb010
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rdi
callq 0xb040
movq %rax, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0xb070
testb $0x1, %al
jne 0x695e
jmp 0x6a45
leaq -0x60(%rbp), %rdi
callq 0xb0b0
movq (%rax), %rax
movq %rax, -0x70(%rbp)
movl -0x70(%rbp), %eax
movl %eax, -0x74(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, -0x78(%rbp)
movl $0x0, -0x7c(%rbp)
movslq -0x7c(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5460
movq %rax, %rcx
movq -0x88(%rbp), %rax
cmpq %rcx, %rax
jae 0x6a35
movq -0x18(%rbp), %rdi
movslq -0x7c(%rbp), %rsi
callq 0xb0d0
movl (%rax), %eax
cmpl -0x74(%rbp), %eax
jne 0x6a25
cmpl $0x0, -0x7c(%rbp)
jle 0x69dd
movq -0x18(%rbp), %rdi
movl -0x7c(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0xb0d0
movl (%rax), %eax
cmpl -0x78(%rbp), %eax
jne 0x69dd
jmp 0x6a27
movslq -0x7c(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5460
movq %rax, %rcx
movq -0x90(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0x6a1f
movq -0x18(%rbp), %rdi
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0xb0d0
movl (%rax), %eax
cmpl -0x78(%rbp), %eax
jne 0x6a1f
jmp 0x6a27
movb $0x0, -0x1(%rbp)
jmp 0x6a49
jmp 0x6a27
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x6981
jmp 0x6a37
leaq -0x60(%rbp), %rdi
callq 0xb0f0
jmp 0x6948
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x90, %rsp
popq %rbp
retq
nopw (%rax,%rax)