// File: /workspace/github_cpp_makefile_star2_O1/sidvishnoi[P]filesystem-assignment/handleInput.cpp
// Function: handleInput(FileSystem&)
int handleInput(FileSystem &disk) {
    /*
    objective: to create a terminal like CLI to handle disk operations
    input: reference to disk
    return:
        0: continue
        1: exit
    */
    string command;
    cout << KGRN << "(myFileSystem)> " << KRST;
    getline(cin, command);
    if (command.empty()) return 1;

    // split command into function and argument part
    vector<string> tokens;
    tokens = split(command, ' ');
    string fun = tokens[0];
    string arg = "";
    if (tokens.size() > 1) {
        arg = tokens[1];
    }

    string arg2 = "";
    if (tokens.size() > 2) {
        arg2 = tokens[2];
    }

    enum Choice {
        HELP, INFO, TREE, READ, CHECK, WRITE, FORMAT, EXIT, NEW_FILE, CAT, DEL, UNDEL, MKDIR, CD, PWD, LS, END
    };
    string CHOICES[] = {
        "help", "info", "tree", "read", "check", "write", "format", "exit", "new", "cat", "del", "undel", "mkdir", "chdir", "pwd", "list", ""
    };
    string choices[] = {
        "h", "info", "tree", "r", "c", "w", "f", "q", "n", "cat", "del", "undel", "mkdir", "cd", "pwd", "ls", ""
    };

    Choice selected = END;
    for (int i = 0; i < END; ++i) {
        if (CHOICES[i] == fun || choices[i] == fun) {
            selected = static_cast<Choice>(i);
            break;
        }
    }

    int sector;
    // handle command
    switch (selected) {
        case READ: {
            if (arg.empty()) {
                cout << "usage: read SECTOR" << endl;
                return 0;
            }
            // convert string to int
            istringstream(arg) >> sector;
            char readBuffer[kSectorSize_g];
            disk.readSector(sector, readBuffer);
            for (int i = 0; i < kSectorSize_g; ++i) {
                cout << readBuffer[i];
            }
            cout << endl;
            break;
        }
        case WRITE: {
            if (arg.empty()) {
                cout << "usage: write SECTOR" << endl;
                return 0;
            }
            istringstream(arg) >> sector;
            if (disk.getStatus(sector) == FileSystem::BUSY) {
                cout << "Overwrite sector data (y/n)? _\b";
                char t;
                cin >> t;
                if (t == 'y' || t == 'Y') {
                    char buf[kSectorSize_g];
                    createBuffer('.', buf);
                    disk.writeSector(sector, buf);
                } else {
                    cin.ignore(32767, '\n');
                    return 0;
                }
            } else {
                char buf[kSectorSize_g];
                createBuffer('.', buf);
                disk.writeSector(sector, buf);
                disk.setStatus(sector, 1);
            }
            break;
        }
        case CHECK: {
            if (arg.empty()) {
                cout << "usage: check SECTOR" << endl;
                return 0;
            }
            istringstream(arg) >> sector;
            int status = disk.getStatus(sector);
            cout << "sector #" << sector << " is ";
            if (status < disk.END && status > -1) {
                cout << disk.statusMsg[status] << endl;
            } else {
                cout << "pointing to sector #" << status << endl;
            }
            break;
        }
        case FORMAT:
            disk.format();
            break;
        case HELP: {
            ifstream helpFile;
            helpFile.open("help.txt", ios::in | ios::ate);
            int helpFileSize = helpFile.tellg();
            char helpMsg[helpFileSize];
            helpFile.seekg(0);
            helpFile.read(helpMsg, helpFileSize);
            helpFile.close();
            cout << helpMsg << endl;
            break;
        }
        case INFO:
            disk.info();
            break;
        case TREE:
            disk.tree();
            break;
        case NEW_FILE: {
            if (arg.empty()) {
                cout << "usage: new FILE_NAME [SRC_FILE]" << endl;
                return 0;
            }
            disk.createFile(arg.c_str(), arg2.c_str());
            break;
        }
        case CAT: {
            if (arg.empty()) {
                cout << "usage: cat FILE_NAME" << endl;
                return 0;
            }
            disk.readFile(arg.c_str());
            break;
        }
        case DEL: {
            if (arg.empty()) {
                cout << "usage: del FILE_NAME" << endl;
                return 0;
            }
            disk.deleteFile(arg.c_str());
            break;
        }
        case UNDEL: {
            if (arg.empty()) {
                cout << "usage: undel FILE_NAME" << endl;
                return 0;
            }
            disk.undeleteFile(arg.c_str());
            break;
        }
        case MKDIR: {
            if (arg.empty()) {
                cout << "usage: mkdir DIR_NAME" << endl;
                return 0;
            }
            disk.createDir(arg.c_str());
            break;
        }
        case CD: {
            if (arg.empty()) {
                cout << "usage: cd DIR_NAME" << endl;
                return 0;
            }
            vector<string> dir = split(arg, '/');
            for (int i = 0; i < dir.size(); ++i) {
                disk.changeDir(dir[i].c_str());
            }
            break;
        }
        case PWD:
            disk.printWorkingDir();
            break;
        case LS:
            disk.listDirectoryContents();
            break;
        case EXIT:
            return 1;
        default:
            cout << "(myFileSystem): command not found: " << fun << endl;
            return 0;
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x6f8, %rsp            # imm = 0x6F8
movq %rdi, -0x38(%rbp)
leaq -0xc8(%rbp), %r15
movq %r15, -0x10(%r15)
movq $0x0, -0x8(%r15)
movb $0x0, (%r15)
movq 0x52a5(%rip), %rdi      # 0x7fd0
leaq 0x239f(%rip), %rsi      # 0x50d1
movl $0x5, %edx
callq 0x2210
movq 0x528d(%rip), %rdi      # 0x7fd0
leaq 0x238d(%rip), %rsi      # 0x50d7
movl $0x10, %edx
callq 0x2210
movq 0x5275(%rip), %rdi      # 0x7fd0
leaq 0x2386(%rip), %rsi      # 0x50e8
movl $0x4, %edx
callq 0x2210
movq 0x526d(%rip), %rdi      # 0x7fe0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %edx
movq 0x5252(%rip), %rdi      # 0x7fe0
leaq -0xd8(%rbp), %rsi
callq 0x2380
cmpq $0x0, -0xd0(%rbp)
je 0x3574
xorps %xmm0, %xmm0
movaps %xmm0, -0x70(%rbp)
movq $0x0, -0x60(%rbp)
leaq -0x500(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
movl $0x20, %edx
callq 0x2b84
leaq -0x720(%rbp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, (%rdi)
movaps -0x70(%rbp), %xmm0
movq -0x60(%rbp), %rax
leaq -0x500(%rbp), %r14
movups (%r14), %xmm1
movaps %xmm1, -0x70(%rbp)
movq 0x10(%r14), %rcx
movq %rcx, -0x60(%rbp)
movaps (%rdi), %xmm1
movaps %xmm0, (%rdi)
movq %rax, 0x10(%rdi)
movups %xmm1, (%r14)
movq $0x0, 0x10(%r14)
callq 0x2a96
movq %r14, %rdi
callq 0x2a96
movq -0x70(%rbp), %rax
leaq -0x88(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x98(%rbp), %rdi
callq 0x2af2
leaq -0x48(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x2340(%rip), %rdx      # 0x5192
leaq -0x58(%rbp), %rdi
movq %rdx, %rsi
callq 0x3e38
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rax
subq %rsi, %rax
cmpq $0x21, %rax
jb 0x2e7c
addq $0x20, %rsi
leaq -0x58(%rbp), %rdi
callq 0x20e0
leaq -0xa8(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x2304(%rip), %rdx      # 0x5192
leaq -0xb8(%rbp), %rdi
movq %rdx, %rsi
callq 0x3e38
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rax
subq %rsi, %rax
cmpq $0x41, %rax
jb 0x2ebe
addq $0x40, %rsi
leaq -0xb8(%rbp), %rdi
callq 0x20e0
leaq -0x710(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x221d(%rip), %rsi      # 0x50ed
leaq 0x221a(%rip), %rdx      # 0x50f1
leaq -0x720(%rbp), %r14
movq %r14, %rdi
callq 0x3e38
leaq -0x700(%rbp), %r15
leaq -0x6f0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x21f3(%rip), %rsi      # 0x50f2
leaq 0x21f0(%rip), %rdx      # 0x50f6
movq %r15, %rdi
callq 0x3e38
leaq -0x6e0(%rbp), %r15
leaq -0x6d0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x21d0(%rip), %rsi      # 0x50f7
leaq 0x21cd(%rip), %rdx      # 0x50fb
movq %r15, %rdi
callq 0x3e38
leaq -0x6c0(%rbp), %r15
leaq -0x6b0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x21ad(%rip), %rsi      # 0x50fc
leaq 0x21aa(%rip), %rdx      # 0x5100
movq %r15, %rdi
callq 0x3e38
leaq -0x6a0(%rbp), %r15
leaq -0x690(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x218a(%rip), %rsi      # 0x5101
leaq 0x2188(%rip), %rdx      # 0x5106
movq %r15, %rdi
callq 0x3e38
leaq -0x680(%rbp), %r15
leaq -0x670(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x2168(%rip), %rsi      # 0x5107
leaq 0x2166(%rip), %rdx      # 0x510c
movq %r15, %rdi
callq 0x3e38
leaq -0x660(%rbp), %r15
leaq -0x650(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x2146(%rip), %rsi      # 0x510d
leaq 0x2145(%rip), %rdx      # 0x5113
movq %r15, %rdi
callq 0x3e38
leaq -0x640(%rbp), %r15
leaq -0x630(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x2125(%rip), %rsi      # 0x5114
leaq 0x2122(%rip), %rdx      # 0x5118
movq %r15, %rdi
callq 0x3e38
leaq -0x620(%rbp), %r15
leaq -0x610(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x2102(%rip), %rsi      # 0x5119
leaq 0x20fe(%rip), %rdx      # 0x511c
movq %r15, %rdi
callq 0x3e38
leaq -0x600(%rbp), %r15
leaq -0x5f0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x20de(%rip), %rsi      # 0x511d
leaq 0x20da(%rip), %rdx      # 0x5120
movq %r15, %rdi
callq 0x3e38
leaq -0x5e0(%rbp), %r15
leaq -0x5d0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x20bc(%rip), %rsi      # 0x5123
leaq 0x20b8(%rip), %rdx      # 0x5126
movq %r15, %rdi
callq 0x3e38
leaq -0x5c0(%rbp), %r15
leaq -0x5b0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x2092(%rip), %rsi      # 0x5121
leaq 0x2090(%rip), %rdx      # 0x5126
movq %r15, %rdi
callq 0x3e38
leaq -0x5a0(%rbp), %r15
leaq -0x590(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x2070(%rip), %rsi      # 0x5127
leaq 0x206e(%rip), %rdx      # 0x512c
movq %r15, %rdi
callq 0x3e38
leaq -0x580(%rbp), %r15
leaq -0x570(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x204e(%rip), %rsi      # 0x512d
leaq 0x204c(%rip), %rdx      # 0x5132
movq %r15, %rdi
callq 0x3e38
leaq -0x560(%rbp), %r15
leaq -0x550(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x202c(%rip), %rsi      # 0x5133
leaq 0x2028(%rip), %rdx      # 0x5136
movq %r15, %rdi
callq 0x3e38
leaq -0x540(%rbp), %r15
leaq -0x530(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x2008(%rip), %rsi      # 0x5137
leaq 0x2005(%rip), %rdx      # 0x513b
movq %r15, %rdi
callq 0x3e38
leaq -0x520(%rbp), %r15
leaq -0x510(%rbp), %r13
movq %r13, -0x10(%r13)
leaq 0x203b(%rip), %rdx      # 0x5192
movq %r15, %rdi
movq %rdx, %rsi
callq 0x3e38
leaq -0x4f0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1fc8(%rip), %rsi      # 0x513c
leaq 0x1fc2(%rip), %rdx      # 0x513d
leaq -0x500(%rbp), %r14
movq %r14, %rdi
callq 0x3e38
leaq -0x4e0(%rbp), %r15
leaq -0x4d0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f4f(%rip), %rsi      # 0x50f2
leaq 0x1f4c(%rip), %rdx      # 0x50f6
movq %r15, %rdi
callq 0x3e38
leaq -0x4c0(%rbp), %r15
leaq -0x4b0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f2c(%rip), %rsi      # 0x50f7
leaq 0x1f29(%rip), %rdx      # 0x50fb
movq %r15, %rdi
callq 0x3e38
leaq -0x4a0(%rbp), %r15
leaq -0x490(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f3e(%rip), %rsi      # 0x5131
leaq 0x1f38(%rip), %rdx      # 0x5132
movq %r15, %rdi
callq 0x3e38
leaq -0x480(%rbp), %r15
leaq -0x470(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f23(%rip), %rsi      # 0x513e
leaq 0x1f1d(%rip), %rdx      # 0x513f
movq %r15, %rdi
callq 0x3e38
leaq -0x460(%rbp), %r15
leaq -0x450(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1ed8(%rip), %rsi      # 0x511b
leaq 0x1ed2(%rip), %rdx      # 0x511c
movq %r15, %rdi
callq 0x3e38
leaq -0x440(%rbp), %r15
leaq -0x430(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1ed5(%rip), %rsi      # 0x5140
leaq 0x1ecf(%rip), %rdx      # 0x5141
movq %r15, %rdi
callq 0x3e38
leaq -0x420(%rbp), %r15
leaq -0x410(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1eaf(%rip), %rsi      # 0x5142
leaq 0x1ea9(%rip), %rdx      # 0x5143
movq %r15, %rdi
callq 0x3e38
leaq -0x400(%rbp), %r15
leaq -0x3f0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1e89(%rip), %rsi      # 0x5144
leaq 0x1e83(%rip), %rdx      # 0x5145
movq %r15, %rdi
callq 0x3e38
leaq -0x3e0(%rbp), %r15
leaq -0x3d0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1e3a(%rip), %rsi      # 0x511d
leaq 0x1e36(%rip), %rdx      # 0x5120
movq %r15, %rdi
callq 0x3e38
leaq -0x3c0(%rbp), %r15
leaq -0x3b0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1e18(%rip), %rsi      # 0x5123
leaq 0x1e14(%rip), %rdx      # 0x5126
movq %r15, %rdi
callq 0x3e38
leaq -0x3a0(%rbp), %r15
leaq -0x390(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1dee(%rip), %rsi      # 0x5121
leaq 0x1dec(%rip), %rdx      # 0x5126
movq %r15, %rdi
callq 0x3e38
leaq -0x380(%rbp), %r15
leaq -0x370(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1dcc(%rip), %rsi      # 0x5127
leaq 0x1dca(%rip), %rdx      # 0x512c
movq %r15, %rdi
callq 0x3e38
leaq -0x360(%rbp), %r15
leaq -0x350(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1dc3(%rip), %rsi      # 0x5146
leaq 0x1dbe(%rip), %rdx      # 0x5148
movq %r15, %rdi
callq 0x3e38
leaq -0x340(%rbp), %r15
leaq -0x330(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1d88(%rip), %rsi      # 0x5133
leaq 0x1d84(%rip), %rdx      # 0x5136
movq %r15, %rdi
callq 0x3e38
leaq -0x320(%rbp), %r15
leaq -0x310(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1d76(%rip), %rsi      # 0x5149
leaq 0x1d71(%rip), %rdx      # 0x514b
movq %r15, %rdi
callq 0x3e38
leaq -0x300(%rbp), %r15
leaq -0x2f0(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x1d96(%rip), %rdx      # 0x5192
movq %r15, %rdi
movq %rdx, %rsi
callq 0x3e38
movq -0x98(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x90(%rbp), %rbx
movl $0x8, %r14d
xorl %r15d, %r15d
movq -0x720(%rbp,%r14), %rdx
cmpq %rbx, %rdx
jne 0x3449
testq %rdx, %rdx
je 0x3483
movq -0x728(%rbp,%r14), %rdi
movq -0x78(%rbp), %rsi
callq 0x21f0
testl %eax, %eax
je 0x3483
movq -0x500(%rbp,%r14), %rdx
cmpq %rbx, %rdx
jne 0x3470
testq %rdx, %rdx
je 0x3483
movq -0x508(%rbp,%r14), %rdi
movq -0x78(%rbp), %rsi
callq 0x21f0
testl %eax, %eax
je 0x3483
incq %r15
addq $0x20, %r14
cmpq $0x10, %r15
jne 0x3422
movl $0x10, %r15d
cmpl $0xf, %r15d
ja 0x3921
movl %r15d, %eax
leaq 0x1be9(%rip), %rcx      # 0x5080
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x2e0(%rbp), %rdi
callq 0x2200
leaq 0x1d0e(%rip), %rsi      # 0x51c1
leaq -0x2e0(%rbp), %rdi
movl $0xa, %edx
callq 0x2110
leaq -0x2e0(%rbp), %rdi
callq 0x2350
movq %rax, %r14
movq %rsp, %r15
movl %r14d, %eax
movq %rsp, %rbx
addq $0xf, %rax
andq $-0x10, %rax
subq %rax, %rbx
movq %rbx, %rsp
leaq -0x2e0(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2240
movslq %r14d, %rdx
leaq -0x2e0(%rbp), %rdi
movq %rbx, %rsi
callq 0x2230
leaq -0x2e0(%rbp), %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x20a0
movq 0x4aa9(%rip), %r14      # 0x7fd0
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x2210
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq 0x4a7d(%rip), %rdi      # 0x7fd0
callq 0x2030
movq %rax, %rdi
callq 0x2130
movq %r15, %rsp
leaq -0x2e0(%rbp), %rdi
callq 0x2050
jmp 0x3a16
movl $0x1, %ebx
jmp 0x3ad2
movq -0x38(%rbp), %rdi
callq 0x4fa0
jmp 0x3a16
cmpq $0x0, -0x50(%rbp)
je 0x3982
movq -0x58(%rbp), %rsi
movq -0x38(%rbp), %rdi
callq 0x4e98
jmp 0x3a16
cmpq $0x0, -0x50(%rbp)
je 0x3990
leaq -0x2e0(%rbp), %rdi
leaq -0x58(%rbp), %rsi
movl $0x8, %edx
callq 0x2320
leaq -0x2e0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x2100
movq -0x38(%rbp), %rbx
movq 0x49e4(%rip), %rsi      # 0x7fc8
leaq -0x2e0(%rbp), %rdi
callq 0x22a0
leaq -0x268(%rbp), %rdi
callq 0x2070
movl -0x30(%rbp), %esi
movq %rbx, %rdi
callq 0x4760
movl %eax, %r14d
movq 0x49bf(%rip), %rdi      # 0x7fd0
leaq 0x1ba0(%rip), %rsi      # 0x51b8
movl $0x8, %edx
callq 0x2210
movl -0x30(%rbp), %esi
movq 0x49a4(%rip), %rdi      # 0x7fd0
callq 0x2340
leaq 0x1b6f(%rip), %rsi      # 0x51a7
movl $0x4, %edx
movq %rax, %rdi
callq 0x2210
cmpl $0x5, %r14d
ja 0x3b36
movl %r14d, %eax
movq 0x68(%rbx), %rcx
shlq $0x5, %rax
movq (%rcx,%rax), %rsi
movq 0x8(%rcx,%rax), %rdx
movq 0x4966(%rip), %rdi      # 0x7fd0
callq 0x2210
jmp 0x3b5d
cmpq $0x0, -0x50(%rbp)
je 0x399e
movq -0x58(%rbp), %rsi
movq -0x38(%rbp), %rdi
callq 0x4ec8
jmp 0x3a16
cmpq $0x0, -0x50(%rbp)
je 0x39ac
movq -0x58(%rbp), %rsi
movq -0x38(%rbp), %rdi
callq 0x4e38
jmp 0x3a16
movq -0x38(%rbp), %rdi
movl $0x1, %esi
movl $0x2, %edx
callq 0x4fac
jmp 0x3a16
movq -0x38(%rbp), %rdi
callq 0x4fa4
jmp 0x3a16
cmpq $0x0, -0x50(%rbp)
je 0x39ba
leaq -0x2e0(%rbp), %rdi
leaq -0x58(%rbp), %rsi
movl $0x8, %edx
callq 0x2320
leaq -0x2e0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x2100
movq -0x38(%rbp), %rbx
movq 0x48b9(%rip), %rsi      # 0x7fc8
leaq -0x2e0(%rbp), %rdi
callq 0x22a0
leaq -0x268(%rbp), %rdi
callq 0x2070
movl -0x30(%rbp), %esi
leaq -0x2e0(%rbp), %rdx
movq %rbx, %rdi
callq 0x46d0
xorl %r15d, %r15d
movq 0x488d(%rip), %rbx      # 0x7fd0
leaq -0x29(%rbp), %r14
movb -0x2e0(%rbp,%r15), %al
movb %al, -0x29(%rbp)
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2210
incq %r15
cmpq $0x200, %r15            # imm = 0x200
jne 0x3747
movq 0x485b(%rip), %rdi      # 0x7fd0
callq 0x20c0
jmp 0x3a16
movl $0x1, %ebx
jmp 0x3a18
movq -0x38(%rbp), %rdi
callq 0x4fa8
jmp 0x3a16
cmpq $0x0, -0x50(%rbp)
je 0x39c8
leaq -0x2e0(%rbp), %rdi
leaq -0x58(%rbp), %rsi
movl $0x8, %edx
callq 0x2320
leaq -0x2e0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x2100
movq -0x38(%rbp), %rbx
movq 0x47f6(%rip), %rsi      # 0x7fc8
leaq -0x2e0(%rbp), %rdi
callq 0x22a0
leaq -0x268(%rbp), %rdi
callq 0x2070
movl -0x30(%rbp), %esi
movq %rbx, %rdi
callq 0x4760
cmpl $0x1, %eax
jne 0x3afe
movq 0x47cb(%rip), %rdi      # 0x7fd0
leaq 0x1967(%rip), %rsi      # 0x5173
movl $0x1f, %edx
callq 0x2210
movq 0x47c3(%rip), %rdi      # 0x7fe0
leaq -0x29(%rbp), %rsi
callq 0x2270
movb -0x29(%rbp), %al
andb $-0x21, %al
cmpb $0x59, %al
jne 0x3b6a
leaq -0x2e0(%rbp), %rsi
movl $0x2e, %edi
callq 0x2c8b
movl -0x30(%rbp), %esi
leaq -0x2e0(%rbp), %rdx
movq %rbx, %rdi
callq 0x4624
jmp 0x3a16
cmpq $0x0, -0x50(%rbp)
je 0x39d6
leaq -0x2e0(%rbp), %rdi
leaq -0x58(%rbp), %rsi
movl $0x2f, %edx
callq 0x2b84
movq -0x2e0(%rbp), %rax
cmpq %rax, -0x2d8(%rbp)
movq -0x38(%rbp), %r15
je 0x38c1
xorl %ebx, %ebx
xorl %r14d, %r14d
movq (%rax,%rbx), %rsi
movq %r15, %rdi
callq 0x4ec8
incq %r14
movq -0x2e0(%rbp), %rax
movq -0x2d8(%rbp), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
addq $0x20, %rbx
cmpq %r14, %rcx
ja 0x3894
leaq -0x2e0(%rbp), %rdi
callq 0x2a96
jmp 0x3a16
movq -0x38(%rbp), %rdi
callq 0x490c
jmp 0x3a16
cmpq $0x0, -0x50(%rbp)
je 0x39e4
movq -0x58(%rbp), %rsi
movq -0x38(%rbp), %rdi
callq 0x4e68
jmp 0x3a16
cmpq $0x0, -0x50(%rbp)
je 0x39f2
movq -0x58(%rbp), %rsi
movq -0xb8(%rbp), %rdx
movq -0x38(%rbp), %rdi
callq 0x4e38
jmp 0x3a16
movq 0x46a8(%rip), %rdi      # 0x7fd0
leaq 0x1925(%rip), %rsi      # 0x5254
movl $0x23, %edx
callq 0x2210
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rdx
movq 0x4682(%rip), %rdi      # 0x7fd0
callq 0x2210
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
jmp 0x3a16
movl $0x16, %edx
leaq 0x1886(%rip), %rsi      # 0x5214
jmp 0x39fe
movl $0x13, %edx
leaq 0x17f7(%rip), %rsi      # 0x5193
jmp 0x39fe
movl $0x15, %edx
leaq 0x1881(%rip), %rsi      # 0x522b
jmp 0x39fe
movl $0x14, %edx
leaq 0x1832(%rip), %rsi      # 0x51ea
jmp 0x39fe
movl $0x12, %edx
leaq 0x1786(%rip), %rsi      # 0x514c
jmp 0x39fe
movl $0x13, %edx
leaq 0x178b(%rip), %rsi      # 0x515f
jmp 0x39fe
movl $0x12, %edx
leaq 0x185f(%rip), %rsi      # 0x5241
jmp 0x39fe
movl $0x14, %edx
leaq 0x180f(%rip), %rsi      # 0x51ff
jmp 0x39fe
movl $0x1f, %edx
leaq 0x17cc(%rip), %rsi      # 0x51ca
movq 0x45cb(%rip), %rdi      # 0x7fd0
callq 0x2210
movq 0x45bf(%rip), %rdi      # 0x7fd0
callq 0x20c0
xorl %ebx, %ebx
movq $-0x220, %r14           # imm = 0xFDE0
movq -0x10(%r12), %rdi
cmpq %rdi, %r12
je 0x3a35
movq (%r12), %rsi
incq %rsi
callq 0x21e0
addq $-0x20, %r12
addq $0x20, %r14
jne 0x3a1f
movq $-0x220, %r14           # imm = 0xFDE0
leaq -0xc8(%rbp), %r15
leaq -0x88(%rbp), %r12
movq -0x10(%r13), %rdi
cmpq %rdi, %r13
je 0x3a69
movq (%r13), %rsi
incq %rsi
callq 0x21e0
addq $-0x20, %r13
addq $0x20, %r14
jne 0x3a54
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x3a95
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x21e0
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x3aae
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x21e0
movq -0x98(%rbp), %rdi
cmpq %r12, %rdi
je 0x3ac9
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x21e0
leaq -0x70(%rbp), %rdi
callq 0x2a96
movq -0xd8(%rbp), %rdi
cmpq %r15, %rdi
je 0x3aed
movq -0xc8(%rbp), %rsi
incq %rsi
callq 0x21e0
movl %ebx, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x2e0(%rbp), %rsi
movl $0x2e, %edi
callq 0x2c8b
movl -0x30(%rbp), %esi
leaq -0x2e0(%rbp), %rdx
movq %rbx, %rdi
callq 0x4624
movl -0x30(%rbp), %esi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x4840
jmp 0x3a16
movq 0x4493(%rip), %rdi      # 0x7fd0
leaq 0x1668(%rip), %rsi      # 0x51ac
movl $0x14, %edx
callq 0x2210
movq 0x447b(%rip), %rdi      # 0x7fd0
movl %r14d, %esi
callq 0x2340
movq %rax, %rdi
callq 0x20c0
jmp 0x3a16
movq 0x446f(%rip), %rdi      # 0x7fe0
movl $0x7fff, %esi           # imm = 0x7FFF
movl $0xa, %edx
callq 0x2120
jmp 0x3a16
jmp 0x3d00
jmp 0x3d00
jmp 0x3b93
jmp 0x3b93
movq %rax, %rbx
movq 0x442b(%rip), %rsi      # 0x7fc8
leaq -0x2e0(%rbp), %rdi
callq 0x22a0
leaq -0x268(%rbp), %rdi
callq 0x2070
jmp 0x3d03
jmp 0x3d00
jmp 0x3d00
jmp 0x3d00
jmp 0x3d00
jmp 0x3d00
jmp 0x3be6
jmp 0x3be6
jmp 0x3d00
jmp 0x3d00
jmp 0x3d00
movq %rax, %rbx
leaq -0x2e0(%rbp), %rdi
callq 0x2050
jmp 0x3d03
movq %rax, %rbx
jmp 0x3d5b
jmp 0x3ce4
movq %rax, %rbx
leaq -0x2e0(%rbp), %rdi
callq 0x2a96
jmp 0x3d03
jmp 0x3c39
jmp 0x3c39
jmp 0x3c39
jmp 0x3c39
jmp 0x3c39
jmp 0x3c39
jmp 0x3c39
jmp 0x3c39
jmp 0x3c39
jmp 0x3c39
jmp 0x3c39
jmp 0x3c39
jmp 0x3c39
jmp 0x3c39
jmp 0x3c39
movq %rax, %rbx
cmpq %r15, %r14
je 0x3d2f
addq $-0x10, %r15
leaq -0x500(%rbp), %r14
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x3c64
movq (%r15), %rsi
incq %rsi
callq 0x21e0
leaq -0x20(%r15), %rax
addq $-0x10, %r15
cmpq %r14, %r15
movq %rax, %r15
jne 0x3c50
jmp 0x3d2f
movq %rax, %rbx
movq %r14, %r15
jmp 0x3c3c
jmp 0x3c9f
jmp 0x3c9f
jmp 0x3c9f
jmp 0x3c9f
jmp 0x3c9f
jmp 0x3c9f
jmp 0x3c9f
jmp 0x3c9f
jmp 0x3c9f
jmp 0x3c9f
jmp 0x3c9f
jmp 0x3c9f
jmp 0x3c9f
jmp 0x3c9f
jmp 0x3c9f
movq %rax, %rbx
cmpq %r15, %r14
je 0x3d5b
addq $-0x10, %r15
leaq -0x720(%rbp), %r14
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x3cca
movq (%r15), %rsi
incq %rsi
callq 0x21e0
leaq -0x20(%r15), %rax
addq $-0x10, %r15
cmpq %r14, %r15
movq %rax, %r15
jne 0x3cb6
jmp 0x3d5b
movq %rax, %rbx
movq %r14, %r15
jmp 0x3ca2
movq %rax, %rbx
jmp 0x3d7d
movq %rax, %rbx
jmp 0x3d96
jmp 0x3cf6
movq %rax, %rbx
jmp 0x3db8
jmp 0x3d00
movq %rax, %rbx
xorl %r14d, %r14d
movq -0x300(%rbp,%r14), %rdi
leaq (%r12,%r14), %rax
cmpq %rdi, %rax
je 0x3d22
movq (%rax), %rsi
incq %rsi
callq 0x21e0
addq $-0x20, %r14
cmpq $-0x220, %r14           # imm = 0xFDE0
jne 0x3d06
xorl %r14d, %r14d
movq -0x520(%rbp,%r14), %rdi
leaq (%r14,%r13), %rax
cmpq %rdi, %rax
je 0x3d4e
movq (%rax), %rsi
incq %rsi
callq 0x21e0
addq $-0x20, %r14
cmpq $-0x220, %r14           # imm = 0xFDE0
jne 0x3d32
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x3d7d
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x21e0
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x3d96
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x21e0
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x3db8
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x21e0
leaq -0x70(%rbp), %rdi
callq 0x2a96
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x3de3
movq -0xc8(%rbp), %rsi
incq %rsi
callq 0x21e0
movq %rbx, %rdi
callq 0x2360
movq %rax, %rbx
jmp 0x3dc1