// File: /workspace/github_cpp_makefile_star2_O2/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 %rdx, %r14
movq %rsi, %r13
movq %rdi, %rbx
movq %rcx, 0x18(%rsp)
movq %rcx, %r12
shrq $0x8, %r12
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movq %rsi, %rdi
movq %rdx, %rsi
callq 0x305a
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
pushq $0x4
popq %rbp
subl %edx, %ebp
xorl $0x3, %edx
imull %ebp, %edx
cmpl %edx, %r15d
jge 0x313c
leal (%r15,%rbp), %r14d
movzbl %r12b, %r12d
cmpl %r12d, %r14d
je 0x3140
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl %ecx, 0x8(%rsp)
movl %r14d, %r8d
callq 0x343e
movq (%rbx), %rsi
shlq $0x20, %rax
movl %r14d, %ecx
orq %rax, %rcx
leaq 0x20(%rsp), %rdx
movq %rcx, (%rdx)
movq %rbx, %rdi
callq 0x40e6
movl 0x8(%rsp), %ecx
jmp 0x3140
movzbl %r12b, %r12d
leal 0x1(%r15), %r14d
movl %r14d, %eax
cltd
idivl %ebp
testl %edx, %edx
sete %al
cmpl %r12d, %r14d
sete %dl
orb %al, %dl
jne 0x319b
movq %r13, 0x8(%rsp)
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl %ecx, %r13d
movl %r14d, %r8d
callq 0x343e
movq (%rbx), %rsi
shlq $0x20, %rax
movl %r14d, %ecx
orq %rax, %rcx
leaq 0x20(%rsp), %rdx
movq %rcx, (%rdx)
movq %rbx, %rdi
callq 0x40e6
movl %r13d, %ecx
movq 0x8(%rsp), %r13
movl %ecx, %eax
cltd
idivl %ebp
testl %edx, %edx
je 0x31ef
leal -0x1(%r15), %r14d
cmpl %r12d, %r14d
je 0x31ef
movq %r13, 0x8(%rsp)
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl %ecx, %r13d
movl %r14d, %r8d
callq 0x343e
movq (%rbx), %rsi
shlq $0x20, %rax
movl %r14d, %ecx
orq %rax, %rcx
leaq 0x20(%rsp), %rdx
movq %rcx, (%rdx)
movq %rbx, %rdi
callq 0x40e6
movl %r13d, %ecx
movq 0x8(%rsp), %r13
subl %ebp, %r15d
jl 0x322b
cmpl %r12d, %r15d
je 0x322b
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl %r15d, %r8d
callq 0x343e
movq (%rbx), %rsi
shlq $0x20, %rax
movl %r15d, %ecx
orq %rax, %rcx
leaq 0x20(%rsp), %rdx
movq %rcx, (%rdx)
movq %rbx, %rdi
callq 0x40e6
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x324b
jmp 0x324b
jmp 0x324b
jmp 0x324b
jmp 0x324b
jmp 0x324b
jmp 0x324b
movq %rax, %r14
movq %rbx, %rdi
callq 0x3bda
movq %r14, %rdi
callq 0x2340