// File: /workspace/github_cpp_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %rbp
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, %rbx
movq %rcx, 0x18(%rsp)
shrq $0x8, %rbp
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq %rsi, %rdi
movq %rdx, %rsi
callq 0x33f0
movl %eax, %r15d
movl %eax, %ecx
movq 0x8(%r13), %rax
movq %rax, %rdx
shlq $0x38, %rdx
shlq $0x34, %rax
orq %rdx, %rax
xorl %edx, %edx
movq %r14, 0x10(%rsp)
testq %r14, %rax
sete %dl
movl $0x4, %r12d
subl %edx, %r12d
xorl $0x3, %edx
imull %r12d, %edx
cmpl %edx, %r15d
jge 0x3518
leal (%r12,%r15), %r14d
movzbl %bpl, %eax
cmpl %eax, %r14d
je 0x3518
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl %ecx, 0x8(%rsp)
movl %r14d, %r8d
callq 0x3872
movq (%rbx), %rsi
shlq $0x20, %rax
movl %r14d, %ecx
orq %rax, %rcx
leaq 0x20(%rsp), %rdx
movq %rcx, (%rdx)
movq %rbx, %rdi
callq 0x4492
movl 0x8(%rsp), %ecx
leal 0x1(%r15), %r14d
movl %r14d, %eax
cltd
idivl %r12d
testl %edx, %edx
sete %al
movzbl %bpl, %edx
cmpl %edx, %r14d
sete %dl
orb %al, %dl
jne 0x3578
movq %r13, 0x8(%rsp)
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl %ecx, %r13d
movl %r14d, %r8d
callq 0x3872
movq (%rbx), %rsi
shlq $0x20, %rax
movl %r14d, %ecx
orq %rax, %rcx
leaq 0x20(%rsp), %rdx
movq %rcx, (%rdx)
movq %rbx, %rdi
callq 0x4492
movl %r13d, %ecx
movq 0x8(%rsp), %r13
movl %ecx, %eax
cltd
idivl %r12d
testl %edx, %edx
je 0x35d1
leal -0x1(%r15), %r14d
movzbl %bpl, %eax
cmpl %eax, %r14d
je 0x35d1
movq %r13, 0x8(%rsp)
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl %ecx, %r13d
movl %r14d, %r8d
callq 0x3872
movq (%rbx), %rsi
shlq $0x20, %rax
movl %r14d, %ecx
orq %rax, %rcx
leaq 0x20(%rsp), %rdx
movq %rcx, (%rdx)
movq %rbx, %rdi
callq 0x4492
movl %r13d, %ecx
movq 0x8(%rsp), %r13
subl %r12d, %r15d
jl 0x3611
movzbl %bpl, %eax
cmpl %eax, %r15d
je 0x3611
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl %r15d, %r8d
callq 0x3872
movq (%rbx), %rsi
shlq $0x20, %rax
movl %r15d, %ecx
orq %rax, %rcx
leaq 0x20(%rsp), %rdx
movq %rcx, (%rdx)
movq %rbx, %rdi
callq 0x4492
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3631
jmp 0x3631
jmp 0x3631
jmp 0x3631
jmp 0x3631
jmp 0x3631
jmp 0x3631
movq %rax, %r14
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x3641
callq 0x2200
movq %r14, %rdi
callq 0x2330
nop