// File: camargodev[P]n-tile-puzzle/src/StateManager.cpp
// Function: StateManager::getNeighborsPositionsAndHeuristics(State)
vector<pair<int, int>> StateManager :: getNeighborsPositionsAndHeuristics(State state) {
    vector<pair<int, int>> neighbors;
    int blankPosition = getBlankTilePosition(state.value);
    int numberOfTiles = getNumberOfTiles(state.value);
    if (blankPosition < numberOfTiles*(numberOfTiles-1)) {
        int newPosition = blankPosition+numberOfTiles;
        if (newPosition != state.parentBlankPos) {
            int heuristic = calculateNeighborHeuristic(state, blankPosition, newPosition);
            neighbors.insert(neighbors.begin(), make_pair(newPosition, heuristic));
        }
    }
    if ((blankPosition+1) % numberOfTiles != 0) {
        int newPosition = blankPosition+1;
        if (newPosition != state.parentBlankPos) {
            int heuristic = calculateNeighborHeuristic(state, blankPosition, newPosition);
            neighbors.insert(neighbors.begin(), make_pair(newPosition, heuristic));
        }
    }
    if (blankPosition % numberOfTiles != 0) {
        int newPosition = blankPosition-1;
        if (newPosition != state.parentBlankPos) {
            int heuristic = calculateNeighborHeuristic(state, blankPosition, newPosition);
            neighbors.insert(neighbors.begin(), make_pair(newPosition, heuristic));
        }
    }
    if (blankPosition > numberOfTiles-1) {
        int newPosition = blankPosition-numberOfTiles;
        if (newPosition != state.parentBlankPos) {
            int heuristic = calculateNeighborHeuristic(state, blankPosition, newPosition);
            neighbors.insert(neighbors.begin(), make_pair(newPosition, heuristic));
        }
    }
    return neighbors;
}

// Assembly:
subq $0x1b8, %rsp            # imm = 0x1B8
movq %rdi, 0x60(%rsp)
movq %rdi, %rax
movq %rax, 0x68(%rsp)
movq %rdi, 0x1b0(%rsp)
movq %rdx, 0x1a0(%rsp)
movq %rcx, 0x1a8(%rsp)
movq %rsi, 0x198(%rsp)
movq 0x198(%rsp), %rax
movq %rax, 0x70(%rsp)
movb $0x0, 0x197(%rsp)
callq 0x7900
movq 0x70(%rsp), %rdi
movq 0x1a0(%rsp), %rsi
callq 0x5e80
movl %eax, 0x7c(%rsp)
jmp 0x5f96
movq 0x70(%rsp), %rdi
movl 0x7c(%rsp), %eax
movl %eax, 0x190(%rsp)
movq 0x1a0(%rsp), %rsi
callq 0x5690
movl %eax, 0x5c(%rsp)
jmp 0x5fb9
movl 0x5c(%rsp), %eax
movl %eax, 0x180(%rsp)
movl 0x190(%rsp), %eax
movl 0x180(%rsp), %ecx
movl 0x180(%rsp), %edx
subl $0x1, %edx
imull %edx, %ecx
cmpl %ecx, %eax
jge 0x6102
movl 0x190(%rsp), %eax
addl 0x180(%rsp), %eax
movl %eax, 0x17c(%rsp)
movl 0x17c(%rsp), %eax
movzbl 0x1a9(%rsp), %ecx
cmpl %ecx, %eax
je 0x6100
movq 0x70(%rsp), %rdi
movups 0x1a0(%rsp), %xmm0
movaps %xmm0, 0x160(%rsp)
movl 0x190(%rsp), %ecx
movl 0x17c(%rsp), %r8d
movq 0x160(%rsp), %rsi
movq 0x168(%rsp), %rdx
callq 0x6a10
movl %eax, 0x58(%rsp)
jmp 0x6052
movq 0x60(%rsp), %rdi
movl 0x58(%rsp), %eax
movl %eax, 0x178(%rsp)
callq 0x7020
movq %rax, 0x150(%rsp)
leaq 0x158(%rsp), %rdi
leaq 0x150(%rsp), %rsi
callq 0x7950
leaq 0x17c(%rsp), %rdi
leaq 0x178(%rsp), %rsi
callq 0x7990
movq %rax, 0x50(%rsp)
jmp 0x60a0
movq 0x60(%rsp), %rdi
movq 0x50(%rsp), %rax
movq %rax, 0x148(%rsp)
movq 0x158(%rsp), %rsi
leaq 0x148(%rsp), %rdx
callq 0x7910
movq %rax, 0x48(%rsp)
jmp 0x60ce
movq 0x48(%rsp), %rax
movq %rax, 0x140(%rsp)
jmp 0x6100
movq 0x60(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
callq 0x7380
jmp 0x644f
jmp 0x6102
movl 0x190(%rsp), %eax
addl $0x1, %eax
cltd
idivl 0x180(%rsp)
cmpl $0x0, %edx
je 0x620f
movl 0x190(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x13c(%rsp)
movl 0x13c(%rsp), %eax
movzbl 0x1a9(%rsp), %ecx
cmpl %ecx, %eax
je 0x620d
movq 0x70(%rsp), %rdi
movups 0x1a0(%rsp), %xmm0
movaps %xmm0, 0x120(%rsp)
movl 0x190(%rsp), %ecx
movl 0x13c(%rsp), %r8d
movq 0x120(%rsp), %rsi
movq 0x128(%rsp), %rdx
callq 0x6a10
movl %eax, 0x44(%rsp)
jmp 0x6184
movq 0x60(%rsp), %rdi
movl 0x44(%rsp), %eax
movl %eax, 0x138(%rsp)
callq 0x7020
movq %rax, 0x110(%rsp)
leaq 0x118(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x7950
leaq 0x13c(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x7990
movq %rax, 0x38(%rsp)
jmp 0x61d2
movq 0x60(%rsp), %rdi
movq 0x38(%rsp), %rax
movq %rax, 0x108(%rsp)
movq 0x118(%rsp), %rsi
leaq 0x108(%rsp), %rdx
callq 0x7910
movq %rax, 0x30(%rsp)
jmp 0x6200
movq 0x30(%rsp), %rax
movq %rax, 0x100(%rsp)
jmp 0x620f
movl 0x190(%rsp), %eax
cltd
idivl 0x180(%rsp)
cmpl $0x0, %edx
je 0x6319
movl 0x190(%rsp), %eax
subl $0x1, %eax
movl %eax, 0xfc(%rsp)
movl 0xfc(%rsp), %eax
movzbl 0x1a9(%rsp), %ecx
cmpl %ecx, %eax
je 0x6317
movq 0x70(%rsp), %rdi
movups 0x1a0(%rsp), %xmm0
movaps %xmm0, 0xe0(%rsp)
movl 0x190(%rsp), %ecx
movl 0xfc(%rsp), %r8d
movq 0xe0(%rsp), %rsi
movq 0xe8(%rsp), %rdx
callq 0x6a10
movl %eax, 0x2c(%rsp)
jmp 0x628e
movq 0x60(%rsp), %rdi
movl 0x2c(%rsp), %eax
movl %eax, 0xf8(%rsp)
callq 0x7020
movq %rax, 0xd0(%rsp)
leaq 0xd8(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x7950
leaq 0xfc(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0x7990
movq %rax, 0x20(%rsp)
jmp 0x62dc
movq 0x60(%rsp), %rdi
movq 0x20(%rsp), %rax
movq %rax, 0xc8(%rsp)
movq 0xd8(%rsp), %rsi
leaq 0xc8(%rsp), %rdx
callq 0x7910
movq %rax, 0x18(%rsp)
jmp 0x630a
movq 0x18(%rsp), %rax
movq %rax, 0xc0(%rsp)
jmp 0x6319
movl 0x190(%rsp), %eax
movl 0x180(%rsp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jle 0x6426
movl 0x190(%rsp), %eax
subl 0x180(%rsp), %eax
movl %eax, 0xbc(%rsp)
movl 0xbc(%rsp), %eax
movzbl 0x1a9(%rsp), %ecx
cmpl %ecx, %eax
je 0x6424
movq 0x70(%rsp), %rdi
movups 0x1a0(%rsp), %xmm0
movaps %xmm0, 0xa0(%rsp)
movl 0x190(%rsp), %ecx
movl 0xbc(%rsp), %r8d
movq 0xa0(%rsp), %rsi
movq 0xa8(%rsp), %rdx
callq 0x6a10
movl %eax, 0x14(%rsp)
jmp 0x639d
movq 0x60(%rsp), %rdi
movl 0x14(%rsp), %eax
movl %eax, 0xb8(%rsp)
callq 0x7020
movq %rax, 0x90(%rsp)
leaq 0x98(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x7950
leaq 0xbc(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x7990
movq %rax, 0x8(%rsp)
jmp 0x63eb
movq 0x60(%rsp), %rdi
movq 0x8(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x98(%rsp), %rsi
leaq 0x88(%rsp), %rdx
callq 0x7910
movq %rax, (%rsp)
jmp 0x6418
movq (%rsp), %rax
movq %rax, 0x80(%rsp)
jmp 0x6426
movb $0x1, 0x197(%rsp)
testb $0x1, 0x197(%rsp)
jne 0x6442
movq 0x60(%rsp), %rdi
callq 0x7380
movq 0x68(%rsp), %rax
addq $0x1b8, %rsp            # imm = 0x1B8
retq
movq 0x188(%rsp), %rdi
callq 0x34a0
nopl (%rax)