// File: cauimsouza[P]rikudo-solver/src/rikudo_solver/main.cpp
// Function: count_path_between_corners(int)
void count_path_between_corners(int n){
    if(n <= 2){
        std::cout << n << std::endl;
        return;
    }

    std::vector<std::vector<int>> adj_list(n*n, std::vector<int>());

    int di[] = {1,0,-1,0};
    int dj[] = {0,1,0,-1};
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            for(int k = 0; k < 4; k++) {
                int ii = i + di[k];
                int jj = j + dj[k];
                if (ii >= 0 && ii < n && jj >= 0 && jj < n)
                    adj_list[ i*n+j ].push_back( ii*n+jj );
            }

    Graph graph(adj_list);
    auto paths = graph.ham_path(0, n*n-1);
    printf("Number of paths: %d\n", (int) paths.size());
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
movl %edi, -0x4(%rbp)
cmpl $0x2, -0x4(%rbp)
jg 0x3627
movl -0x4(%rbp), %esi
movq 0x169c2(%rip), %rdi     # 0x19fd0
callq 0x33f0
movq %rax, %rdi
movq 0x1699b(%rip), %rsi     # 0x19fb8
callq 0x3250
jmp 0x3954
movl -0x4(%rbp), %eax
imull %eax, %eax
movq %rax, -0x1a8(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movq $0x0, -0x30(%rbp)
leaq -0x40(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
callq 0x4300
leaq -0x41(%rbp), %rdi
movq %rdi, -0x198(%rbp)
callq 0x4320
movq -0x1a8(%rbp), %rsi
movq -0x1a0(%rbp), %rdx
movq -0x198(%rbp), %rcx
leaq -0x20(%rbp), %rdi
callq 0x4340
jmp 0x3683
leaq -0x41(%rbp), %rdi
callq 0x43c0
leaq -0x40(%rbp), %rdi
callq 0x43e0
movq 0xf974(%rip), %rax      # 0x13010
movq %rax, -0x70(%rbp)
movq 0xf971(%rip), %rax      # 0x13018
movq %rax, -0x68(%rbp)
movq 0xf96e(%rip), %rax      # 0x13020
movq %rax, -0x80(%rbp)
movq 0xf96b(%rip), %rax      # 0x13028
movq %rax, -0x78(%rbp)
movl $0x0, -0x84(%rbp)
movl -0x84(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x3833
movl $0x0, -0x88(%rbp)
movl -0x88(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x381d
movl $0x0, -0x8c(%rbp)
cmpl $0x4, -0x8c(%rbp)
jge 0x3807
movl -0x84(%rbp), %eax
movslq -0x8c(%rbp), %rcx
addl -0x70(%rbp,%rcx,4), %eax
movl %eax, -0x90(%rbp)
movl -0x88(%rbp), %eax
movslq -0x8c(%rbp), %rcx
addl -0x80(%rbp,%rcx,4), %eax
movl %eax, -0x94(%rbp)
cmpl $0x0, -0x90(%rbp)
jl 0x37f1
movl -0x90(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x37f1
cmpl $0x0, -0x94(%rbp)
jl 0x37f1
movl -0x94(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x37f1
movl -0x84(%rbp), %eax
movl -0x4(%rbp), %ecx
imull %ecx, %eax
movl -0x88(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
leaq -0x20(%rbp), %rdi
callq 0x4440
movq %rax, %rdi
movl -0x90(%rbp), %eax
movl -0x4(%rbp), %ecx
imull %ecx, %eax
movl -0x94(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x98(%rbp)
leaq -0x98(%rbp), %rsi
callq 0x4460
jmp 0x37bb
jmp 0x37f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x41(%rbp), %rdi
callq 0x43c0
leaq -0x40(%rbp), %rdi
callq 0x43e0
jmp 0x39b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x39a7
jmp 0x37f3
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x36fd
jmp 0x3809
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
jmp 0x36e4
jmp 0x381f
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x36cb
leaq -0x140(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x6c90
jmp 0x3845
movl -0x4(%rbp), %eax
imull %eax, %eax
decl %eax
movl %eax, -0x1bc(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x1e0(%rbp)
movaps %xmm0, -0x170(%rbp)
movq $0x0, -0x160(%rbp)
leaq -0x170(%rbp), %rdi
movq %rdi, -0x1b8(%rbp)
callq 0x4490
movaps -0x1e0(%rbp), %xmm0
movaps %xmm0, -0x190(%rbp)
movq $0x0, -0x180(%rbp)
leaq -0x190(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0x4490
movq -0x1c8(%rbp), %rcx
movl -0x1bc(%rbp), %edx
movq -0x1b8(%rbp), %r9
movq %rsp, %rax
movq %rcx, (%rax)
leaq -0x140(%rbp), %rdi
movl $0x1, %ecx
xorl %r8d, %r8d
movl %r8d, %esi
callq 0x9f70
movq %rax, -0x1b0(%rbp)
jmp 0x38e8
movq -0x1b0(%rbp), %rsi
leaq -0x158(%rbp), %rdi
callq 0x44b0
jmp 0x38fd
leaq -0x190(%rbp), %rdi
callq 0x45a0
leaq -0x170(%rbp), %rdi
callq 0x45a0
leaq -0x158(%rbp), %rdi
callq 0x4600
movl %eax, %esi
leaq 0xf706(%rip), %rdi      # 0x13030
xorl %eax, %eax
callq 0x3040
jmp 0x3933
leaq -0x158(%rbp), %rdi
callq 0x4630
leaq -0x140(%rbp), %rdi
callq 0x4690
leaq -0x20(%rbp), %rdi
callq 0x4630
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x45a0
leaq -0x170(%rbp), %rdi
callq 0x45a0
jmp 0x399b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x4630
leaq -0x140(%rbp), %rdi
callq 0x4690
leaq -0x20(%rbp), %rdi
callq 0x4630
movq -0x50(%rbp), %rdi
callq 0x3400
nopl (%rax)