// File: /workspace/github_cpp_makefile_star2_O2/kaiming[P]Chamber-Crawler-3k/main.cc
// Function: main
int main(int argc, char* argv[]) {
    bool restart = true;

    while (restart) {
        restart = false;

        std::ifstream infile;
        std::vector<std::vector<std::vector<std::shared_ptr<Tile>>>> floors;
        std::vector<std::shared_ptr<WalkableTile>> playerSpawns;
        std::vector<std::vector<std::shared_ptr<WalkableTile>>> enemies;
        std::vector<std::vector<std::shared_ptr<WalkableTile>>> dragonHoards;
        std::vector<bool> filled;
        int winner = -1; // code 0 for restart, code 1 for win, code 2 for loss

        // if no file is passed in command line
        if (argc == 1) {
            try { 
                infile.open("./default.txt");
            } catch (...) {
               std::cerr << "Error reading in default file" << std::endl;
               infile.close();
               return 1;
            }
            
        } else { // if there are at least one command line argument (only take the first one and try to open it as a file)
            try {
                // get file name 
                const std::string fileName {argv[1]};

                infile.open(fileName);
            } catch (...) {
                std::cerr << "Error reading in given file" << std::endl;
                infile.close();
                return 1;
            }
        } 

        // read in file for floor plan
        readFloorPlan(infile, floors, playerSpawns, enemies, dragonHoards, filled);

        // close file
        infile.close();

        TextDisplay td;

        // Ask player to enter one of the specified races or quit
        std::string race, in;

        std::cout << "Welcome to ChamberCrawler3000, prepare to enter the unknown!" << std::endl;
        
        // Extra Features menu
        std::cout << "Enter settings menu? (y or n): ";
        std::cin >> in;

        while (in != "y" && in != "n") {
            std::cerr << "Invalid option" << std::endl;
            std::cout << "Enter here: ";

            if (std::cin.fail()) {
                if (std::cin.eof()) return 0;

                std::cin.clear();
                std::cin.ignore();
            }

            std::cin >> in;
        }

        int seed = -1;
        bool enemyTracking = false;
        int radius = -1;

        if (in == "y") {
            std::cout << "Settings menu"<< std::endl;
            
            // Get seed
            std::cout << "Enter seed (int) or -1 to skip: ";
            std::cin >> seed;
            
            while (std::cin.fail()) {
                if (std::cin.eof()) return 0;

                std::cin.clear();
                std::cin.ignore();
                std::cout << "Invalid int."<< std::endl;
                std::cout << "Enter seed (int) or -1 to skip:";
                std::cin >> seed;
            }

            if (seed != -1) {
                std::cout << "Seed entered: " << std::to_string(seed) << std::endl;
            }


            // Get enemy tracking option
            std::cout << "Enable Enemy Tracking? (y or n): ";

            std::cin >> in;

            while (in != "y" && in != "n") {
                std::cerr << "Invalid option" << std::endl;
                std::cout << "Enter here: ";

                if (std::cin.fail()) {
                    if (std::cin.eof()) return 0;

                    std::cin.clear();
                    std::cin.ignore();
                }
                
                std::cin >> in;
            }

            if (in == "y") {
                enemyTracking = true;
                std::cout << "Enemy Tracking Enabled" << std::endl;
            } else if (in == "n") {
                enemyTracking = false;
                std::cout << "Enemy Tracking Disabled" << std::endl;
            }

            
            // If enemy tracking option activated, get difficulty
            if (enemyTracking) {
                std::cout << "Set Enemy Tracking difficulty (e, m, h): ";
                std::cin >> in;

                while (in != "e" && in != "m" && in != "h") {
                    std::cerr << "Invalid option" << std::endl;
                    std::cout << "Enter here: ";

                    if (std::cin.fail()) {
                        if (std::cin.eof()) return 0;

                        std::cin.clear();
                        std::cin.ignore();
                    }

                    std::cin >> in;
                }

                if (in == "e") {
                    radius = 2;
                    std::cout << "Enemy Tracking Difficulty: Easy (radius 2)" << std::endl;
                } else if (in == "m") {
                    radius = 3;
                    std::cout << "Enemy Tracking Difficulty: Medium (radius 3)" << std::endl;
                } else if (in == "h") {
                    radius = 4;
                    std::cout << "Enemy Tracking Difficulty: Hard (radius 4)" << std::endl;
                }

            }

            std::cout << "End of Settings menu." << std::endl;

        } else if (race == "n") {
            // Continue
            std::cout << "Settings menu bypassed." << std::endl;

        }



        std::cout << "Choose your character: Shade 's' (default), Drow 'd', Vampire 'v', Goblin 'g', Troll 't'" << std::endl;
        std::cout << "Enter here: ";

        std::getline(std::cin, race);
        std::getline(std::cin, race);



        while (race != "" && race != "s" && race != "d" && race != "v" && race != "g" && race != "t") {
            std::cerr << "Invalid race" << std::endl;
            std::cout << "Enter here: ";

            if (std::cin.fail()) {
                if (std::cin.eof()) return 0;

                std::cin.clear();
                std::cin.ignore();
            }

            std::cin >> std::noskipws >> race;
        }

        if (race == "q") {
            return 0; // NOTE: MAYBE HAVE IT SO A NEW GAME STARTS??
        } else if (race == "r") {
            restart = true; // Sort of useless LOL
            continue;
        } else if (race == "") { // default race
            race = "s";
        }

        std::cout << "Race selected: " + race << std::endl;
/*
    int seed = -1;
        bool enemyTracking = false;
        int radius = -1;
*/

        Board b = Board {floors, filled, playerSpawns, enemies, dragonHoards, race, seed, enemyTracking, radius};


        td.drawFloor(std::cout, b, "The adventure begins");

        std::string cmd;

        while (true) {
            std::cout << "Enter command: ";
            getline(std::cin, cmd);

            // break clause
            if (std::cin.fail()) {
                if (std::cin.eof()) {
                    return 0;
                }
            }

            // Process commands
            std::string message;

            if (cmd == "no" || cmd == "so" || cmd == "ea" || cmd == "we" || cmd == "ne" || cmd == "nw" || cmd == "se" || cmd == "sw") {
                // Move player in given direction
                message = b.movePlayer(cmd);

                if (message == "Dungeon cleared. You win!") {
                    // Game Won by Player
                    winner = 1;

                    break;
                } 

            } else if (static_cast<int>(cmd.length()) == 4 && cmd[0] == 'u') {
                // Use potion in given direction
                message = b.usePotion(cmd.substr(cmd.length() - 2));

            } else if (static_cast<int>(cmd.length()) == 4 && cmd[0] == 'a') {
                // Attack enemy in the given direction
                message = b.attackEnemy(cmd.substr(cmd.length() - 2));

            } else if (cmd == "f") {
                // Freeze enemies
                bool isFrozen = b.toggleFreeze();

                message = "Enemies Frozen: ";
                
                if (isFrozen) {
                    message += "Enabled ";
                 } else {
                    message += "Disabled ";
                 }

            } else if (cmd == "r") {
                // Restart game
                std::cout << "Resetting the game..." << std::endl;
                restart = true;
                winner = 0;

                break;
            } else if (cmd == "q") {
                // Quit Game
                std::cout << "You gave up! Better luck next time!" << std::endl;;

                return 0;
            } else {
                // Invalid Command
                std::cerr << "Invalid Command" << std::endl;
                continue;
            }

            // Move Enemies
            if (message.length () > 30 && message.substr(message.length()-26) == "Proceeding to next floor. ") {

            } else {
                std::string e_message = b.moveEnemies();

                if (e_message.length() == 0) {
                    e_message = "Enemies moved.";
                }

                message +=e_message;
            }
            

            td.drawFloor(std::cout, b, message);

            if (message.length() > 12 && message.substr(message.length()-10) == "Game Over!") {
                // Player killed and lost
                winner = 2;
                break;
            }

        } // End of Command Interpreter

        if (winner == 1) {
            // Print winner stuff
            
            std::cout << "Congratulations! You won!" << std::endl;
        } else if (winner == 2) {
            // Print loser stuff
            
            std::cout << "You have been defeated!" << std::endl;

        }

        if (winner != 0) {
            // Ask Player if they want to play again
            std::cout << "Play again? y or n" << std::endl;
            std::string replay = "";
            
            while (replay != "y" && replay != "n") {
                if (replay != "") {
                    std::cerr << "Invalid Answer" << std::endl;
                }
                
                std::cin >> replay;

                if (std::cin.fail()) {
                    if (std::cin.eof()) return 0;

                    std::cin.clear();
                    std::cin.ignore();
                }
            }

            if (replay == "y") {
                restart = true;
            }
        }

    } // End of restart loop

    

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x5c8, %rsp            # imm = 0x5C8
movq %rsi, 0x118(%rsp)
movl %edi, 0x5c(%rsp)
movb $0x1, %cl
leaq 0x3c0(%rsp), %r15
movq 0x1fa06(%rip), %r14     # 0x24ff0
movq 0x1f9d7(%rip), %r12     # 0x24fc8
movq 0x1f9e0(%rip), %rbx     # 0x24fd8
leaq 0x148(%rsp), %rbp
xorl %eax, %eax
testb $0x1, %cl
je 0x65b3
movl %eax, 0xc(%rsp)
movq %r15, %rdi
callq 0x5240
andq $0x0, 0x110(%rsp)
andq $0x0, 0xf0(%rsp)
andq $0x0, 0xd0(%rsp)
andq $0x0, 0xb0(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x100(%rsp)
andq $0x0, 0x120(%rsp)
movaps %xmm0, 0xe0(%rsp)
andl $0x0, 0x128(%rsp)
movaps %xmm0, 0xc0(%rsp)
andq $0x0, 0x130(%rsp)
movaps %xmm0, 0xa0(%rsp)
andl $0x0, 0x138(%rsp)
andq $0x0, 0x140(%rsp)
cmpl $0x1, 0x5c(%rsp)
jne 0x56a4
movq %r15, %rdi
leaq 0x1296a(%rip), %rsi     # 0x18004
pushq $0x8
popq %rdx
callq 0x5150
jmp 0x56db
movq 0x118(%rsp), %rax
movq 0x8(%rax), %rsi
leaq 0x2b0(%rsp), %r13
movq %r13, %rdi
leaq 0x38(%rsp), %rdx
callq 0x67bc
movq %r15, %rdi
movq %r13, %rsi
pushq $0x8
popq %rdx
callq 0x51b0
movq %r13, %rdi
callq 0x5100
movq %r15, %rdi
leaq 0x100(%rsp), %rsi
leaq 0xe0(%rsp), %rdx
leaq 0xc0(%rsp), %rcx
leaq 0xa0(%rsp), %r8
leaq 0x120(%rsp), %r9
callq 0x761e
movq %r15, %rdi
callq 0x5060
leaq 0x48(%rsp), %rax
movq %rax, 0x38(%rsp)
andq $0x0, 0x40(%rsp)
xorl %ecx, %ecx
movb %cl, 0x48(%rsp)
leaq 0x158(%rsp), %rax
movq %rax, 0x148(%rsp)
andq $0x0, 0x150(%rsp)
movb %cl, 0x158(%rsp)
movq %r12, %rdi
leaq 0x128f9(%rip), %rsi     # 0x1804c
callq 0x51f0
movq %rax, %rdi
callq 0x5120
movq %r12, %rdi
leaq 0x1291f(%rip), %rsi     # 0x18089
callq 0x51f0
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x5280
movq %rbp, %rdi
leaq 0x12925(%rip), %rsi     # 0x180a9
callq 0x67f7
testb %al, %al
je 0x57ff
movq %rbp, %rdi
leaq 0x12c5c(%rip), %rsi     # 0x183f3
callq 0x67f7
testb %al, %al
je 0x57ff
movq %r14, %rdi
leaq 0x12901(%rip), %rsi     # 0x180ab
callq 0x51f0
movq %rax, %rdi
callq 0x5120
movq %r12, %rdi
leaq 0x128f9(%rip), %rsi     # 0x180ba
callq 0x51f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
movl 0x20(%rbx,%rdi), %eax
testb $0x5, %al
je 0x57ef
testb $0x2, %al
jne 0x58ec
addq %rbx, %rdi
xorl %esi, %esi
callq 0x5370
movq %rbx, %rdi
callq 0x53b0
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x5280
jmp 0x577a
orl $-0x1, 0x8(%rsp)
movq %rbp, %rdi
leaq 0x1289b(%rip), %rsi     # 0x180a9
callq 0x6801
testb %al, %al
je 0x58b0
movq %r12, %rdi
leaq 0x128a2(%rip), %rsi     # 0x180c7
callq 0x51f0
movq %rax, %rdi
callq 0x5120
movq %r12, %rdi
leaq 0x12899(%rip), %rsi     # 0x180d5
callq 0x51f0
movq %rbx, %rdi
leaq 0x8(%rsp), %rsi
callq 0x5140
movq (%rbx), %rax
movq -0x18(%rax), %rdi
movl 0x20(%rbx,%rdi), %eax
testb $0x5, %al
je 0x58fb
testb $0x2, %al
jne 0x5d56
addq %rbx, %rdi
xorl %esi, %esi
callq 0x5370
movq %rbx, %rdi
callq 0x53b0
movq %r12, %rdi
leaq 0x12871(%rip), %rsi     # 0x180f6
callq 0x51f0
movq %rax, %rdi
callq 0x5120
movq %r12, %rdi
leaq 0x12867(%rip), %rsi     # 0x18103
callq 0x51f0
movq %rbx, %rdi
leaq 0x8(%rsp), %rsi
callq 0x5140
jmp 0x584e
leaq 0x38(%rsp), %rdi
leaq 0x12b37(%rip), %rsi     # 0x183f3
callq 0x6801
testb %al, %al
je 0x58dc
movq %r12, %rdi
leaq 0x1297b(%rip), %rsi     # 0x1824a
callq 0x51f0
movq %rax, %rdi
callq 0x5120
xorl %r13d, %r13d
pushq $-0x1
popq %rax
movq %rax, 0x10(%rsp)
jmp 0x5bd2
xorl %r13d, %r13d
pushq $0x1
popq %r14
xorl %r15d, %r15d
jmp 0x64a8
cmpl $-0x1, 0x8(%rsp)
je 0x5948
movq %r12, %rdi
leaq 0x12817(%rip), %rsi     # 0x18123
callq 0x51f0
movq %rax, %r13
movl 0x8(%rsp), %esi
leaq 0x2b0(%rsp), %r15
movq %r15, %rdi
callq 0x680e
movq %r13, %rdi
movq %r15, %rsi
callq 0x51d0
movq %rax, %rdi
callq 0x5120
leaq 0x2b0(%rsp), %rdi
callq 0x5100
movq %r12, %rdi
leaq 0x127e0(%rip), %rsi     # 0x18132
callq 0x51f0
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x5280
movq %rbp, %rdi
leaq 0x1273d(%rip), %rsi     # 0x180a9
callq 0x67f7
testb %al, %al
je 0x59e7
movq %rbp, %rdi
leaq 0x12a74(%rip), %rsi     # 0x183f3
callq 0x67f7
testb %al, %al
je 0x59e7
movq %r14, %rdi
leaq 0x12719(%rip), %rsi     # 0x180ab
callq 0x51f0
movq %rax, %rdi
callq 0x5120
movq %r12, %rdi
leaq 0x12711(%rip), %rsi     # 0x180ba
callq 0x51f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
movl 0x20(%rbx,%rdi), %eax
testb $0x5, %al
je 0x59d7
testb $0x2, %al
jne 0x5d56
addq %rbx, %rdi
xorl %esi, %esi
callq 0x5370
movq %rbx, %rdi
callq 0x53b0
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x5280
jmp 0x5962
movq %rbp, %rdi
leaq 0x126b8(%rip), %rsi     # 0x180a9
callq 0x6801
movl %eax, %r13d
testb %al, %al
je 0x5ad6
movq %r12, %rdi
leaq 0x12749(%rip), %rsi     # 0x18154
callq 0x51f0
movq %rax, %rdi
callq 0x5120
movq %r12, %rdi
leaq 0x12761(%rip), %rsi     # 0x18183
callq 0x51f0
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x5280
movq %rbp, %rdi
leaq 0x1288c(%rip), %rsi     # 0x182c8
callq 0x67f7
testb %al, %al
je 0x5b19
movq %rbp, %rdi
leaq 0x1275a(%rip), %rsi     # 0x181ad
callq 0x67f7
testb %al, %al
je 0x5b19
movq %rbp, %rdi
leaq 0x12745(%rip), %rsi     # 0x181af
callq 0x67f7
testb %al, %al
je 0x5b19
movq %r14, %rdi
leaq 0x1262a(%rip), %rsi     # 0x180ab
callq 0x51f0
movq %rax, %rdi
callq 0x5120
movq %r12, %rdi
leaq 0x12622(%rip), %rsi     # 0x180ba
callq 0x51f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
movl 0x20(%rbx,%rdi), %eax
testb $0x5, %al
je 0x5ac6
testb $0x2, %al
jne 0x5d56
addq %rbx, %rdi
xorl %esi, %esi
callq 0x5370
movq %rbx, %rdi
callq 0x53b0
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x5280
jmp 0x5a32
movq %rbp, %rdi
leaq 0x12913(%rip), %rsi     # 0x183f3
callq 0x6801
pushq $-0x1
popq %rcx
movq %rcx, 0x10(%rsp)
testb %al, %al
je 0x5bbb
movq %r12, %rdi
leaq 0x1266c(%rip), %rsi     # 0x1816b
callq 0x51f0
movq %rax, %rdi
callq 0x5120
pushq $-0x1
popq %rax
movq %rax, 0x10(%rsp)
jmp 0x5bbb
movq %rbp, %rdi
leaq 0x127a5(%rip), %rsi     # 0x182c8
callq 0x6801
testb %al, %al
je 0x5b4d
movq %r12, %rdi
leaq 0x1267b(%rip), %rsi     # 0x181b1
callq 0x51f0
movq %rax, %rdi
callq 0x5120
pushq $0x2
popq %rax
movq %rax, 0x10(%rsp)
jmp 0x5bbb
movq %rbp, %rdi
leaq 0x12656(%rip), %rsi     # 0x181ad
callq 0x6801
testb %al, %al
je 0x5b81
movq %r12, %rdi
leaq 0x12672(%rip), %rsi     # 0x181dc
callq 0x51f0
movq %rax, %rdi
callq 0x5120
pushq $0x3
popq %rax
movq %rax, 0x10(%rsp)
jmp 0x5bbb
movq %rbp, %rdi
leaq 0x12624(%rip), %rsi     # 0x181af
callq 0x6801
pushq $-0x1
popq %rcx
movq %rcx, 0x10(%rsp)
testb %al, %al
je 0x5bbb
movq %r12, %rdi
leaq 0x12663(%rip), %rsi     # 0x18209
callq 0x51f0
movq %rax, %rdi
callq 0x5120
pushq $0x4
popq %rax
movq %rax, 0x10(%rsp)
movq %r12, %rdi
leaq 0x1266f(%rip), %rsi     # 0x18234
callq 0x51f0
movq %rax, %rdi
callq 0x5120
movq %r12, %rdi
leaq 0x12686(%rip), %rsi     # 0x18262
callq 0x51f0
movq %rax, %rdi
callq 0x5120
movq %r12, %rdi
leaq 0x124c7(%rip), %rsi     # 0x180ba
callq 0x51f0
movq %rbx, %rdi
leaq 0x38(%rsp), %rsi
callq 0x5050
movq %rbx, %rdi
leaq 0x38(%rsp), %rsi
callq 0x5050
leaq 0x38(%rsp), %rdi
leaq 0x13271(%rip), %rsi     # 0x18e8f
callq 0x67f7
testb %al, %al
je 0x5d09
leaq 0x38(%rsp), %rdi
leaq 0x126b8(%rip), %rsi     # 0x182ef
callq 0x67f7
testb %al, %al
je 0x5d09
leaq 0x38(%rsp), %rdi
leaq 0x12519(%rip), %rsi     # 0x18169
callq 0x67f7
testb %al, %al
je 0x5d09
leaq 0x38(%rsp), %rdi
leaq 0x12652(%rip), %rsi     # 0x182bb
callq 0x67f7
testb %al, %al
je 0x5d09
leaq 0x38(%rsp), %rdi
leaq 0x1346d(%rip), %rsi     # 0x190ef
callq 0x67f7
testb %al, %al
je 0x5d09
leaq 0x38(%rsp), %rdi
leaq 0x13187(%rip), %rsi     # 0x18e1e
callq 0x67f7
testb %al, %al
je 0x5d09
movq %r14, %rdi
leaq 0x12613(%rip), %rsi     # 0x182bd
callq 0x51f0
movq %rax, %rdi
callq 0x5120
movq %r12, %rdi
leaq 0x123f9(%rip), %rsi     # 0x180ba
callq 0x51f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
movl 0x20(%rbx,%rdi), %eax
testb $0x5, %al
je 0x5cf2
testb $0x2, %al
jne 0x5d56
addq %rbx, %rdi
xorl %esi, %esi
callq 0x5370
movq %rbx, %rdi
callq 0x53b0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
andb $-0x11, 0x19(%rbx,%rdi)
movq %rbx, %rdi
leaq 0x38(%rsp), %rsi
callq 0x5280
jmp 0x5c12
leaq 0x38(%rsp), %rdi
leaq 0x125b5(%rip), %rsi     # 0x182ca
callq 0x6801
xorl %ecx, %ecx
pushq $0x1
popq %r14
movl $0x0, %r15d
testb %al, %al
jne 0x64a5
leaq 0x38(%rsp), %r14
movq %r14, %rdi
leaq 0x126c5(%rip), %rsi     # 0x18402
callq 0x6801
movb $0x1, %cl
testb %al, %al
je 0x5d64
pushq $0x2
popq %r14
movl 0xc(%rsp), %r15d
jmp 0x64a5
xorl %ecx, %ecx
pushq $0x1
popq %r14
xorl %r15d, %r15d
jmp 0x64a5
movq %r14, %rdi
leaq 0x13121(%rip), %rsi     # 0x18e8f
callq 0x6801
testb %al, %al
je 0x5d88
leaq 0x38(%rsp), %rdi
leaq 0x1256c(%rip), %rsi     # 0x182ef
callq 0x53d0
leaq 0x2b0(%rsp), %r15
movq %r15, %rdi
leaq 0x12532(%rip), %rsi     # 0x182cc
leaq 0x38(%rsp), %rdx
callq 0x6867
movq %r12, %rdi
movq %r15, %rsi
callq 0x51d0
movq %rax, %rdi
callq 0x5120
leaq 0x2b0(%rsp), %rdi
callq 0x5100
leaq 0x1d0(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x68de
leaq 0x208(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x6938
leaq 0x180(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x69b4
leaq 0x168(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x6a08
leaq 0x1b8(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x6a08
leaq 0x198(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x52b0
movl 0x8(%rsp), %eax
movzbl %r13b, %r10d
leaq 0x2b0(%rsp), %rdi
leaq 0x1d0(%rsp), %r15
movq %r15, %rsi
leaq 0x208(%rsp), %r13
movq %r13, %rdx
leaq 0x180(%rsp), %rcx
leaq 0x168(%rsp), %r8
leaq 0x1b8(%rsp), %r14
movq %r14, %r9
pushq 0x10(%rsp)
pushq %r10
pushq %rax
leaq 0x1b0(%rsp), %rax
pushq %rax
callq 0xc960
addq $0x20, %rsp
leaq 0x198(%rsp), %rdi
callq 0x5100
movq %r14, %rdi
callq 0x6a62
leaq 0x168(%rsp), %rdi
callq 0x6a62
leaq 0x180(%rsp), %rdi
callq 0x6a84
movq %r13, %rdi
callq 0x6aa6
movq %r15, %rdi
callq 0x6ab6
leaq 0x290(%rsp), %r14
movq %r14, %rdi
leaq 0x123f2(%rip), %rsi     # 0x182dc
leaq 0x60(%rsp), %rdx
callq 0x67bc
leaq 0x7(%rsp), %rdi
movq %r12, %rsi
leaq 0x2b0(%rsp), %rdx
movq %r14, %rcx
callq 0x16e3c
leaq 0x1e8(%rsp), %r15
movq %r14, %rdi
callq 0x5100
leaq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
andq $0x0, 0x68(%rsp)
movb $0x0, 0x70(%rsp)
movq %r12, %rdi
leaq 0x123b6(%rip), %rsi     # 0x182f1
callq 0x51f0
movq %rbx, %rdi
leaq 0x60(%rsp), %rsi
callq 0x5050
movq (%rbx), %rax
movq -0x18(%rax), %rax
movl 0x20(%rbx,%rax), %eax
testb $0x5, %al
setne %cl
andl $0x2, %eax
shrl %eax
testb %al, %cl
jne 0x6481
leaq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
andq $0x0, 0x20(%rsp)
movb $0x0, 0x28(%rsp)
leaq 0x60(%rsp), %r14
movq %r14, %rdi
leaq 0x12373(%rip), %rsi     # 0x18301
callq 0x6801
testb %al, %al
jne 0x6024
movq %r14, %rdi
leaq 0x1235f(%rip), %rsi     # 0x18304
callq 0x6801
testb %al, %al
jne 0x6024
movq %r14, %rdi
leaq 0x1234f(%rip), %rsi     # 0x18307
callq 0x6801
testb %al, %al
jne 0x6024
movq %r14, %rdi
leaq 0x1233f(%rip), %rsi     # 0x1830a
callq 0x6801
testb %al, %al
jne 0x6024
movq %r14, %rdi
leaq 0x1232f(%rip), %rsi     # 0x1830d
callq 0x6801
testb %al, %al
jne 0x6024
movq %r14, %rdi
leaq 0x1231f(%rip), %rsi     # 0x18310
callq 0x6801
testb %al, %al
jne 0x6024
movq %r14, %rdi
leaq 0x1230f(%rip), %rsi     # 0x18313
callq 0x6801
testb %al, %al
jne 0x6024
movq %r14, %rdi
leaq 0x122ff(%rip), %rsi     # 0x18316
callq 0x6801
testb %al, %al
je 0x61a9
leaq 0x270(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x52b0
leaq 0x80(%rsp), %r14
movq %r14, %rdi
leaq 0x2b0(%rsp), %rsi
movq %r13, %rdx
callq 0xe454
leaq 0x18(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x5270
movq %r14, %rdi
callq 0x5100
movq %r13, %rdi
callq 0x5100
movq %r15, %rdi
leaq 0x1229d(%rip), %rsi     # 0x18319
callq 0x6801
testb %al, %al
leaq 0x1e8(%rsp), %r15
jne 0x6300
movq 0x20(%rsp), %rdx
cmpq $0x1f, %rdx
jb 0x60d7
addq $-0x1a, %rdx
leaq 0x80(%rsp), %r14
movq %r14, %rdi
leaq 0x18(%rsp), %rsi
pushq $-0x1
popq %rcx
callq 0x5220
movq %r14, %rdi
leaq 0x12c4d(%rip), %rsi     # 0x18d0f
callq 0x6801
movl %eax, %r13d
movq %r14, %rdi
callq 0x5100
testb %r13b, %r13b
jne 0x6123
leaq 0x80(%rsp), %rdi
leaq 0x2b0(%rsp), %rsi
callq 0x1033a
cmpq $0x0, 0x88(%rsp)
leaq 0x80(%rsp), %r13
jne 0x610e
movq %r13, %rdi
leaq 0x12298(%rip), %rsi     # 0x183a1
callq 0x53d0
leaq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x53e0
movq %r13, %rdi
callq 0x5100
movq %r15, %rdi
leaq 0x18(%rsp), %rsi
callq 0x52b0
leaq 0x7(%rsp), %rdi
movq %r12, %rsi
leaq 0x2b0(%rsp), %rdx
movq %r15, %rcx
callq 0x16e3c
movq %r15, %rdi
callq 0x5100
movq 0x20(%rsp), %rdx
cmpq $0xd, %rdx
jb 0x619a
addq $-0xa, %rdx
leaq 0x80(%rsp), %r14
movq %r14, %rdi
leaq 0x18(%rsp), %rsi
pushq $-0x1
popq %rcx
callq 0x5220
movq %r14, %rdi
leaq 0x12d55(%rip), %rsi     # 0x18ed6
callq 0x6801
movl %eax, %r13d
movq %r14, %rdi
callq 0x5100
testb %r13b, %r13b
jne 0x6313
leaq 0x18(%rsp), %rdi
callq 0x5100
jmp 0x5f31
movq 0x68(%rsp), %rdx
cmpl $0x4, %edx
jne 0x6203
movq 0x60(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x61, %eax
je 0x62a9
cmpl $0x75, %eax
jne 0x6203
addq $-0x2, %rdx
leaq 0x250(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
pushq $-0x1
popq %rcx
callq 0x5220
leaq 0x80(%rsp), %r14
movq %r14, %rdi
leaq 0x2b0(%rsp), %rsi
movq %r13, %rdx
callq 0x11f1e
jmp 0x62de
movq %r14, %rdi
leaq 0x12ec5(%rip), %rsi     # 0x190d2
callq 0x6801
testb %al, %al
je 0x625b
leaq 0x2b0(%rsp), %rdi
callq 0xdb28
movl %eax, %r13d
leaq 0x18(%rsp), %rdi
leaq 0x12101(%rip), %rsi     # 0x18333
callq 0x53d0
testb %r13b, %r13b
leaq 0x1210c(%rip), %rsi     # 0x1834d
leaq 0x120fc(%rip), %rax     # 0x18344
cmovneq %rax, %rsi
leaq 0x18(%rsp), %rdi
callq 0x53c0
jmp 0x6091
movq %r14, %rdi
leaq 0x1219d(%rip), %rsi     # 0x18402
callq 0x6801
testb %al, %al
jne 0x6437
movq %r14, %rdi
leaq 0x1204e(%rip), %rsi     # 0x182ca
callq 0x6801
testb %al, %al
jne 0x6460
movq 0x1ed60(%rip), %rdi     # 0x24ff0
leaq 0x120fa(%rip), %rsi     # 0x18391
callq 0x51f0
movq %rax, %rdi
callq 0x5120
jmp 0x619a
addq $-0x2, %rdx
leaq 0x230(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
pushq $-0x1
popq %rcx
callq 0x5220
leaq 0x80(%rsp), %r14
movq %r14, %rdi
leaq 0x2b0(%rsp), %rsi
movq %r13, %rdx
callq 0xf258
leaq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0x5270
movq %r14, %rdi
callq 0x5100
movq %r13, %rdi
callq 0x5100
jmp 0x6091
leaq 0x18(%rsp), %rdi
callq 0x5100
leaq 0x1209f(%rip), %rsi     # 0x183b0
jmp 0x6324
leaq 0x18(%rsp), %rdi
callq 0x5100
leaq 0x120a6(%rip), %rsi     # 0x183ca
movq %r12, %rdi
callq 0x51f0
leaq 0x80(%rsp), %r14
movq %rax, %rdi
callq 0x5120
movq %r12, %rdi
leaq 0x1209c(%rip), %rsi     # 0x183e2
callq 0x51f0
movq %rax, %rdi
callq 0x5120
leaq 0x18(%rsp), %rdi
leaq 0x12b30(%rip), %rsi     # 0x18e8f
movq %r14, %rdx
callq 0x67bc
leaq 0x18(%rsp), %rdi
leaq 0x11d36(%rip), %rsi     # 0x180a9
callq 0x67f7
testb %al, %al
je 0x63f8
leaq 0x18(%rsp), %rdi
leaq 0x1206b(%rip), %rsi     # 0x183f3
callq 0x67f7
testb %al, %al
je 0x63f8
leaq 0x18(%rsp), %rdi
leaq 0x12af2(%rip), %rsi     # 0x18e8f
callq 0x67f7
testb %al, %al
je 0x63c1
movq 0x1ec43(%rip), %rdi     # 0x24ff0
leaq 0x12041(%rip), %rsi     # 0x183f5
callq 0x51f0
movq %rax, %rdi
callq 0x5120
movq %rbx, %rdi
leaq 0x18(%rsp), %rsi
callq 0x5280
movq (%rbx), %rax
movq -0x18(%rax), %rdi
movl 0x20(%rbx,%rdi), %eax
testb $0x5, %al
je 0x6367
testb $0x2, %al
jne 0x6414
addq %rbx, %rdi
xorl %esi, %esi
callq 0x5370
movq %rbx, %rdi
callq 0x53b0
jmp 0x6367
leaq 0x18(%rsp), %r15
movq %r15, %rdi
leaq 0x11ca2(%rip), %rsi     # 0x180a9
callq 0x6801
movl %eax, %r12d
xorl %r14d, %r14d
jmp 0x6428
xorl %r12d, %r12d
pushq $0x1
popq %r14
movl $0x0, 0xc(%rsp)
leaq 0x18(%rsp), %r15
movq %r15, %rdi
callq 0x5100
movl 0xc(%rsp), %r15d
jmp 0x648b
movq %r12, %rdi
leaq 0x11f16(%rip), %rsi     # 0x18357
callq 0x51f0
movq %rax, %rdi
callq 0x5120
leaq 0x18(%rsp), %rdi
callq 0x5100
xorl %r14d, %r14d
movb $0x1, %r12b
jmp 0x6430
movq %r12, %rdi
leaq 0x11f03(%rip), %rsi     # 0x1836d
callq 0x51f0
movq %rax, %rdi
callq 0x5120
leaq 0x18(%rsp), %rdi
callq 0x5100
xorl %r12d, %r12d
pushq $0x1
popq %r14
xorl %r15d, %r15d
leaq 0x60(%rsp), %rdi
callq 0x5100
leaq 0x2b0(%rsp), %rdi
callq 0x6ad8
movl %r12d, %ecx
movl %ecx, %r13d
movq %rbp, %rdi
callq 0x5100
leaq 0x38(%rsp), %rdi
callq 0x5100
movl %r15d, %r12d
leaq 0x120(%rsp), %rdi
callq 0x6aa6
leaq 0xa0(%rsp), %rdi
callq 0x6a62
leaq 0xc0(%rsp), %rdi
callq 0x6a62
leaq 0xe0(%rsp), %rdi
callq 0x6a84
leaq 0x100(%rsp), %rdi
callq 0x6ab6
leaq 0x3c0(%rsp), %r15
movq %r15, %rdi
callq 0x5080
testb $0x1, %r14b
movq 0x1ead7(%rip), %r14     # 0x24ff0
movl %r12d, %eax
movq 0x1eaa5(%rip), %r12     # 0x24fc8
movl %r13d, %ecx
je 0x5602
jmp 0x65b3
movq %rax, %r14
movq %r13, %rdi
callq 0x5100
jmp 0x6541
movq %rax, %r14
movq %r14, %rdi
callq 0x50d0
movq 0x1eaa0(%rip), %rdi     # 0x24ff0
leaq 0x11ad9(%rip), %rsi     # 0x18030
callq 0x51f0
movq %rax, %rdi
callq 0x5120
leaq 0x3c0(%rsp), %rdi
callq 0x5060
jmp 0x659f
movq %rax, %rdi
callq 0x50d0
movq %r14, %rdi
leaq 0x11a8d(%rip), %rsi     # 0x18012
callq 0x51f0
movq %rax, %rdi
callq 0x5120
leaq 0x3c0(%rsp), %rdi
callq 0x5060
callq 0x5340
xorl %r13d, %r13d
pushq $0x1
popq %r12
movl %r12d, %r14d
jmp 0x64bd
addq $0x5c8, %rsp            # imm = 0x5C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
callq 0x5340
jmp 0x675b
movq %rax, %rbx
callq 0x5340
jmp 0x675b
movq %rax, %rdi
callq 0x67b1
jmp 0x66e1
movq %rax, %rbx
leaq 0x230(%rsp), %rdi
jmp 0x66fe
jmp 0x66e1
movq %rax, %rbx
leaq 0x250(%rsp), %rdi
jmp 0x66fe
jmp 0x66e1
jmp 0x66e1
jmp 0x670a
movq %rax, %rbx
leaq 0x290(%rsp), %rdi
jmp 0x6723
movq %rax, %rbx
jmp 0x6728
movq %rax, %rbx
leaq 0x198(%rsp), %rdi
callq 0x5100
jmp 0x664d
movq %rax, %rbx
leaq 0x1b8(%rsp), %rdi
callq 0x6a62
jmp 0x665f
movq %rax, %rbx
leaq 0x168(%rsp), %rdi
callq 0x6a62
jmp 0x6671
movq %rax, %rbx
leaq 0x180(%rsp), %rdi
callq 0x6a84
jmp 0x6683
movq %rax, %rbx
leaq 0x208(%rsp), %rdi
callq 0x6aa6
leaq 0x1d0(%rsp), %rdi
callq 0x6ab6
jmp 0x6744
movq %rax, %rbx
jmp 0x6690
jmp 0x6741
jmp 0x6741
jmp 0x6741
jmp 0x66b8
movq %rax, %rbx
leaq 0x2b0(%rsp), %rdi
callq 0x5100
jmp 0x6744
jmp 0x670a
jmp 0x66e1
jmp 0x66e1
jmp 0x66e1
movq %rax, %rbx
leaq 0x1e8(%rsp), %rdi
jmp 0x66fe
jmp 0x66e1
movq %rax, %rbx
jmp 0x6703
movq %rax, %rbx
leaq 0x270(%rsp), %rdi
jmp 0x66fe
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x5100
jmp 0x6714
movq %rax, %rbx
jmp 0x675b
movq %rax, %rbx
jmp 0x671e
jmp 0x6741
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x5100
leaq 0x60(%rsp), %rdi
callq 0x5100
leaq 0x2b0(%rsp), %rdi
callq 0x6ad8
jmp 0x6744
jmp 0x6741
jmp 0x6741
jmp 0x6741
jmp 0x6741
jmp 0x6741
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
callq 0x5100
leaq 0x38(%rsp), %rdi
callq 0x5100
leaq 0x120(%rsp), %rdi
callq 0x6aa6
leaq 0xa0(%rsp), %rdi
callq 0x6a62
leaq 0xc0(%rsp), %rdi
callq 0x6a62
leaq 0xe0(%rsp), %rdi
callq 0x6a84
leaq 0x100(%rsp), %rdi
callq 0x6ab6
leaq 0x3c0(%rsp), %rdi
callq 0x5080
movq %rbx, %rdi
callq 0x5390