// File: /workspace/github_cpp_makefile_star2_O1/NathanWine[P]2048-AI-Solvers/src/Game.cpp
// Function: Game::computePossibilities() const
std::map<int, weightedmoves> Game::computePossibilities() const {
    // Note: Responsibility to check if game can continue is given to other functions
    std::map<int, weightedmoves> possibilities;
    movelist valid_moves;
    generatePossibleMoves(valid_moves);

    for (auto const &move : valid_moves) {
        int dir = move.first;
        for (int i = 0; i < DIM; ++i) {
            for (int j = 0; j < DIM; ++j) {
                if (move.second.state[i][j] == 0) {      // If space is 0, add all outcomes if tile added here
                    Game game_copy = move.second;
                    game_copy.state[i][j] = 2;
                    possibilities[dir].push_back(std::pair<float, Game>(0.9, game_copy));
                    game_copy.state[i][j] = 4;
                    possibilities[dir].push_back(std::pair<float, Game>(0.1, game_copy));
                }
            }
        }
    }

    for (auto &possibility : possibilities) {           // Normalize the probabilities
        int len = (int) possibility.second.size();
        for (int i = 0; i < len; ++i) {
            possibility.second[i].first /= len;
        }
    }

    return possibilities;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, %rax
leaq 0x8(%rdi), %rdx
movl $0x0, 0x8(%rdi)
xorl %ecx, %ecx
movq %rcx, 0x10(%rdi)
movq %rdx, 0x18(%rdi)
movq %rdx, 0x38(%rsp)
movq %rdx, 0x20(%rdi)
movq %rdi, (%rsp)
movq %rcx, 0x28(%rdi)
leaq 0x50(%rsp), %rsi
movq %rcx, 0x10(%rsi)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsi)
movq %rax, %rdi
callq 0x6432
movq 0x50(%rsp), %r13
movq 0x58(%rsp), %rax
movq %rax, 0x40(%rsp)
cmpq %rax, %r13
je 0x69d0
leaq 0x70(%rsp), %r14
movl (%r13), %eax
movl %eax, 0xc(%rsp)
leaq 0x10(%r13), %r15
xorl %eax, %eax
movq %rax, 0x48(%rsp)
leaq (%rax,%rax,2), %rbx
xorl %ebp, %ebp
movq 0x10(%r13), %rax
movq (%rax,%rbx,8), %rax
cmpl $0x0, (%rax,%rbp,4)
jne 0x69a2
movl 0x8(%r13), %eax
movl %eax, 0x68(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x2d38
movq 0x70(%rsp), %rax
movq (%rax,%rbx,8), %rax
movl $0x2, (%rax,%rbp,4)
movq (%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x770c
movq %rax, %r12
movl $0x3f666666, 0x10(%rsp) # imm = 0x3F666666
movl 0x68(%rsp), %eax
movl %eax, 0x18(%rsp)
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
callq 0x2d38
movq %r12, %rdi
leaq 0x10(%rsp), %rsi
callq 0x8010
leaq 0x20(%rsp), %rdi
callq 0x2e18
movq 0x70(%rsp), %rax
movq (%rax,%rbx,8), %rax
movl $0x4, (%rax,%rbp,4)
movq (%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x770c
movq %rax, %r12
movl $0x3dcccccd, 0x10(%rsp) # imm = 0x3DCCCCCD
movl 0x68(%rsp), %eax
movl %eax, 0x18(%rsp)
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
callq 0x2d38
movq %r12, %rdi
leaq 0x10(%rsp), %rsi
callq 0x8010
leaq 0x20(%rsp), %rdi
callq 0x2e18
movq %r14, %rdi
callq 0x2e18
incq %rbp
cmpq $0x4, %rbp
jne 0x68cb
movq 0x48(%rsp), %rax
incq %rax
cmpq $0x4, %rax
jne 0x68c0
addq $0x28, %r13
cmpq 0x40(%rsp), %r13
jne 0x68b2
movq (%rsp), %rax
movq 0x18(%rax), %rax
movq 0x38(%rsp), %r14
cmpq %r14, %rax
je 0x6a32
movabsq $-0x3333333333333333, %rbx # imm = 0xCCCCCCCCCCCCCCCD
movq 0x28(%rax), %rcx
movq 0x30(%rax), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %rbx, %rdx
testl %edx, %edx
jle 0x6a25
xorps %xmm0, %xmm0
cvtsi2ss %edx, %xmm0
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movss (%rcx), %xmm1
divss %xmm0, %xmm1
movss %xmm1, (%rcx)
addq $0x28, %rcx
decq %rdx
jne 0x6a10
movq %rax, %rdi
callq 0x2120
cmpq %r14, %rax
jne 0x69ec
leaq 0x50(%rsp), %rdi
callq 0x3e06
movq (%rsp), %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6a58
jmp 0x6a6e
jmp 0x6a6e
movq %rax, %r15
jmp 0x6a79
jmp 0x6a5f
movq %rax, %r15
leaq 0x20(%rsp), %rdi
callq 0x2e18
jmp 0x6a71
movq %rax, %r15
movq %r14, %rdi
callq 0x2e18
leaq 0x50(%rsp), %rdi
callq 0x3e06
movq (%rsp), %rdi
callq 0x3efc
movq %r15, %rdi
callq 0x22b0