// File: Bartor[P]kompilator/main.cpp
// Function: main
int main(int argc, char **argv) {
    std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();

    if (argc < 2) {
        std::cerr << "[i] Usage: compiler <source> [destination] [optimize=(0|1)]" << std::endl;
        return 1;
    }

    FILE *source = fopen(argv[1], "r");
    if (!source) {
        std::cerr << "[e] Can't open " << argv[1] << std::endl;
        return 1;
    }

    bool optimize = true, verbose = false;
    for (int i = 0; i < argc; i++) {
        if (argv[i][0] == '-' && argv[i][1] == 'v') verbose = true;
        if (argv[i][0] == '-' && argv[i][1] == 'o') optimize = false;
    }

    std::cout << "[i] Compiling file " << argv[1] << (optimize ? " with optimization" : " without optimization") << std::endl;

    std::cout << "[i] Parsing... " << std::endl;

    yyin = source;
    yyparse();

    std::cout << "   [i] done" << std::endl;

    if (commands == nullptr) commands = new CommandList();
    if (declarations == nullptr) declarations = new DeclarationList();

    Program *program = new Program(*declarations, *commands, *constants);

    if (verbose) std::cout << "-=- A S T -=-" << std::endl;
    if (verbose) std::cout << program->toString() << std::endl;

    if (optimize) {
        std::cout << "[i] AST Optimization... " << std::endl;
        if (verbose) std::cout << std::endl;
        ASTOptimizer *astOptimizer = new ASTOptimizer(program);
        astOptimizer->optimize(verbose);
        if (verbose) std::cout << std::endl;
        std::cout << "   [i] done" << std::endl;

        if (verbose) std::cout << "-=- OPTIMIZED A S T -=-" << std::endl;
        if (verbose) std::cout << program->toString() << std::endl;
    }

    AbstractAssembler *assembler = new AbstractAssembler(*program);

    std::cout << "[i] Compiling... " << std::endl;
    if (verbose) std::cout << std::endl;

    try {
        InstructionList &assembled = assembler->assemble(verbose);

        std::cout << "   [i] done" << std::endl;

        if (verbose) std::cout << std::endl << "-=- A S M -=-" << std::endl;

        std::ofstream output;
        output.open(argv[2] ? argv[2] : "a.out");

        for (const auto &ins : assembled.getInstructions()) {
            if (!ins->stub) {
                if (verbose) std::cout << std::setbase(10) << ins->getAddress() << ": " << ins->toAssemblyCode(true) << std::endl;
                if (!optimize) output << ins->toAssemblyCode(true) << std::endl;
            }
        }

        if (optimize) {
            std::cout << "[i] ASM Optimization... " << std::endl;
            if (verbose) std::cout << std::endl;
            PeepholeOptimizer *peepholeOptimizer = new PeepholeOptimizer(assembled);

            peepholeOptimizer->optimize(verbose);
            assembled.seal(false);

            if (verbose) std::cout << std::endl;
            std::cout << "   [i] done" << std::endl;

            if (verbose) std::cout << std::endl << "-=- OPTIMIZED A S M -=-" << std::endl;

            for (const auto &ins : assembled.getInstructions()) {
                if (!ins->stub) {
                    if (verbose) std::cout << std::setbase(10) << ins->getAddress() << ": " << ins->toAssemblyCode(true) << std::endl;
                    output << ins->toAssemblyCode(true) << std::endl;
                }
            }
            output.close();
        }

        std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();

        if (warning) {
            std::cout << "[w] Compiled with warnings in " << std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count() << " ms" << std::endl;

        } else {
            std::cout << "[i] Compiled successfully in " << std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count() << " ms" << std::endl;
        }

    } catch (std::string errorMessage) {
        std::cout << "   [e] " << errorMessage << std::endl;
        std::cout << "[e] Aborting" << std::endl;
        return 1;
    } catch (char const *errorMessage) {
        std::cout << "   [e] " << errorMessage << std::endl;
        std::cout << "[e] Aborting" << std::endl;
        return 1;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x580, %rsp            # imm = 0x580
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
callq 0x6390
movq %rax, -0x18(%rbp)
cmpl $0x2, -0x8(%rbp)
jge 0x2edf6
movq 0x12221(%rip), %rdi     # 0x40ff0
leaq 0x3d90(%rip), %rsi      # 0x32b66
callq 0x6250
movq %rax, %rdi
movq 0x121ab(%rip), %rsi     # 0x40f90
callq 0x6280
movl $0x1, -0x4(%rbp)
jmp 0x2fdfc
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x3814(%rip), %rsi      # 0x32619
callq 0x6310
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x2ee53
movq 0x121d4(%rip), %rdi     # 0x40ff0
leaq 0x3d7f(%rip), %rsi      # 0x32ba2
callq 0x6250
movq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x6250
movq %rax, %rdi
movq 0x1214e(%rip), %rsi     # 0x40f90
callq 0x6280
movl $0x1, -0x4(%rbp)
jmp 0x2fdfc
movb $0x1, -0x21(%rbp)
movb $0x0, -0x22(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x2eed1
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x2ee97
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x76, %eax
jne 0x2ee97
movb $0x1, -0x22(%rbp)
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x2eec4
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x6f, %eax
jne 0x2eec4
movb $0x0, -0x21(%rbp)
jmp 0x2eec6
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x2ee62
movq 0x120f0(%rip), %rdi     # 0x40fc8
leaq 0x3cd3(%rip), %rsi      # 0x32bb2
callq 0x6250
movq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x6250
movq %rax, %rdi
movb -0x21(%rbp), %cl
leaq 0x3cd8(%rip), %rsi      # 0x32bd9
leaq 0x3cbe(%rip), %rax      # 0x32bc6
testb $0x1, %cl
cmovneq %rax, %rsi
callq 0x6250
movq %rax, %rdi
movq 0x12072(%rip), %rsi     # 0x40f90
callq 0x6280
movq 0x1209e(%rip), %rdi     # 0x40fc8
leaq 0x3cbe(%rip), %rsi      # 0x32bef
callq 0x6250
movq %rax, %rdi
movq 0x12050(%rip), %rsi     # 0x40f90
callq 0x6280
movq -0x20(%rbp), %rcx
leaq 0x12408(%rip), %rax     # 0x41358
movq %rcx, (%rax)
callq 0x6990
movq 0x12069(%rip), %rdi     # 0x40fc8
leaq 0x3c99(%rip), %rsi      # 0x32bff
callq 0x6250
movq %rax, %rdi
movq 0x1201b(%rip), %rsi     # 0x40f90
callq 0x6280
leaq 0x123a7(%rip), %rax     # 0x41328
cmpq $0x0, (%rax)
jne 0x2efda
movl $0x20, %edi
callq 0x6260
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x3c8(%rbp)
callq 0x8420
jmp 0x2efa5
movq -0x3c8(%rbp), %rcx
leaq 0x12375(%rip), %rax     # 0x41328
movq %rcx, (%rax)
jmp 0x2efda
movq -0x3c8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
movl $0x20, %esi
callq 0x6270
jmp 0x2fe08
leaq 0x1233f(%rip), %rax     # 0x41320
cmpq $0x0, (%rax)
jne 0x2f03a
movl $0x20, %edi
callq 0x6260
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x3d0(%rbp)
callq 0x83b0
jmp 0x2f005
movq -0x3d0(%rbp), %rcx
leaq 0x1230d(%rip), %rax     # 0x41320
movq %rcx, (%rax)
jmp 0x2f03a
movq -0x3d0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
movl $0x20, %esi
callq 0x6270
jmp 0x2fe08
movl $0x18, %edi
callq 0x6260
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x3d8(%rbp)
leaq 0x122c8(%rip), %rax     # 0x41320
movq (%rax), %rsi
leaq 0x122c6(%rip), %rax     # 0x41328
movq (%rax), %rdx
leaq 0x122c4(%rip), %rax     # 0x41330
movq (%rax), %rcx
callq 0x2fe20
jmp 0x2f076
movq -0x3d8(%rbp), %rax
movq %rax, -0x40(%rbp)
testb $0x1, -0x22(%rbp)
je 0x2f0cd
movq 0x11f3a(%rip), %rdi     # 0x40fc8
leaq 0x3b76(%rip), %rsi      # 0x32c0b
callq 0x6250
movq %rax, %rdi
movq 0x11eec(%rip), %rsi     # 0x40f90
callq 0x6280
jmp 0x2f0cd
movq -0x3d8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
movl $0x18, %esi
callq 0x6270
jmp 0x2fe08
testb $0x1, -0x22(%rbp)
je 0x2f13d
movq -0x40(%rbp), %rsi
leaq -0x60(%rbp), %rdi
movq %rdi, -0x3e8(%rbp)
callq 0xf050
movq -0x3e8(%rbp), %rsi
movq 0x11ed3(%rip), %rdi     # 0x40fc8
callq 0x6240
movq %rax, -0x3e0(%rbp)
jmp 0x2f103
movq -0x3e0(%rbp), %rdi
movq 0x11e7f(%rip), %rsi     # 0x40f90
callq 0x6280
jmp 0x2f118
leaq -0x60(%rbp), %rdi
callq 0x6598
jmp 0x2f13d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x6598
jmp 0x2fe08
testb $0x1, -0x21(%rbp)
je 0x2f2c2
movq 0x11e7a(%rip), %rdi     # 0x40fc8
leaq 0x3ac4(%rip), %rsi      # 0x32c19
callq 0x6250
movq %rax, %rdi
movq 0x11e2c(%rip), %rsi     # 0x40f90
callq 0x6280
testb $0x1, -0x22(%rbp)
je 0x2f182
movq 0x11e52(%rip), %rdi     # 0x40fc8
movq 0x11e13(%rip), %rsi     # 0x40f90
callq 0x6280
movl $0x8, %edi
callq 0x6260
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x3f0(%rbp)
movq -0x40(%rbp), %rsi
callq 0x2fe60
jmp 0x2f1a4
movq -0x3f0(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
movb -0x22(%rbp), %al
andb $0x1, %al
movzbl %al, %esi
callq 0x274f0
testb $0x1, -0x22(%rbp)
je 0x2f1fd
movq 0x11dfb(%rip), %rdi     # 0x40fc8
movq 0x11dbc(%rip), %rsi     # 0x40f90
callq 0x6280
jmp 0x2f1fd
movq -0x3f0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
movl $0x8, %esi
callq 0x6270
jmp 0x2fe08
movq 0x11dc4(%rip), %rdi     # 0x40fc8
leaq 0x39f4(%rip), %rsi      # 0x32bff
callq 0x6250
movq %rax, %rdi
movq 0x11d76(%rip), %rsi     # 0x40f90
callq 0x6280
testb $0x1, -0x22(%rbp)
je 0x2f247
movq 0x11d9c(%rip), %rdi     # 0x40fc8
leaq 0x39ff(%rip), %rsi      # 0x32c32
callq 0x6250
movq %rax, %rdi
movq 0x11d4e(%rip), %rsi     # 0x40f90
callq 0x6280
testb $0x1, -0x22(%rbp)
je 0x2f2c0
movq -0x40(%rbp), %rsi
leaq -0x88(%rbp), %rdi
movq %rdi, -0x400(%rbp)
callq 0xf050
movq -0x400(%rbp), %rsi
movq 0x11d56(%rip), %rdi     # 0x40fc8
callq 0x6240
movq %rax, -0x3f8(%rbp)
jmp 0x2f280
movq -0x3f8(%rbp), %rdi
movq 0x11d02(%rip), %rsi     # 0x40f90
callq 0x6280
jmp 0x2f295
leaq -0x88(%rbp), %rdi
callq 0x6598
jmp 0x2f2c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x6598
jmp 0x2fe08
jmp 0x2f2c2
movl $0x38, %edi
callq 0x6260
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x408(%rbp)
movq -0x40(%rbp), %rsi
callq 0x2fe80
jmp 0x2f2e4
movq -0x408(%rbp), %rax
movq %rax, -0x90(%rbp)
movq 0x11ccf(%rip), %rdi     # 0x40fc8
leaq 0x394a(%rip), %rsi      # 0x32c4a
callq 0x6250
movq %rax, %rdi
movq 0x11c81(%rip), %rsi     # 0x40f90
callq 0x6280
testb $0x1, -0x22(%rbp)
je 0x2f351
movq 0x11ca7(%rip), %rdi     # 0x40fc8
movq 0x11c68(%rip), %rsi     # 0x40f90
callq 0x6280
jmp 0x2f351
movq -0x408(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
movl $0x38, %esi
callq 0x6270
jmp 0x2fe08
movq -0x90(%rbp), %rdi
movzbl -0x22(%rbp), %esi
andl $0x1, %esi
callq 0x1f6d0
movq %rax, -0x410(%rbp)
jmp 0x2f36d
movq -0x410(%rbp), %rax
movq %rax, -0x98(%rbp)
movq 0x11c46(%rip), %rdi     # 0x40fc8
leaq 0x3876(%rip), %rsi      # 0x32bff
callq 0x6250
movq %rax, -0x418(%rbp)
jmp 0x2f397
movq -0x418(%rbp), %rdi
movq 0x11beb(%rip), %rsi     # 0x40f90
callq 0x6280
jmp 0x2f3ac
testb $0x1, -0x22(%rbp)
je 0x2f412
movq 0x11c0f(%rip), %rdi     # 0x40fc8
movq 0x11bd0(%rip), %rsi     # 0x40f90
callq 0x6280
movq %rax, -0x420(%rbp)
jmp 0x2f3ce
movq -0x420(%rbp), %rdi
leaq 0x3880(%rip), %rsi      # 0x32c5c
callq 0x6250
movq %rax, -0x428(%rbp)
jmp 0x2f3ea
movq -0x428(%rbp), %rdi
movq 0x11b98(%rip), %rsi     # 0x40f90
callq 0x6280
jmp 0x2f3ff
jmp 0x2f412
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x2fc34
leaq -0x298(%rbp), %rdi
callq 0x6480
jmp 0x2f420
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x2f43c
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x430(%rbp)
jmp 0x2f44c
leaq 0x3827(%rip), %rax      # 0x32c6a
movq %rax, -0x430(%rbp)
jmp 0x2f44c
movq -0x430(%rbp), %rsi
leaq -0x298(%rbp), %rdi
movl $0x10, %edx
callq 0x6050
jmp 0x2f466
movq -0x98(%rbp), %rdi
callq 0x2b160
movq %rax, -0x438(%rbp)
jmp 0x2f47b
movq -0x438(%rbp), %rax
movq %rax, -0x2a0(%rbp)
movq -0x2a0(%rbp), %rdi
callq 0x1fda0
movq %rax, -0x2a8(%rbp)
movq -0x2a0(%rbp), %rdi
callq 0x1fdd0
movq %rax, -0x2b0(%rbp)
leaq -0x2a8(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
callq 0x1fe00
testb $0x1, %al
jne 0x2f4cb
jmp 0x2f6af
leaq -0x2a8(%rbp), %rdi
callq 0x1fe40
movq %rax, -0x2b8(%rbp)
movq -0x2b8(%rbp), %rax
movq (%rax), %rax
testb $0x1, 0x10(%rax)
jne 0x2f69c
testb $0x1, -0x22(%rbp)
je 0x2f617
movl $0xa, %edi
callq 0x2ffb0
movl %eax, -0x43c(%rbp)
jmp 0x2f50e
movl -0x43c(%rbp), %eax
movl %eax, -0x2bc(%rbp)
movl -0x2bc(%rbp), %esi
movq 0x11aa1(%rip), %rdi     # 0x40fc8
callq 0x6220
movq %rax, -0x448(%rbp)
jmp 0x2f535
movq -0x2b8(%rbp), %rax
movq (%rax), %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
callq *%rax
movq %rax, -0x450(%rbp)
jmp 0x2f551
movq -0x450(%rbp), %rsi
movq -0x448(%rbp), %rdi
callq 0x6150
movq %rax, -0x458(%rbp)
jmp 0x2f56d
movq -0x458(%rbp), %rdi
leaq 0x31ca(%rip), %rsi      # 0x32745
callq 0x6250
movq %rax, -0x460(%rbp)
jmp 0x2f589
movq -0x2b8(%rbp), %rax
movq (%rax), %rsi
movq (%rsi), %rax
movq 0x10(%rax), %rax
leaq -0x2e0(%rbp), %rdi
movl $0x1, %edx
callq *%rax
jmp 0x2f5aa
movq -0x460(%rbp), %rdi
leaq -0x2e0(%rbp), %rsi
callq 0x6240
movq %rax, -0x468(%rbp)
jmp 0x2f5c6
movq -0x468(%rbp), %rdi
movq 0x119bc(%rip), %rsi     # 0x40f90
callq 0x6280
jmp 0x2f5db
leaq -0x2e0(%rbp), %rdi
callq 0x6598
jmp 0x2f617
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x2fc28
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x2e0(%rbp), %rdi
callq 0x6598
jmp 0x2fc28
testb $0x1, -0x21(%rbp)
jne 0x2f69a
movq -0x2b8(%rbp), %rax
movq (%rax), %rsi
movq (%rsi), %rax
movq 0x10(%rax), %rax
leaq -0x300(%rbp), %rdi
movl $0x1, %edx
callq *%rax
jmp 0x2f63e
leaq -0x298(%rbp), %rdi
leaq -0x300(%rbp), %rsi
callq 0x6240
movq %rax, -0x470(%rbp)
jmp 0x2f65a
movq -0x470(%rbp), %rdi
movq 0x11928(%rip), %rsi     # 0x40f90
callq 0x6280
jmp 0x2f66f
leaq -0x300(%rbp), %rdi
callq 0x6598
jmp 0x2f69a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x300(%rbp), %rdi
callq 0x6598
jmp 0x2fc28
jmp 0x2f69c
jmp 0x2f69e
leaq -0x2a8(%rbp), %rdi
callq 0x1fe60
jmp 0x2f4af
testb $0x1, -0x21(%rbp)
je 0x2fa67
movq 0x11908(%rip), %rdi     # 0x40fc8
leaq 0x35a9(%rip), %rsi      # 0x32c70
callq 0x6250
movq %rax, -0x478(%rbp)
jmp 0x2f6d5
movq -0x478(%rbp), %rdi
movq 0x118ad(%rip), %rsi     # 0x40f90
callq 0x6280
jmp 0x2f6ea
testb $0x1, -0x22(%rbp)
je 0x2f707
movq 0x118d1(%rip), %rdi     # 0x40fc8
movq 0x11892(%rip), %rsi     # 0x40f90
callq 0x6280
jmp 0x2f705
jmp 0x2f707
movl $0x8, %edi
callq 0x6260
movq %rax, -0x480(%rbp)
jmp 0x2f71a
movq -0x480(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x2ffd0
jmp 0x2f72f
movq -0x480(%rbp), %rax
movq %rax, -0x308(%rbp)
movq -0x308(%rbp), %rdi
movzbl -0x22(%rbp), %esi
andl $0x1, %esi
callq 0x2a280
jmp 0x2f752
movq -0x98(%rbp), %rdi
xorl %esi, %esi
callq 0x2b2a0
jmp 0x2f762
testb $0x1, -0x22(%rbp)
je 0x2f7a1
movq 0x11859(%rip), %rdi     # 0x40fc8
movq 0x1181a(%rip), %rsi     # 0x40f90
callq 0x6280
jmp 0x2f77d
jmp 0x2f7a1
movq -0x480(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
movl $0x8, %esi
callq 0x6270
jmp 0x2fc28
movq 0x11820(%rip), %rdi     # 0x40fc8
leaq 0x3450(%rip), %rsi      # 0x32bff
callq 0x6250
movq %rax, -0x488(%rbp)
jmp 0x2f7bd
movq -0x488(%rbp), %rdi
movq 0x117c5(%rip), %rsi     # 0x40f90
callq 0x6280
jmp 0x2f7d2
testb $0x1, -0x22(%rbp)
je 0x2f827
movq 0x117e9(%rip), %rdi     # 0x40fc8
movq 0x117aa(%rip), %rsi     # 0x40f90
callq 0x6280
movq %rax, -0x490(%rbp)
jmp 0x2f7f4
movq -0x490(%rbp), %rdi
leaq 0x3487(%rip), %rsi      # 0x32c89
callq 0x6250
movq %rax, -0x498(%rbp)
jmp 0x2f810
movq -0x498(%rbp), %rdi
movq 0x11772(%rip), %rsi     # 0x40f90
callq 0x6280
jmp 0x2f825
jmp 0x2f827
movq -0x98(%rbp), %rdi
callq 0x2b160
movq %rax, -0x4a0(%rbp)
jmp 0x2f83c
movq -0x4a0(%rbp), %rax
movq %rax, -0x310(%rbp)
movq -0x310(%rbp), %rdi
callq 0x1fda0
movq %rax, -0x318(%rbp)
movq -0x310(%rbp), %rdi
callq 0x1fdd0
movq %rax, -0x320(%rbp)
leaq -0x318(%rbp), %rdi
leaq -0x320(%rbp), %rsi
callq 0x1fe00
testb $0x1, %al
jne 0x2f88c
jmp 0x2fa57
leaq -0x318(%rbp), %rdi
callq 0x1fe40
movq %rax, -0x328(%rbp)
movq -0x328(%rbp), %rax
movq (%rax), %rax
testb $0x1, 0x10(%rax)
jne 0x2fa44
testb $0x1, -0x22(%rbp)
je 0x2f9c7
movl $0xa, %edi
callq 0x2ffb0
movl %eax, -0x4a4(%rbp)
jmp 0x2f8cf
movl -0x4a4(%rbp), %eax
movl %eax, -0x32c(%rbp)
movl -0x32c(%rbp), %esi
movq 0x116e0(%rip), %rdi     # 0x40fc8
callq 0x6220
movq %rax, -0x4b0(%rbp)
jmp 0x2f8f6
movq -0x328(%rbp), %rax
movq (%rax), %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
callq *%rax
movq %rax, -0x4b8(%rbp)
jmp 0x2f912
movq -0x4b8(%rbp), %rsi
movq -0x4b0(%rbp), %rdi
callq 0x6150
movq %rax, -0x4c0(%rbp)
jmp 0x2f92e
movq -0x4c0(%rbp), %rdi
leaq 0x2e09(%rip), %rsi      # 0x32745
callq 0x6250
movq %rax, -0x4c8(%rbp)
jmp 0x2f94a
movq -0x328(%rbp), %rax
movq (%rax), %rsi
movq (%rsi), %rax
movq 0x10(%rax), %rax
leaq -0x350(%rbp), %rdi
movl $0x1, %edx
callq *%rax
jmp 0x2f96b
movq -0x4c8(%rbp), %rdi
leaq -0x350(%rbp), %rsi
callq 0x6240
movq %rax, -0x4d0(%rbp)
jmp 0x2f987
movq -0x4d0(%rbp), %rdi
movq 0x115fb(%rip), %rsi     # 0x40f90
callq 0x6280
jmp 0x2f99c
leaq -0x350(%rbp), %rdi
callq 0x6598
jmp 0x2f9c7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x350(%rbp), %rdi
callq 0x6598
jmp 0x2fc28
movq -0x328(%rbp), %rax
movq (%rax), %rsi
movq (%rsi), %rax
movq 0x10(%rax), %rax
leaq -0x370(%rbp), %rdi
movl $0x1, %edx
callq *%rax
jmp 0x2f9e8
leaq -0x298(%rbp), %rdi
leaq -0x370(%rbp), %rsi
callq 0x6240
movq %rax, -0x4d8(%rbp)
jmp 0x2fa04
movq -0x4d8(%rbp), %rdi
movq 0x1157e(%rip), %rsi     # 0x40f90
callq 0x6280
jmp 0x2fa19
leaq -0x370(%rbp), %rdi
callq 0x6598
jmp 0x2fa44
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x370(%rbp), %rdi
callq 0x6598
jmp 0x2fc28
jmp 0x2fa46
leaq -0x318(%rbp), %rdi
callq 0x1fe60
jmp 0x2f870
leaq -0x298(%rbp), %rdi
callq 0x63c0
jmp 0x2fa65
jmp 0x2fa67
callq 0x6390
movq %rax, -0x378(%rbp)
testb $0x1, 0x119e8(%rip)     # 0x41462
je 0x2fb4d
movq 0x11541(%rip), %rdi     # 0x40fc8
leaq 0x3213(%rip), %rsi      # 0x32ca1
callq 0x6250
movq %rax, -0x4e0(%rbp)
jmp 0x2fa9c
leaq -0x378(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x30020
movq %rax, -0x4e8(%rbp)
jmp 0x2fab5
movq -0x4e8(%rbp), %rax
movq %rax, -0x388(%rbp)
leaq -0x388(%rbp), %rdi
callq 0x2fff0
movq %rax, -0x4f0(%rbp)
jmp 0x2fad8
movq -0x4f0(%rbp), %rax
movq %rax, -0x380(%rbp)
leaq -0x380(%rbp), %rdi
callq 0x30070
movq %rax, -0x4f8(%rbp)
jmp 0x2fafb
movq -0x4f8(%rbp), %rsi
movq -0x4e0(%rbp), %rdi
callq 0x6510
movq %rax, -0x500(%rbp)
jmp 0x2fb17
movq -0x500(%rbp), %rdi
leaq 0x319b(%rip), %rsi      # 0x32cc0
callq 0x6250
movq %rax, -0x508(%rbp)
jmp 0x2fb33
movq -0x508(%rbp), %rdi
movq 0x1144f(%rip), %rsi     # 0x40f90
callq 0x6280
jmp 0x2fb48
jmp 0x2fc17
movq 0x11474(%rip), %rdi     # 0x40fc8
leaq 0x3169(%rip), %rsi      # 0x32cc4
callq 0x6250
movq %rax, -0x510(%rbp)
jmp 0x2fb69
leaq -0x378(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x30020
movq %rax, -0x518(%rbp)
jmp 0x2fb82
movq -0x518(%rbp), %rax
movq %rax, -0x398(%rbp)
leaq -0x398(%rbp), %rdi
callq 0x2fff0
movq %rax, -0x520(%rbp)
jmp 0x2fba5
movq -0x520(%rbp), %rax
movq %rax, -0x390(%rbp)
leaq -0x390(%rbp), %rdi
callq 0x30070
movq %rax, -0x528(%rbp)
jmp 0x2fbc8
movq -0x528(%rbp), %rsi
movq -0x510(%rbp), %rdi
callq 0x6510
movq %rax, -0x530(%rbp)
jmp 0x2fbe4
movq -0x530(%rbp), %rdi
leaq 0x30ce(%rip), %rsi      # 0x32cc0
callq 0x6250
movq %rax, -0x538(%rbp)
jmp 0x2fc00
movq -0x538(%rbp), %rdi
movq 0x11382(%rip), %rsi     # 0x40f90
callq 0x6280
jmp 0x2fc15
jmp 0x2fc17
leaq -0x298(%rbp), %rdi
callq 0x63f0
jmp 0x2fdf5
leaq -0x298(%rbp), %rdi
callq 0x63f0
movl -0x34(%rbp), %eax
movl %eax, -0x53c(%rbp)
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x2fd12
movq -0x30(%rbp), %rdi
movq %rdi, -0x548(%rbp)
callq 0x6360
movq %rax, %rsi
leaq -0x3c0(%rbp), %rdi
callq 0x6100
jmp 0x2fc6b
movq -0x548(%rbp), %rdi
callq 0x60f0
movq 0x1134a(%rip), %rdi     # 0x40fc8
leaq 0x198d(%rip), %rsi      # 0x31612
callq 0x6250
movq %rax, -0x550(%rbp)
jmp 0x2fc93
movq -0x550(%rbp), %rdi
leaq -0x3c0(%rbp), %rsi
callq 0x6240
movq %rax, -0x558(%rbp)
jmp 0x2fcaf
movq -0x558(%rbp), %rdi
movq 0x112d3(%rip), %rsi     # 0x40f90
callq 0x6280
jmp 0x2fcc4
movq 0x112fd(%rip), %rdi     # 0x40fc8
leaq 0x1952(%rip), %rsi      # 0x31624
callq 0x6250
movq %rax, -0x560(%rbp)
jmp 0x2fce0
movq -0x560(%rbp), %rdi
movq 0x112a2(%rip), %rsi     # 0x40f90
callq 0x6280
jmp 0x2fcf5
movl $0x1, -0x4(%rbp)
leaq -0x3c0(%rbp), %rdi
callq 0x6598
callq 0x6450
jmp 0x2fdfc
movl -0x53c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x2fe08
movq -0x30(%rbp), %rdi
callq 0x60f0
movq %rax, -0x3a0(%rbp)
movq 0x1128c(%rip), %rdi     # 0x40fc8
leaq 0x18cf(%rip), %rsi      # 0x31612
callq 0x6250
movq %rax, -0x568(%rbp)
jmp 0x2fd51
movq -0x568(%rbp), %rdi
movq -0x3a0(%rbp), %rsi
callq 0x6250
movq %rax, -0x570(%rbp)
jmp 0x2fd6d
movq -0x570(%rbp), %rdi
movq 0x11215(%rip), %rsi     # 0x40f90
callq 0x6280
jmp 0x2fd82
movq 0x1123f(%rip), %rdi     # 0x40fc8
leaq 0x1894(%rip), %rsi      # 0x31624
callq 0x6250
movq %rax, -0x578(%rbp)
jmp 0x2fd9e
movq -0x578(%rbp), %rdi
movq 0x111e4(%rip), %rsi     # 0x40f90
callq 0x6280
jmp 0x2fdb3
movl $0x1, -0x4(%rbp)
callq 0x6450
jmp 0x2fdfc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
callq 0x6450
jmp 0x2fe08
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x3c0(%rbp), %rdi
callq 0x6598
callq 0x6450
jmp 0x2fdf3
jmp 0x2fe08
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x580, %rsp            # imm = 0x580
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x64d0
movq %rax, %rdi
callq 0x9470
nopl (%rax)