// File: NathanWine[P]2048-AI-Solvers/src/Main.cpp
// Function: main
int main(int argc, char** argv) {
    enum ALGORITHMS {MONTECARLO, MINIMAX, EXPECTIMAX};
    std::map<std::string, int> alg_map = {{"montecarlo", MONTECARLO}, {"minimax", MINIMAX}, {"expectimax", EXPECTIMAX}};
    int alg_key = MINIMAX;
    int num_games = 1;
    int num_runs = 25;
    int depth = 1;
    int print_level = 2;

    // Parse command-line arguments
    CmdParser cmd_parser(argc, argv);
    if (cmd_parser.cmdOptionExists("-h") || cmd_parser.cmdOptionExists("--help") 
            || cmd_parser.cmdOptionExists("help") || cmd_parser.cmdOptionExists("usage")) {
        std::string msg = "Usage:\
            \n  AISolver <flag> <flag_val> ...\
            \n  Flag list:\
            \n    -a: Integer/String value; Algorithm to run. 0=montecarlo, 1=minimax, 2=expectimax\
            \n    -n: Integer value; # times to run the algorithm. Stats displayed at program completion\
            \n    -r: Integer value; # runs MonteCarlo completes for each move. Higher=better but slower. Recommend 10-100\
            \n    -d: Integer value; # depth level for Minimax / Expectimax\
            \n    -p: Integer value; Print level. Higher=more display. 0=minimal, 1=medium, 2=high, 3=full\
            \n  Ex: AISolver -a minimax -n 1 -d 1 -p 3";
        std::cout << msg << std::endl;
        return 0;
    }
    if (cmd_parser.cmdOptionExists("-a")) {
        std::string a_arg = cmd_parser.getCmdOption("-a");
        if (isNumber(a_arg)) {
            alg_key = std::stoi(a_arg);
        }
        else {
            lowercase(a_arg);
            alg_key = alg_map[a_arg];
        }
    }
    if (cmd_parser.cmdOptionExists("-n")) {
        std::string n_option = cmd_parser.getCmdOption("-n");
        if (isNumber(n_option)) {
            num_games = std::stoi(n_option);
        }
    }
    if (cmd_parser.cmdOptionExists("-r")) {
        std::string r_option = cmd_parser.getCmdOption("-r");
        if (isNumber(r_option)) {
            num_runs = std::stoi(r_option);
        }
    }
    if (cmd_parser.cmdOptionExists("-d")) {
        std::string d_option = cmd_parser.getCmdOption("-d");
        if (isNumber(d_option)) {
            depth = std::stoi(d_option);
        }
    }
    if (cmd_parser.cmdOptionExists("-p")) {
        std::string p_option = cmd_parser.getCmdOption("-p");
        if (isNumber(p_option)) {
            print_level = std::stoi(p_option);
        }
    }

    // Set up variables for statistics
    int successes = 0;
    std::vector<int> scores;
    std::vector<int> highest_tiles;
    high_resolution_clock::time_point t1 = high_resolution_clock::now();
    switch (alg_key) {          // Run chosen algorithm
        case MONTECARLO:
            successes = monteCarloSolve(num_games, num_runs, print_level, scores, highest_tiles);
            break;
        case MINIMAX:
            successes = minimaxSolve(num_games, depth, print_level, scores, highest_tiles);
            break;
        case EXPECTIMAX:
            successes = expectimaxSolve(num_games, depth, print_level, &scores, &highest_tiles);
    }
    high_resolution_clock::time_point t2 = high_resolution_clock::now();
    duration<double> time_span = duration_cast<duration<double>>(t2 - t1);

    // Display statistics
    if (num_games > 1) {
        std::cout << "Success rate: " << (float) successes / num_games * 100 << "%" << std::endl;
        float average = std::accumulate(scores.begin(), scores.end(), 0.0) / num_games;
        std::cout << "Average score: " << average << std::endl;
        std::cout << "Highest tiles: ";
        for (int i = 0; i < (int) highest_tiles.size(); ++i) {
            std::cout << highest_tiles[i] << ", ";
        }
        std::cout << std::endl;
    }
    else {
        std::cout << (successes > 0 ? "Game won!" : "Game lost.") << std::endl;
        std::cout << "Final score: " << scores[0] << std::endl;
        std::cout << "Highest tile: " << highest_tiles[0] << std::endl;
    }
    std::cout << "Time elapsed: " << time_span.count() << " seconds" << std::endl;

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x6a0, %rsp            # imm = 0x6A0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0xc8(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
movl $0x0, -0xd4(%rbp)
leaq 0xdf48(%rip), %rsi      # 0x18130
leaq -0xd4(%rbp), %rdx
callq 0xb800
jmp 0xa1f6
leaq -0xa0(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
movl $0x1, -0xe8(%rbp)
leaq 0xdf26(%rip), %rsi      # 0x1813b
leaq -0xe8(%rbp), %rdx
callq 0xb880
jmp 0xa223
leaq -0x78(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
movl $0x2, -0xec(%rbp)
leaq 0xdf04(%rip), %rsi      # 0x18143
leaq -0xec(%rbp), %rdx
callq 0xb800
jmp 0xa24d
leaq -0xc8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq $0x3, -0x48(%rbp)
leaq -0xee(%rbp), %rdi
movq %rdi, -0x490(%rbp)
callq 0xb9d0
movq -0x490(%rbp), %r8
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
leaq -0x40(%rbp), %rdi
leaq -0xed(%rbp), %rcx
callq 0xb9f0
jmp 0xa294
leaq -0xee(%rbp), %rdi
callq 0xbac0
leaq -0xc8(%rbp), %rax
movq %rax, -0x4a0(%rbp)
addq $0x78, %rax
movq %rax, -0x498(%rbp)
movq -0x498(%rbp), %rdi
addq $-0x28, %rdi
movq %rdi, -0x4a8(%rbp)
callq 0xb9b0
movq -0x4a0(%rbp), %rcx
movq -0x4a8(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x498(%rbp)
jne 0xa2b9
movl $0x1, -0xf4(%rbp)
movl $0x1, -0xf8(%rbp)
movl $0x19, -0xfc(%rbp)
movl $0x1, -0x100(%rbp)
movl $0x2, -0x104(%rbp)
movq -0x10(%rbp), %rdx
leaq -0x120(%rbp), %rdi
leaq -0x8(%rbp), %rsi
callq 0xbae0
jmp 0xa332
leaq -0x141(%rbp), %rdi
movq %rdi, -0x4b0(%rbp)
callq 0x33e0
movq -0x4b0(%rbp), %rdx
movb $0x0, -0x16a(%rbp)
movb $0x0, -0x16b(%rbp)
movb $0x0, -0x192(%rbp)
movb $0x0, -0x193(%rbp)
movb $0x0, -0x1ba(%rbp)
movb $0x0, -0x1bb(%rbp)
leaq 0xddd1(%rip), %rsi      # 0x1814e
leaq -0x140(%rbp), %rdi
callq 0xbc40
jmp 0xa38b
leaq -0x120(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0xbbd0
movb %al, -0x4b1(%rbp)
jmp 0xa3a6
movb -0x4b1(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x4b2(%rbp)
jne 0xa503
jmp 0xa3bf
leaq -0x169(%rbp), %rdi
movq %rdi, -0x4c0(%rbp)
callq 0x33e0
movq -0x4c0(%rbp), %rdx
movb $0x1, -0x16a(%rbp)
leaq 0xdd6a(%rip), %rsi      # 0x18151
leaq -0x168(%rbp), %rdi
callq 0xbc40
jmp 0xa3f5
movb $0x1, -0x16b(%rbp)
leaq -0x120(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0xbbd0
movb %al, -0x4c1(%rbp)
jmp 0xa417
movb -0x4c1(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x4b2(%rbp)
jne 0xa503
jmp 0xa430
leaq -0x191(%rbp), %rdi
movq %rdi, -0x4d0(%rbp)
callq 0x33e0
movq -0x4d0(%rbp), %rdx
movb $0x1, -0x192(%rbp)
leaq 0xdcfb(%rip), %rsi      # 0x18153
leaq -0x190(%rbp), %rdi
callq 0xbc40
jmp 0xa466
movb $0x1, -0x193(%rbp)
leaq -0x120(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0xbbd0
movb %al, -0x4d1(%rbp)
jmp 0xa488
movb -0x4d1(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x4b2(%rbp)
jne 0xa503
jmp 0xa49d
leaq -0x1b9(%rbp), %rdi
movq %rdi, -0x4e0(%rbp)
callq 0x33e0
movq -0x4e0(%rbp), %rdx
movb $0x1, -0x1ba(%rbp)
leaq 0xdc93(%rip), %rsi      # 0x18158
leaq -0x1b8(%rbp), %rdi
callq 0xbc40
jmp 0xa4d3
movb $0x1, -0x1bb(%rbp)
leaq -0x120(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0xbbd0
movb %al, -0x4e1(%rbp)
jmp 0xa4f5
movb -0x4e1(%rbp), %al
movb %al, -0x4b2(%rbp)
jmp 0xa503
movb -0x4b2(%rbp), %al
movb %al, -0x4e2(%rbp)
testb $0x1, -0x1bb(%rbp)
jne 0xa51a
jmp 0xa526
leaq -0x1b8(%rbp), %rdi
callq 0x3458
testb $0x1, -0x1ba(%rbp)
jne 0xa531
jmp 0xa53d
leaq -0x1b9(%rbp), %rdi
callq 0x32c0
testb $0x1, -0x193(%rbp)
jne 0xa548
jmp 0xa554
leaq -0x190(%rbp), %rdi
callq 0x3458
testb $0x1, -0x192(%rbp)
jne 0xa55f
jmp 0xa56b
leaq -0x191(%rbp), %rdi
callq 0x32c0
testb $0x1, -0x16b(%rbp)
jne 0xa576
jmp 0xa582
leaq -0x168(%rbp), %rdi
callq 0x3458
testb $0x1, -0x16a(%rbp)
jne 0xa58d
jmp 0xa599
leaq -0x169(%rbp), %rdi
callq 0x32c0
leaq -0x140(%rbp), %rdi
callq 0x3458
leaq -0x141(%rbp), %rdi
callq 0x32c0
movb -0x4e2(%rbp), %al
testb $0x1, %al
jne 0xa5c0
jmp 0xa8da
leaq -0x1e1(%rbp), %rdi
movq %rdi, -0x4f0(%rbp)
callq 0x33e0
movq -0x4f0(%rbp), %rdx
leaq 0xdb7d(%rip), %rsi      # 0x1815e
leaq -0x1e0(%rbp), %rdi
callq 0xbc40
jmp 0xa5ef
leaq -0x1e1(%rbp), %rdi
callq 0x32c0
movq 0x189c6(%rip), %rdi     # 0x22fc8
leaq -0x1e0(%rbp), %rsi
callq 0x3210
movq %rax, -0x4f8(%rbp)
jmp 0xa617
movq -0x4f8(%rbp), %rdi
movq 0x1898b(%rip), %rsi     # 0x22fb0
callq 0x32a0
jmp 0xa62c
movl $0x0, -0x4(%rbp)
movl $0x1, -0x1e8(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x3458
jmp 0xb7b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
movq -0xd0(%rbp), %rax
leaq -0xc8(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0x500(%rbp)
je 0xa6ab
movq -0x500(%rbp), %rdi
addq $-0x28, %rdi
movq %rdi, -0x508(%rbp)
callq 0xb9b0
movq -0x508(%rbp), %rax
leaq -0xc8(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0x500(%rbp)
jne 0xa67a
jmp 0xb7e6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0xee(%rbp), %rdi
callq 0xbac0
leaq -0xc8(%rbp), %rax
movq %rax, -0x518(%rbp)
addq $0x78, %rax
movq %rax, -0x510(%rbp)
movq -0x510(%rbp), %rdi
addq $-0x28, %rdi
movq %rdi, -0x520(%rbp)
callq 0xb9b0
movq -0x518(%rbp), %rcx
movq -0x520(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x510(%rbp)
jne 0xa6e7
jmp 0xb7e6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xb7dd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xa883
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xa877
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xa85e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xa845
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xa82c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xa813
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xa7fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
testb $0x1, -0x1bb(%rbp)
jne 0xa7ec
jmp 0xa7f8
leaq -0x1b8(%rbp), %rdi
callq 0x3458
jmp 0xa7fa
testb $0x1, -0x1ba(%rbp)
jne 0xa805
jmp 0xa811
leaq -0x1b9(%rbp), %rdi
callq 0x32c0
jmp 0xa813
testb $0x1, -0x193(%rbp)
jne 0xa81e
jmp 0xa82a
leaq -0x190(%rbp), %rdi
callq 0x3458
jmp 0xa82c
testb $0x1, -0x192(%rbp)
jne 0xa837
jmp 0xa843
leaq -0x191(%rbp), %rdi
callq 0x32c0
jmp 0xa845
testb $0x1, -0x16b(%rbp)
jne 0xa850
jmp 0xa85c
leaq -0x168(%rbp), %rdi
callq 0x3458
jmp 0xa85e
testb $0x1, -0x16a(%rbp)
jne 0xa869
jmp 0xa875
leaq -0x169(%rbp), %rdi
callq 0x32c0
jmp 0xa877
leaq -0x140(%rbp), %rdi
callq 0x3458
leaq -0x141(%rbp), %rdi
callq 0x32c0
jmp 0xb7d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x1e1(%rbp), %rdi
callq 0x32c0
jmp 0xb7d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x3458
jmp 0xb7d1
leaq -0x209(%rbp), %rdi
movq %rdi, -0x528(%rbp)
callq 0x33e0
movq -0x528(%rbp), %rdx
leaq 0xdada(%rip), %rsi      # 0x183d5
leaq -0x208(%rbp), %rdi
callq 0xbc40
jmp 0xa909
leaq -0x120(%rbp), %rdi
leaq -0x208(%rbp), %rsi
callq 0xbbd0
movb %al, -0x529(%rbp)
jmp 0xa924
leaq -0x208(%rbp), %rdi
callq 0x3458
leaq -0x209(%rbp), %rdi
callq 0x32c0
movb -0x529(%rbp), %al
testb $0x1, %al
jne 0xa94b
jmp 0xaaf1
leaq -0x251(%rbp), %rdi
movq %rdi, -0x538(%rbp)
callq 0x33e0
movq -0x538(%rbp), %rdx
leaq 0xda69(%rip), %rsi      # 0x183d5
leaq -0x250(%rbp), %rdi
callq 0xbc40
jmp 0xa97a
leaq -0x120(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0xbcf0
movq %rax, -0x540(%rbp)
jmp 0xa996
movq -0x540(%rbp), %rsi
leaq -0x230(%rbp), %rdi
callq 0x30d0
jmp 0xa9ab
leaq -0x250(%rbp), %rdi
callq 0x3458
leaq -0x251(%rbp), %rdi
callq 0x32c0
leaq -0x230(%rbp), %rdi
callq 0xa050
testb $0x1, %al
jne 0xa9d8
jmp 0xaaaf
xorl %eax, %eax
movl %eax, %esi
leaq -0x230(%rbp), %rdi
movl $0xa, %edx
callq 0xbe70
movl %eax, -0x544(%rbp)
jmp 0xa9f5
movl -0x544(%rbp), %eax
movl %eax, -0xf4(%rbp)
jmp 0xaae5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xaa38
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x208(%rbp), %rdi
callq 0x3458
leaq -0x209(%rbp), %rdi
callq 0x32c0
jmp 0xb7d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xaa7b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x3458
leaq -0x251(%rbp), %rdi
callq 0x32c0
jmp 0xb7d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x3458
jmp 0xb7d1
leaq -0x230(%rbp), %rdi
callq 0xa0e0
jmp 0xaabd
leaq -0x40(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0xbeb0
movq %rax, -0x550(%rbp)
jmp 0xaad6
movq -0x550(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xf4(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x3458
leaq -0x279(%rbp), %rdi
movq %rdi, -0x558(%rbp)
callq 0x33e0
movq -0x558(%rbp), %rdx
leaq 0xd8c6(%rip), %rsi      # 0x183d8
leaq -0x278(%rbp), %rdi
callq 0xbc40
jmp 0xab20
leaq -0x120(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0xbbd0
movb %al, -0x559(%rbp)
jmp 0xab3b
leaq -0x278(%rbp), %rdi
callq 0x3458
leaq -0x279(%rbp), %rdi
callq 0x32c0
movb -0x559(%rbp), %al
testb $0x1, %al
jne 0xab62
jmp 0xacd2
leaq -0x2c1(%rbp), %rdi
movq %rdi, -0x568(%rbp)
callq 0x33e0
movq -0x568(%rbp), %rdx
leaq 0xd855(%rip), %rsi      # 0x183d8
leaq -0x2c0(%rbp), %rdi
callq 0xbc40
jmp 0xab91
leaq -0x120(%rbp), %rdi
leaq -0x2c0(%rbp), %rsi
callq 0xbcf0
movq %rax, -0x570(%rbp)
jmp 0xabad
movq -0x570(%rbp), %rsi
leaq -0x2a0(%rbp), %rdi
callq 0x30d0
jmp 0xabc2
leaq -0x2c0(%rbp), %rdi
callq 0x3458
leaq -0x2c1(%rbp), %rdi
callq 0x32c0
leaq -0x2a0(%rbp), %rdi
callq 0xa050
testb $0x1, %al
jne 0xabef
jmp 0xacc6
xorl %eax, %eax
movl %eax, %esi
leaq -0x2a0(%rbp), %rdi
movl $0xa, %edx
callq 0xbe70
movl %eax, -0x574(%rbp)
jmp 0xac0c
movl -0x574(%rbp), %eax
movl %eax, -0xf8(%rbp)
jmp 0xacc6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xac4f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x278(%rbp), %rdi
callq 0x3458
leaq -0x279(%rbp), %rdi
callq 0x32c0
jmp 0xb7d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xac92
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x2c0(%rbp), %rdi
callq 0x3458
leaq -0x2c1(%rbp), %rdi
callq 0x32c0
jmp 0xb7d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x2a0(%rbp), %rdi
callq 0x3458
jmp 0xb7d1
leaq -0x2a0(%rbp), %rdi
callq 0x3458
leaq -0x2e9(%rbp), %rdi
movq %rdi, -0x580(%rbp)
callq 0x33e0
movq -0x580(%rbp), %rdx
leaq 0xd6e8(%rip), %rsi      # 0x183db
leaq -0x2e8(%rbp), %rdi
callq 0xbc40
jmp 0xad01
leaq -0x120(%rbp), %rdi
leaq -0x2e8(%rbp), %rsi
callq 0xbbd0
movb %al, -0x581(%rbp)
jmp 0xad1c
leaq -0x2e8(%rbp), %rdi
callq 0x3458
leaq -0x2e9(%rbp), %rdi
callq 0x32c0
movb -0x581(%rbp), %al
testb $0x1, %al
jne 0xad43
jmp 0xaeb3
leaq -0x331(%rbp), %rdi
movq %rdi, -0x590(%rbp)
callq 0x33e0
movq -0x590(%rbp), %rdx
leaq 0xd677(%rip), %rsi      # 0x183db
leaq -0x330(%rbp), %rdi
callq 0xbc40
jmp 0xad72
leaq -0x120(%rbp), %rdi
leaq -0x330(%rbp), %rsi
callq 0xbcf0
movq %rax, -0x598(%rbp)
jmp 0xad8e
movq -0x598(%rbp), %rsi
leaq -0x310(%rbp), %rdi
callq 0x30d0
jmp 0xada3
leaq -0x330(%rbp), %rdi
callq 0x3458
leaq -0x331(%rbp), %rdi
callq 0x32c0
leaq -0x310(%rbp), %rdi
callq 0xa050
testb $0x1, %al
jne 0xadd0
jmp 0xaea7
xorl %eax, %eax
movl %eax, %esi
leaq -0x310(%rbp), %rdi
movl $0xa, %edx
callq 0xbe70
movl %eax, -0x59c(%rbp)
jmp 0xaded
movl -0x59c(%rbp), %eax
movl %eax, -0xfc(%rbp)
jmp 0xaea7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xae30
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x2e8(%rbp), %rdi
callq 0x3458
leaq -0x2e9(%rbp), %rdi
callq 0x32c0
jmp 0xb7d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xae73
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x330(%rbp), %rdi
callq 0x3458
leaq -0x331(%rbp), %rdi
callq 0x32c0
jmp 0xb7d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x310(%rbp), %rdi
callq 0x3458
jmp 0xb7d1
leaq -0x310(%rbp), %rdi
callq 0x3458
leaq -0x359(%rbp), %rdi
movq %rdi, -0x5a8(%rbp)
callq 0x33e0
movq -0x5a8(%rbp), %rdx
leaq 0xd50a(%rip), %rsi      # 0x183de
leaq -0x358(%rbp), %rdi
callq 0xbc40
jmp 0xaee2
leaq -0x120(%rbp), %rdi
leaq -0x358(%rbp), %rsi
callq 0xbbd0
movb %al, -0x5a9(%rbp)
jmp 0xaefd
leaq -0x358(%rbp), %rdi
callq 0x3458
leaq -0x359(%rbp), %rdi
callq 0x32c0
movb -0x5a9(%rbp), %al
testb $0x1, %al
jne 0xaf24
jmp 0xb094
leaq -0x3a1(%rbp), %rdi
movq %rdi, -0x5b8(%rbp)
callq 0x33e0
movq -0x5b8(%rbp), %rdx
leaq 0xd499(%rip), %rsi      # 0x183de
leaq -0x3a0(%rbp), %rdi
callq 0xbc40
jmp 0xaf53
leaq -0x120(%rbp), %rdi
leaq -0x3a0(%rbp), %rsi
callq 0xbcf0
movq %rax, -0x5c0(%rbp)
jmp 0xaf6f
movq -0x5c0(%rbp), %rsi
leaq -0x380(%rbp), %rdi
callq 0x30d0
jmp 0xaf84
leaq -0x3a0(%rbp), %rdi
callq 0x3458
leaq -0x3a1(%rbp), %rdi
callq 0x32c0
leaq -0x380(%rbp), %rdi
callq 0xa050
testb $0x1, %al
jne 0xafb1
jmp 0xb088
xorl %eax, %eax
movl %eax, %esi
leaq -0x380(%rbp), %rdi
movl $0xa, %edx
callq 0xbe70
movl %eax, -0x5c4(%rbp)
jmp 0xafce
movl -0x5c4(%rbp), %eax
movl %eax, -0x100(%rbp)
jmp 0xb088
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xb011
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x358(%rbp), %rdi
callq 0x3458
leaq -0x359(%rbp), %rdi
callq 0x32c0
jmp 0xb7d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xb054
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x3a0(%rbp), %rdi
callq 0x3458
leaq -0x3a1(%rbp), %rdi
callq 0x32c0
jmp 0xb7d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x380(%rbp), %rdi
callq 0x3458
jmp 0xb7d1
leaq -0x380(%rbp), %rdi
callq 0x3458
leaq -0x3c9(%rbp), %rdi
movq %rdi, -0x5d0(%rbp)
callq 0x33e0
movq -0x5d0(%rbp), %rdx
leaq 0xd32c(%rip), %rsi      # 0x183e1
leaq -0x3c8(%rbp), %rdi
callq 0xbc40
jmp 0xb0c3
leaq -0x120(%rbp), %rdi
leaq -0x3c8(%rbp), %rsi
callq 0xbbd0
movb %al, -0x5d1(%rbp)
jmp 0xb0de
leaq -0x3c8(%rbp), %rdi
callq 0x3458
leaq -0x3c9(%rbp), %rdi
callq 0x32c0
movb -0x5d1(%rbp), %al
testb $0x1, %al
jne 0xb105
jmp 0xb275
leaq -0x411(%rbp), %rdi
movq %rdi, -0x5e0(%rbp)
callq 0x33e0
movq -0x5e0(%rbp), %rdx
leaq 0xd2bb(%rip), %rsi      # 0x183e1
leaq -0x410(%rbp), %rdi
callq 0xbc40
jmp 0xb134
leaq -0x120(%rbp), %rdi
leaq -0x410(%rbp), %rsi
callq 0xbcf0
movq %rax, -0x5e8(%rbp)
jmp 0xb150
movq -0x5e8(%rbp), %rsi
leaq -0x3f0(%rbp), %rdi
callq 0x30d0
jmp 0xb165
leaq -0x410(%rbp), %rdi
callq 0x3458
leaq -0x411(%rbp), %rdi
callq 0x32c0
leaq -0x3f0(%rbp), %rdi
callq 0xa050
testb $0x1, %al
jne 0xb192
jmp 0xb269
xorl %eax, %eax
movl %eax, %esi
leaq -0x3f0(%rbp), %rdi
movl $0xa, %edx
callq 0xbe70
movl %eax, -0x5ec(%rbp)
jmp 0xb1af
movl -0x5ec(%rbp), %eax
movl %eax, -0x104(%rbp)
jmp 0xb269
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xb1f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x3c8(%rbp), %rdi
callq 0x3458
leaq -0x3c9(%rbp), %rdi
callq 0x32c0
jmp 0xb7d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xb235
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x410(%rbp), %rdi
callq 0x3458
leaq -0x411(%rbp), %rdi
callq 0x32c0
jmp 0xb7d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x3f0(%rbp), %rdi
callq 0x3458
jmp 0xb7d1
leaq -0x3f0(%rbp), %rdi
callq 0x3458
movl $0x0, -0x418(%rbp)
leaq -0x430(%rbp), %rdi
callq 0xbf90
leaq -0x448(%rbp), %rdi
callq 0xbf90
callq 0x3050
movq %rax, -0x450(%rbp)
movl -0xf4(%rbp), %eax
movl %eax, -0x5f0(%rbp)
testl %eax, %eax
je 0xb2da
jmp 0xb2b5
movl -0x5f0(%rbp), %eax
subl $0x1, %eax
je 0xb347
jmp 0xb2c6
movl -0x5f0(%rbp), %eax
subl $0x2, %eax
je 0xb382
jmp 0xb3bb
movl -0xf8(%rbp), %edi
movl -0xfc(%rbp), %esi
movl -0x104(%rbp), %edx
leaq -0x430(%rbp), %rcx
leaq -0x448(%rbp), %r8
callq 0x3e80
movl %eax, -0x5f4(%rbp)
jmp 0xb307
movl -0x5f4(%rbp), %eax
movl %eax, -0x418(%rbp)
jmp 0xb3bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x448(%rbp), %rdi
callq 0x4370
leaq -0x430(%rbp), %rdi
callq 0x4370
jmp 0xb7d1
movl -0xf8(%rbp), %edi
movl -0x100(%rbp), %esi
movl -0x104(%rbp), %edx
leaq -0x430(%rbp), %rcx
leaq -0x448(%rbp), %r8
callq 0x7d40
movl %eax, -0x5f8(%rbp)
jmp 0xb374
movl -0x5f8(%rbp), %eax
movl %eax, -0x418(%rbp)
jmp 0xb3bb
movl -0xf8(%rbp), %edi
movl -0x100(%rbp), %esi
movl -0x104(%rbp), %edx
leaq -0x430(%rbp), %rcx
leaq -0x448(%rbp), %r8
callq 0x16850
movl %eax, -0x5fc(%rbp)
jmp 0xb3af
movl -0x5fc(%rbp), %eax
movl %eax, -0x418(%rbp)
callq 0x3050
movq %rax, -0x458(%rbp)
leaq -0x458(%rbp), %rdi
leaq -0x450(%rbp), %rsi
callq 0xbfe0
movq %rax, -0x608(%rbp)
jmp 0xb3e3
movq -0x608(%rbp), %rax
movq %rax, -0x468(%rbp)
leaq -0x468(%rbp), %rdi
callq 0xbfb0
movsd %xmm0, -0x610(%rbp)
jmp 0xb407
movsd -0x610(%rbp), %xmm0
movsd %xmm0, -0x460(%rbp)
cmpl $0x1, -0xf8(%rbp)
jle 0xb611
movq 0x17b9d(%rip), %rdi     # 0x22fc8
leaq 0xcfb2(%rip), %rsi      # 0x183e4
callq 0x3260
movq %rax, -0x618(%rbp)
jmp 0xb440
movq -0x618(%rbp), %rdi
cvtsi2ssl -0x418(%rbp), %xmm0
cvtsi2ssl -0xf8(%rbp), %xmm1
divss %xmm1, %xmm0
movss 0xccb1(%rip), %xmm1     # 0x18114
mulss %xmm1, %xmm0
callq 0x31b0
movq %rax, -0x620(%rbp)
jmp 0xb475
movq -0x620(%rbp), %rdi
leaq 0xcf70(%rip), %rsi      # 0x183f3
callq 0x3260
movq %rax, -0x628(%rbp)
jmp 0xb491
movq -0x628(%rbp), %rdi
movq 0x17b11(%rip), %rsi     # 0x22fb0
callq 0x32a0
jmp 0xb4a6
leaq -0x430(%rbp), %rdi
movq %rdi, -0x638(%rbp)
callq 0x42c0
movq -0x638(%rbp), %rdi
movq %rax, -0x478(%rbp)
callq 0x6cc0
movq %rax, -0x480(%rbp)
movq -0x478(%rbp), %rdi
movq -0x480(%rbp), %rsi
xorps %xmm0, %xmm0
callq 0xc030
movsd %xmm0, -0x630(%rbp)
jmp 0xb4f3
movsd -0x630(%rbp), %xmm0
cvtsi2sdl -0xf8(%rbp), %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x46c(%rbp)
movq 0x17aae(%rip), %rdi     # 0x22fc8
leaq 0xced4(%rip), %rsi      # 0x183f5
callq 0x3260
movq %rax, -0x640(%rbp)
jmp 0xb52f
movq -0x640(%rbp), %rdi
movss -0x46c(%rbp), %xmm0
callq 0x31b0
movq %rax, -0x648(%rbp)
jmp 0xb54c
movq -0x648(%rbp), %rdi
movq 0x17a56(%rip), %rsi     # 0x22fb0
callq 0x32a0
jmp 0xb561
movq 0x17a60(%rip), %rdi     # 0x22fc8
leaq 0xce96(%rip), %rsi      # 0x18405
callq 0x3260
jmp 0xb576
movl $0x0, -0x484(%rbp)
movl -0x484(%rbp), %eax
movl %eax, -0x64c(%rbp)
leaq -0x448(%rbp), %rdi
callq 0x41e0
movq %rax, %rcx
movl -0x64c(%rbp), %eax
cmpl %ecx, %eax
jge 0xb5f7
movslq -0x484(%rbp), %rsi
leaq -0x448(%rbp), %rdi
callq 0x4230
movl (%rax), %esi
movq 0x17a07(%rip), %rdi     # 0x22fc8
callq 0x33b0
movq %rax, -0x658(%rbp)
jmp 0xb5cf
movq -0x658(%rbp), %rdi
leaq 0xcb33(%rip), %rsi      # 0x18110
callq 0x3260
jmp 0xb5e4
jmp 0xb5e6
movl -0x484(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x484(%rbp)
jmp 0xb580
movq 0x179ca(%rip), %rdi     # 0x22fc8
movq 0x179ab(%rip), %rsi     # 0x22fb0
callq 0x32a0
jmp 0xb60c
jmp 0xb707
movl -0x418(%rbp), %eax
testl %eax, %eax
leaq 0xcdf5(%rip), %rax      # 0x18415
leaq 0xcdf8(%rip), %rsi      # 0x1841f
cmovgq %rax, %rsi
movq 0x17996(%rip), %rdi     # 0x22fc8
callq 0x3260
movq %rax, -0x660(%rbp)
jmp 0xb640
movq -0x660(%rbp), %rdi
movq 0x17962(%rip), %rsi     # 0x22fb0
callq 0x32a0
jmp 0xb655
movq 0x1796c(%rip), %rdi     # 0x22fc8
leaq 0xcdc7(%rip), %rsi      # 0x1842a
callq 0x3260
movq %rax, -0x668(%rbp)
jmp 0xb671
xorl %eax, %eax
movl %eax, %esi
leaq -0x430(%rbp), %rdi
callq 0x4230
movq -0x668(%rbp), %rdi
movl (%rax), %esi
callq 0x33b0
movq %rax, -0x670(%rbp)
jmp 0xb698
movq -0x670(%rbp), %rdi
movq 0x1790a(%rip), %rsi     # 0x22fb0
callq 0x32a0
jmp 0xb6ad
movq 0x17914(%rip), %rdi     # 0x22fc8
leaq 0xcd7d(%rip), %rsi      # 0x18438
callq 0x3260
movq %rax, -0x678(%rbp)
jmp 0xb6c9
xorl %eax, %eax
movl %eax, %esi
leaq -0x448(%rbp), %rdi
callq 0x4230
movq -0x678(%rbp), %rdi
movl (%rax), %esi
callq 0x33b0
movq %rax, -0x680(%rbp)
jmp 0xb6f0
movq -0x680(%rbp), %rdi
movq 0x178b2(%rip), %rsi     # 0x22fb0
callq 0x32a0
jmp 0xb705
jmp 0xb707
movq 0x178ba(%rip), %rdi     # 0x22fc8
leaq 0xcd32(%rip), %rsi      # 0x18447
callq 0x3260
movq %rax, -0x688(%rbp)
jmp 0xb723
leaq -0x460(%rbp), %rdi
callq 0xc0a0
movsd %xmm0, -0x690(%rbp)
jmp 0xb739
movsd -0x690(%rbp), %xmm0
movq -0x688(%rbp), %rdi
callq 0x3420
movq %rax, -0x698(%rbp)
jmp 0xb756
movq -0x698(%rbp), %rdi
leaq 0xccf2(%rip), %rsi      # 0x18456
callq 0x3260
movq %rax, -0x6a0(%rbp)
jmp 0xb772
movq -0x6a0(%rbp), %rdi
movq 0x17830(%rip), %rsi     # 0x22fb0
callq 0x32a0
jmp 0xb787
movl $0x0, -0x4(%rbp)
movl $0x1, -0x1e8(%rbp)
leaq -0x448(%rbp), %rdi
callq 0x4370
leaq -0x430(%rbp), %rdi
callq 0x4370
leaq -0x120(%rbp), %rdi
callq 0xc0c0
leaq -0x40(%rbp), %rdi
callq 0xc0e0
movl -0x4(%rbp), %eax
addq $0x6a0, %rsp            # imm = 0x6A0
popq %rbp
retq
leaq -0x120(%rbp), %rdi
callq 0xc0c0
leaq -0x40(%rbp), %rdi
callq 0xc0e0
movq -0xe0(%rbp), %rdi
callq 0x33d0
nopw %cs:(%rax,%rax)