// File: /workspace/github_cpp_makefile_star2_O3/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)
movq $0x0, 0x10(%rdi)
movq %rsi, %rdi
movq %rdx, %rsi
callq 0x3408
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, %ebp
subl %edx, %ebp
xorl $0x3, %edx
imull %ebp, %edx
cmpl %edx, %r15d
jge 0x34fd
leal (%r15,%rbp), %r14d
movzbl %r12b, %r12d
cmpl %r12d, %r14d
je 0x3501
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl %ecx, 0x8(%rsp)
movl %r14d, %r8d
callq 0x3850
movq (%rbx), %rsi
shlq $0x20, %rax
movl %r14d, %ecx
orq %rax, %rcx
leaq 0x20(%rsp), %rdx
movq %rcx, (%rdx)
movq %rbx, %rdi
callq 0x4488
movl 0x8(%rsp), %ecx
jmp 0x3501
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 0x355c
movq %r13, 0x8(%rsp)
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl %ecx, %r13d
movl %r14d, %r8d
callq 0x3850
movq (%rbx), %rsi
shlq $0x20, %rax
movl %r14d, %ecx
orq %rax, %rcx
leaq 0x20(%rsp), %rdx
movq %rcx, (%rdx)
movq %rbx, %rdi
callq 0x4488
movl %r13d, %ecx
movq 0x8(%rsp), %r13
movl %ecx, %eax
cltd
idivl %ebp
testl %edx, %edx
je 0x35b0
leal -0x1(%r15), %r14d
cmpl %r12d, %r14d
je 0x35b0
movq %r13, 0x8(%rsp)
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl %ecx, %r13d
movl %r14d, %r8d
callq 0x3850
movq (%rbx), %rsi
shlq $0x20, %rax
movl %r14d, %ecx
orq %rax, %rcx
leaq 0x20(%rsp), %rdx
movq %rcx, (%rdx)
movq %rbx, %rdi
callq 0x4488
movl %r13d, %ecx
movq 0x8(%rsp), %r13
subl %ebp, %r15d
jl 0x35ec
cmpl %r12d, %r15d
je 0x35ec
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl %r15d, %r8d
callq 0x3850
movq (%rbx), %rsi
shlq $0x20, %rax
movl %r15d, %ecx
orq %rax, %rcx
leaq 0x20(%rsp), %rdx
movq %rcx, (%rdx)
movq %rbx, %rdi
callq 0x4488
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x360c
jmp 0x360c
jmp 0x360c
jmp 0x360c
jmp 0x360c
jmp 0x360c
jmp 0x360c
movq %rax, %r14
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x361c
callq 0x21f0
movq %r14, %rdi
callq 0x2320