// File: NathanWine[P]2048-AI-Solvers/src/MonteCarlo.cpp
// Function: simulateOneRun(Game)
std::pair<int, int> simulateOneRun(Game game) {
    Game game_cpy = game;
    int first_move = -1;

    while(game_cpy.canContinue()) {
        board before_state = game_cpy.state;
        std::vector<int> move_bank = {UP, DOWN, LEFT, RIGHT};

        while (before_state == game_cpy.state) {
            int random_pos = DISTS[move_bank.size() - 1](rng);
            int chosen_move = move_bank[random_pos];

            switch(chosen_move) {
                case UP:
                    game_cpy.up(false);
                    break;
                case DOWN:
                    game_cpy.down(false);
                    break;
                case LEFT:
                    game_cpy.left(false);
                    break;
                case RIGHT:
                    game_cpy.right(false);
                    break;
            }
            if (first_move == -1) {
                first_move = chosen_move;
            }
            move_bank.erase(move_bank.begin() + random_pos);
        }
    }

    std::pair<int, int> ret(first_move, game_cpy.score);
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, %rsi
movq %rsi, -0x10(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3f70
movl $0xffffffff, -0x34(%rbp) # imm = 0xFFFFFFFF
leaq -0x30(%rbp), %rdi
callq 0xf4f0
movb %al, -0xc9(%rbp)
jmp 0x38e3
movb -0xc9(%rbp), %al
testb $0x1, %al
jne 0x38f2
jmp 0x3b45
leaq -0x28(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x3fb0
jmp 0x3901
movl $0x0, -0x98(%rbp)
movl $0x1, -0x94(%rbp)
movl $0x2, -0x90(%rbp)
movl $0x3, -0x8c(%rbp)
leaq -0x98(%rbp), %rax
movq %rax, -0x88(%rbp)
movq $0x4, -0x80(%rbp)
leaq -0x99(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x40a0
movq -0xd8(%rbp), %rcx
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rdx
leaq -0x78(%rbp), %rdi
callq 0x40c0
jmp 0x396f
leaq -0x99(%rbp), %rdi
callq 0x4140
leaq -0x28(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x4160
movb %al, -0xd9(%rbp)
jmp 0x3990
movb -0xd9(%rbp), %al
testb $0x1, %al
jne 0x399f
jmp 0x3b23
leaq -0x78(%rbp), %rdi
callq 0x41e0
movq %rax, %rcx
leaq 0x21fde(%rip), %rax     # 0x25990
leaq -0x8(%rax,%rcx,8), %rdi
leaq 0x20c42(%rip), %rsi     # 0x24600
callq 0x4200
movl %eax, -0xe0(%rbp)
jmp 0x39cb
movl -0xe0(%rbp), %eax
movl %eax, -0xa0(%rbp)
movslq -0xa0(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x4230
movl (%rax), %eax
movl %eax, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
movq %rax, -0xe8(%rbp)
subq $0x3, %rax
ja 0x3aa1
movq -0xe8(%rbp), %rax
leaq 0x145f0(%rip), %rcx     # 0x18004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x3b6e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x99(%rbp), %rdi
callq 0x4140
jmp 0x3b3a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x4370
jmp 0x3b3a
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
callq 0xfa10
jmp 0x3a72
jmp 0x3aa1
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
callq 0xfac0
jmp 0x3a81
jmp 0x3aa1
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
callq 0xfb10
jmp 0x3a90
jmp 0x3aa1
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
callq 0xfb60
jmp 0x3a9f
jmp 0x3aa1
cmpl $-0x1, -0x34(%rbp)
jne 0x3ab0
movl -0xa4(%rbp), %eax
movl %eax, -0x34(%rbp)
leaq -0x78(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x42c0
movq %rax, -0xc0(%rbp)
movslq -0xa0(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
callq 0x42f0
movq %rax, -0xb8(%rbp)
leaq -0xb0(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x4330
movq -0xf8(%rbp), %rdi
movq -0xb0(%rbp), %rsi
callq 0x4250
movq %rax, -0xf0(%rbp)
jmp 0x3b10
movq -0xf0(%rbp), %rax
movq %rax, -0xc8(%rbp)
jmp 0x397b
leaq -0x78(%rbp), %rdi
callq 0x4370
leaq -0x60(%rbp), %rdi
callq 0x43d0
jmp 0x38d2
leaq -0x60(%rbp), %rdi
callq 0x43d0
jmp 0x3b6e
leaq -0x8(%rbp), %rdi
leaq -0x34(%rbp), %rsi
leaq -0x30(%rbp), %rdx
callq 0x4430
jmp 0x3b58
leaq -0x30(%rbp), %rdi
callq 0x4460
movq -0x8(%rbp), %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x4460
movq -0x40(%rbp), %rdi
callq 0x33d0