// File: /workspace/github_cpp_makefile_star2_O3/danomatika[P]miditester/src/main.cpp
// Function: main
int main(int argc, char *argv[]) {
    RtMidiIn *midiin = new RtMidiIn();
    RtMidiOut *midiout = new RtMidiOut();
    midiin->setErrorCallback(midiError);
    midiout->setErrorCallback(midiError);

    // parse commandline
    std::string tests = "all";
    int port = 0;
    int channel = 1;
    int speed = -1;
    bool hex = true;
    bool name = false;
    bool list = false;
    std::string option = "";
    for(int i = 1; i < argc; ++i) {
        std::string arg = argv[i];

        // previous option which expects a value
        if(option != "") {
            if(arg[0] == '-') {
                std::cout << option << " expects a value" << std::endl;
                return 1;
            }
            if(!isnumeric(arg)) {
                std::cout << option << " expects a positive integer, got "
                          << arg << std::endl;
                return 1;
            }
            if(option == "-p" || option == "--port") {
                port = std::atoi(argv[i]);
            }
            else if(option == "-c" || option == "--channel") {
                channel = std::atoi(argv[i]);
                if(channel < 1 || channel > 16) {
                    std::cout << option << " option must be 1-16" << std::endl;
                    return 1;
                }
            }
            else if(option == "-s" || option == "--speed") {
                speed = std::atoi(argv[i]);
            }
            else {
                std::cout << "unknown option: " << option << std::endl;
                return 1;
            }
            option = "";
            continue;
        }

        // current argument
        if(arg[0] == '-') {
            // option
            if(arg == "-h" || arg == "--help") {
                std::cout << HELP << std::endl;
                return 0;
            }
            else if(arg == "-d" || arg == "--decimal") {
                hex = false;
            }
            else if(arg == "-n" || arg == "--name") {
                name = true;
            }
            else if(arg == "-l" || arg == "--list") {
                list = true;
                break;
            }
            else {
                option = arg;
            }
        }
        else {
            // argument
            tests = arg;
        }      
    }

    // list devices and exit?
    if(list) {
        if(midiin->getPortCount() > 0) {
            std::cout << "input ports:" << std::endl;
            for(int i = 0; i < midiin->getPortCount(); ++i) {
              std::cout << "  " << i << ": "
                        << midiin->getPortName(i) << std::endl;
            }
        }
        else {
            std::cout << "no input ports" << std::endl;
        }
        if(midiin->getPortCount() > 0) {
            std::cout << "output ports:" << std::endl;
            for(int i = 0; i < midiin->getPortCount(); ++i) {
              std::cout << "  " << i << ": "
                        << midiout->getPortName(i) << std::endl;
            }
        }
        else {
            std::cout << "no output ports" << std::endl;
        }
        return 0;
    }

    channel--; // decrement from human-readable index

    // set signal handling
    signal(SIGTERM, signalExit); // terminate
    signal(SIGQUIT, signalExit); // quit
    signal(SIGINT,  signalExit); // interrupt

    if(tests == "input") {
        if(speed < 0) speed = 40;

        std::cout << "running tests: " << tests << std::endl
          << "port: " << port << std::endl
          << "speed: " << speed << " ms" << std::endl;

        // check if there is anything to receive from
        unsigned int numPorts = midiin->getPortCount();
        if(numPorts == 0) {
            std::cout << "no input ports available" << std::endl;
            delete midiin;
            delete midiout;
            return 0;
        }

        // try opening given port
        midiin->openPort(port);
        std::cout << "opened " << midiin->getPortName(port) << std::endl;

        // disable message filtering
        midiin->ignoreTypes(false, false, false);

        // listen for new messages until loop is stopped
        std::cout << "input test" << std::endl;
        std::cout << "started listening" << std::endl;
        std::chrono::milliseconds sleepMS(20);
        std::vector<unsigned char> message;
        while(run) {
            if(midiin->getMessage(&message)) {
                printMessage(message, hex, name);
                message.clear();
            }
            std::this_thread::sleep_for(sleepMS);
        }
        std::cout << "stopped listening" << std::endl;

        // done
        midiin->closePort();
    }
    else {
        TestQueue queue;
        if(speed < 0) speed = 500;

        std::cout << "running tests: " << tests << std::endl
          << "port: " << port << std::endl
          << "channel: " << channel << std::endl
          << "speed: " << speed << " ms" << std::endl;

        // check if there is anything to send to
        unsigned int numPorts = midiout->getPortCount();
        if(numPorts == 0) {
            std::cout << "no output ports available" << std::endl;
            delete midiin;
            delete midiout;
            return 0;
        }

        // try opening given port
        midiout->openPort(port);
        std::cout << "opened " << midiout->getPortName(port) << std::endl;
        
        // prepare message queue
        bool allTests = (tests == "all");
        bool addedTest = false;
        if(allTests || tests == "channel")  channelMessages(queue, channel), addedTest = true;
        if(allTests || tests == "system")   systemMessages(queue, channel), addedTest = true;
        if(allTests || tests == "realtime") realtimeMessages(queue, channel), addedTest = true;
        if(allTests || tests == "running")  runningStatus(queue, channel), addedTest = true;
        if(allTests || tests == "sysex")    sysex(queue, channel), addedTest = true;
        if(allTests || tests == "timecode") timecode(queue), addedTest = true;
        if(!addedTest) {
            std::cout << "unknown test: " << tests << std::endl;
            return 1;
        }

        // send messages
        std::chrono::milliseconds sleepMS(speed);
        for(auto &test : queue) {
            if(!run) {break;}
            std::cout << test.name << " test" << std::endl;
            for(auto &message : test.messages) {
                if(!run) {break;}
                std::cout << "  sending ";
                printMessage(message, hex, name);
                midiout->sendMessage(&message);
                std::this_thread::sleep_for(sleepMS);
            }
        }

        // done
        midiout->closePort();
    }

    // cleanup
    delete midiin;
    delete midiout;
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rsi, %r12
movl %edi, %ebx
movl $0x10, %edi
callq 0x3190
movq %rax, %r15
leaq 0x128(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x4afc(%rip), %rsi      # 0x809b
leaq 0x4b08(%rip), %rdx      # 0x80ae
leaq 0x118(%rsp), %rdi
movq %rax, (%rsp)
callq 0x5e78
leaq 0x118(%rsp), %rdx
movq %r15, %rdi
xorl %esi, %esi
movl $0x64, %ecx
callq 0x69ee
movq 0x118(%rsp), %rdi
cmpq %r14, %rdi
je 0x35eb
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x31a0
movl $0x10, %edi
callq 0x3190
movq %rax, %r15
leaq 0x108(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x4aa4(%rip), %rsi      # 0x80af
leaq 0x4ab1(%rip), %rdx      # 0x80c3
leaq 0xf8(%rsp), %rdi
movq %rax, 0x30(%rsp)
callq 0x5e78
leaq 0xf8(%rsp), %rdx
movq %r15, %rdi
xorl %esi, %esi
callq 0x6d68
movq 0xf8(%rsp), %rdi
cmpq %r14, %rdi
je 0x3653
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x31a0
movq (%rsp), %rdi
movq (%rdi), %rax
leaq 0x148b(%rip), %r14      # 0x4aec
movq %r14, %rsi
xorl %edx, %edx
callq *0x30(%rax)
movq 0x30(%rsp), %rdi
movq (%rdi), %rax
movq %r14, %rsi
xorl %edx, %edx
callq *0x30(%rax)
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4a3b(%rip), %rsi      # 0x80c4
leaq 0x4a37(%rip), %rdx      # 0x80c7
leaq 0x48(%rsp), %rdi
callq 0x5e78
leaq 0xa0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x508d(%rip), %rdx      # 0x873a
leaq 0x90(%rsp), %rdi
movq %rdx, %rsi
callq 0x5e78
cmpl $0x2, %ebx
jl 0x3b80
movl %ebx, %r14d
movl $0xffffffff, 0x6c(%rsp) # imm = 0xFFFFFFFF
movb $0x1, %al
movl %eax, 0x40(%rsp)
movl $0x1, 0x88(%rsp)
xorl %r15d, %r15d
movl $0x1, %ebp
leaq 0x10(%rsp), %r13
movl $0x0, 0xc(%rsp)
movq $0x0, 0x38(%rsp)
movq $0x0, 0xb0(%rsp)
movq (%r12,%rbp,8), %rsi
movq %r13, %rdi
leaq 0x70(%rsp), %rdx
callq 0x5ce2
leaq 0x90(%rsp), %rbx
movq %rbx, %rdi
leaq 0x500b(%rip), %rsi      # 0x873a
callq 0x3070
movq 0x10(%rsp), %rcx
movb (%rcx), %cl
testl %eax, %eax
je 0x3794
cmpb $0x2d, %cl
jne 0x3878
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
movq 0x8871(%rip), %rdi      # 0xbfd0
callq 0x31b0
movq %rax, %rbx
movl $0x10, %edx
movq %rax, %rdi
leaq 0x4952(%rip), %rsi      # 0x80c8
callq 0x31b0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3170
jmp 0x38f4
leaq 0x48(%rsp), %rdi
cmpb $0x2d, %cl
jne 0x3869
movq %r13, %rdi
leaq 0x4997(%rip), %rsi      # 0x8143
callq 0x3070
testl %eax, %eax
je 0x3a26
movq %r13, %rdi
leaq 0x4983(%rip), %rsi      # 0x8146
callq 0x3070
testl %eax, %eax
je 0x3a26
movq %r13, %rdi
leaq 0x4973(%rip), %rsi      # 0x814d
callq 0x3070
testl %eax, %eax
je 0x3b37
movq %r13, %rdi
leaq 0x495f(%rip), %rsi      # 0x8150
callq 0x3070
xorl %ebx, %ebx
testl %eax, %eax
je 0x3b55
movq %r13, %rdi
leaq 0x4950(%rip), %rsi      # 0x815a
callq 0x3070
testl %eax, %eax
je 0x3b46
movq %r13, %rdi
leaq 0x493c(%rip), %rsi      # 0x815d
callq 0x3070
testl %eax, %eax
je 0x3b46
movq %r13, %rdi
leaq 0x492c(%rip), %rsi      # 0x8164
callq 0x3070
movl $0x2, %ebx
testl %eax, %eax
je 0x3b74
movq %r13, %rdi
leaq 0x4913(%rip), %rsi      # 0x8167
callq 0x3070
leaq 0x90(%rsp), %rdi
testl %eax, %eax
je 0x3b74
xorl %ebx, %ebx
movq %r13, %rsi
callq 0x30f0
jmp 0x3912
movl $0xa, %ecx
movq %r13, %rdi
leaq 0x4809(%rip), %rsi      # 0x8090
xorl %edx, %edx
callq 0x3250
cmpq $-0x1, %rax
je 0x394c
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
movq 0x8721(%rip), %rdi      # 0xbfd0
callq 0x31b0
movq %rax, %rbx
movl $0x21, %edx
movq %rax, %rdi
leaq 0x4813(%rip), %rsi      # 0x80d9
callq 0x31b0
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %rbx, %rdi
callq 0x31b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3170
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movl $0x1, %ebx
movq %rax, %rdi
callq 0x3110
movl $0x1, %r15d
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x392e
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x31a0
testl %ebx, %ebx
je 0x393b
cmpl $0x4, %ebx
jne 0x3b96
incq %rbp
cmpq %rbp, %r14
jne 0x370c
jmp 0x3b9f
movq %rbx, %rdi
leaq 0x47a5(%rip), %rsi      # 0x80fb
callq 0x3070
testl %eax, %eax
je 0x3a7d
movq %rbx, %rdi
leaq 0x4791(%rip), %rsi      # 0x80fe
callq 0x3070
testl %eax, %eax
je 0x3a7d
movq %rbx, %rdi
leaq 0x4781(%rip), %rsi      # 0x8105
callq 0x3070
testl %eax, %eax
je 0x3ab5
movq %rbx, %rdi
leaq 0x476d(%rip), %rsi      # 0x8108
callq 0x3070
testl %eax, %eax
je 0x3ab5
movq %rbx, %rdi
leaq 0x4775(%rip), %rsi      # 0x8127
callq 0x3070
testl %eax, %eax
je 0x3b62
movq %rbx, %rdi
leaq 0x4761(%rip), %rsi      # 0x812a
callq 0x3070
testl %eax, %eax
je 0x3b62
movl $0x10, %edx
movq 0x85ee(%rip), %rdi      # 0xbfd0
leaq 0x4749(%rip), %rsi      # 0x8132
callq 0x31b0
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
movq 0x85cb(%rip), %rdi      # 0xbfd0
callq 0x31b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3170
jmp 0x38f4
movl $0x31a, %edx            # imm = 0x31A
movq 0x859e(%rip), %rdi      # 0xbfd0
leaq 0x492f(%rip), %rsi      # 0x8368
callq 0x31b0
movq 0x858b(%rip), %rcx      # 0xbfd0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x3170
movsbl %al, %esi
movq 0x856d(%rip), %rdi      # 0xbfd0
callq 0x3040
movq %rax, %rdi
callq 0x3110
xorl %r15d, %r15d
movl $0x1, %ebx
jmp 0x3912
movq (%r12,%rbp,8), %rdi
callq 0x3220
movl %eax, 0xc(%rsp)
movl $0x4, %ebx
movq 0x98(%rsp), %rdx
leaq 0x90(%rsp), %rdi
xorl %esi, %esi
leaq 0x4c92(%rip), %rcx      # 0x873a
xorl %r8d, %r8d
callq 0x3210
jmp 0x3912
movq (%r12,%rbp,8), %rdi
callq 0x3220
movl %eax, 0x88(%rsp)
addl $-0x11, %eax
cmpl $-0x11, %eax
ja 0x3a8a
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
movq 0x84ec(%rip), %rdi      # 0xbfd0
callq 0x31b0
movq %rax, %rbx
movl $0x14, %edx
movq %rax, %rdi
leaq 0x4617(%rip), %rsi      # 0x8112
callq 0x31b0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3170
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movl $0x1, %ebx
movq %rax, %rdi
callq 0x3110
movl $0x1, %r15d
jmp 0x3912
movl $0x0, 0x40(%rsp)
xorl %ebx, %ebx
jmp 0x3912
movb $0x1, %al
movq %rax, 0xb0(%rsp)
jmp 0x3912
movl $0x0, 0x40(%rsp)
jmp 0x3912
movq (%r12,%rbp,8), %rdi
callq 0x3220
movl %eax, 0x6c(%rsp)
jmp 0x3a8a
movb $0x1, %al
movq %rax, 0x38(%rsp)
jmp 0x3912
xorl %r12d, %r12d
movb $0x1, %r15b
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
xorl %r14d, %r14d
xorl %ebp, %ebp
jmp 0x3cec
cmpl $0x2, %ebx
jne 0x472c
testb $0x1, 0x38(%rsp)
je 0x3ccb
movq (%rsp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
testl %eax, %eax
je 0x4782
movq 0x840d(%rip), %rbx      # 0xbfd0
leaq 0x45a4(%rip), %rsi      # 0x816e
movl $0xc, %edx
movq %rbx, %rdi
callq 0x31b0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x3170
movsbl %al, %esi
movq 0x83db(%rip), %rdi      # 0xbfd0
callq 0x3040
movq %rax, %rdi
callq 0x3110
xorl %ebx, %ebx
movq 0x83c5(%rip), %r14      # 0xbfd0
leaq 0x4569(%rip), %r15      # 0x817b
leaq 0x45b4(%rip), %r12      # 0x81cd
leaq 0x10(%rsp), %r13
movq (%rsp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
cmpl %eax, %ebx
jae 0x47c8
movl $0x2, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x31b0
movq %r14, %rdi
movl %ebx, %esi
callq 0x3270
movq %rax, %rbp
movl $0x2, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x31b0
movq (%rsp), %rsi
movq (%rsi), %rax
movq %r13, %rdi
movl %ebx, %edx
callq *0x18(%rax)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %rbp, %rdi
callq 0x31b0
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x3170
movsbl %al, %esi
movq %rbp, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3110
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x3cc4
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x31a0
incl %ebx
jmp 0x3c1e
movl 0x88(%rsp), %r14d
decl %r14d
movl 0x40(%rsp), %r15d
movq 0xb0(%rsp), %r12
movl 0xc(%rsp), %ebp
movl 0x6c(%rsp), %r13d
leaq 0xe2d(%rip), %rbx       # 0x4b20
movl $0xf, %edi
movq %rbx, %rsi
callq 0x31d0
movl $0x3, %edi
movq %rbx, %rsi
callq 0x31d0
movl $0x2, %edi
movq %rbx, %rsi
callq 0x31d0
leaq 0x448a(%rip), %rsi      # 0x81ab
leaq 0x48(%rsp), %rdi
callq 0x3070
testl %eax, %eax
je 0x3fd4
xorpd %xmm0, %xmm0
movapd %xmm0, 0x70(%rsp)
movq $0x0, 0x80(%rsp)
testl %r13d, %r13d
movl $0x1f4, %eax            # imm = 0x1F4
cmovnsl %r13d, %eax
movl %eax, 0xc(%rsp)
movq 0x8270(%rip), %rdi      # 0xbfd0
leaq 0x444a(%rip), %rsi      # 0x81b1
movl $0xf, %edx
callq 0x31b0
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq 0x824e(%rip), %rdi      # 0xbfd0
callq 0x31b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3170
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3110
movq %rax, %rbx
leaq 0x4406(%rip), %rsi      # 0x81c1
movl $0x6, %edx
movq %rax, %rdi
callq 0x31b0
movq %rbx, %rdi
movl %ebp, %esi
callq 0x3270
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3170
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3110
movq %rax, %rbx
leaq 0x442b(%rip), %rsi      # 0x8231
movl $0x9, %edx
movq %rax, %rdi
callq 0x31b0
movq %rbx, %rdi
movl %r14d, %esi
callq 0x3270
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3170
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3110
movq %rax, %rbx
leaq 0x4376(%rip), %rsi      # 0x81c8
movl $0x7, %edx
movq %rax, %rdi
callq 0x31b0
movq %rbx, %rdi
movl 0xc(%rsp), %esi
callq 0x3270
movq %rax, %rbx
leaq 0x435b(%rip), %rsi      # 0x81d0
movl $0x3, %edx
movq %rax, %rdi
callq 0x31b0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3170
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3110
movq 0x30(%rsp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
testl %eax, %eax
je 0x44af
leaq 0xc8(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x4386(%rip), %rsi      # 0x8255
leaq 0x438c(%rip), %rdx      # 0x8262
leaq 0xb8(%rsp), %rdi
callq 0x5e78
movq 0x30(%rsp), %rdi
movq (%rdi), %rax
leaq 0xb8(%rsp), %rdx
movl %ebp, %esi
callq *(%rax)
movq 0xb8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x3f14
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x31a0
movq 0x80b5(%rip), %rdi      # 0xbfd0
leaq 0x42d8(%rip), %rsi      # 0x81fa
movl $0x7, %edx
callq 0x31b0
movq 0x30(%rsp), %rsi
movq (%rsi), %rax
leaq 0x10(%rsp), %rdi
movl %ebp, %edx
callq *0x18(%rax)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x8081(%rip), %rdi      # 0xbfd0
callq 0x31b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3170
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3110
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3f99
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x31a0
leaq 0x4124(%rip), %rsi      # 0x80c4
leaq 0x48(%rsp), %rdi
callq 0x3070
movl %eax, %ebx
testl %eax, %eax
je 0x4387
leaq 0x414f(%rip), %rsi      # 0x810a
leaq 0x48(%rsp), %rdi
callq 0x3070
testl %eax, %eax
je 0x4387
xorl %ebp, %ebp
jmp 0x439b
testl %r13d, %r13d
movl $0x28, %ebx
cmovnsl %r13d, %ebx
movq 0x7fe9(%rip), %rdi      # 0xbfd0
leaq 0x41c3(%rip), %rsi      # 0x81b1
movl $0xf, %edx
callq 0x31b0
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq 0x7fc7(%rip), %rdi      # 0xbfd0
callq 0x31b0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3170
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3110
movq %rax, %r14
leaq 0x417f(%rip), %rsi      # 0x81c1
movl $0x6, %edx
movq %rax, %rdi
callq 0x31b0
movq %r14, %rdi
movl %ebp, %esi
callq 0x3270
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3170
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3110
movq %rax, %r14
leaq 0x413b(%rip), %rsi      # 0x81c8
movl $0x7, %edx
movq %rax, %rdi
callq 0x31b0
movq %r14, %rdi
movl %ebx, %esi
callq 0x3270
movq %rax, %rbx
leaq 0x4122(%rip), %rsi      # 0x81d0
movl $0x3, %edx
movq %rax, %rdi
callq 0x31b0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3170
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3110
movq (%rsp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
testl %eax, %eax
je 0x46ce
leaq 0xe8(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x40e6(%rip), %rsi      # 0x81ed
leaq 0x40eb(%rip), %rdx      # 0x81f9
leaq 0xd8(%rsp), %rdi
callq 0x5e78
movq (%rsp), %rdi
movq (%rdi), %rax
leaq 0xd8(%rsp), %rdx
movl %ebp, %esi
callq *(%rax)
movq 0xd8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x414b
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x31a0
movq 0x7e7e(%rip), %rdi      # 0xbfd0
leaq 0x40a1(%rip), %rsi      # 0x81fa
movl $0x7, %edx
callq 0x31b0
movq (%rsp), %rsi
movq (%rsi), %rax
leaq 0x10(%rsp), %rdi
movl %ebp, %edx
callq *0x18(%rax)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x7e4b(%rip), %rdi      # 0xbfd0
callq 0x31b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3170
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3110
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x41cf
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x31a0
movq (%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq *0x48(%rax)
movq 0x7de6(%rip), %rbx      # 0xbfd0
leaq 0x4011(%rip), %rsi      # 0x8202
movl $0xa, %edx
movq %rbx, %rdi
callq 0x31b0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x3170
movsbl %al, %esi
movq 0x7db4(%rip), %rdi      # 0xbfd0
callq 0x3040
movq %rax, %rdi
callq 0x3110
movq 0x7da0(%rip), %rbx      # 0xbfd0
leaq 0x3fd6(%rip), %rsi      # 0x820d
movl $0x11, %edx
movq %rbx, %rdi
callq 0x31b0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x3170
movsbl %al, %esi
movq 0x7d6e(%rip), %rdi      # 0xbfd0
callq 0x3040
movq %rax, %rdi
callq 0x3110
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
cmpl $0x0, 0x7ee7(%rip)      # 0xc170
je 0x4317
leaq 0x10(%rsp), %rbx
movzbl %r15b, %ebp
andl $0x1, %ebp
movzbl %r12b, %r14d
andl $0x1, %r14d
leaq 0x70(%rsp), %r15
movq (%rsp), %rax
movq 0x8(%rax), %rdi
movq %rbx, %rsi
callq 0x7434
ucomisd 0x3d48(%rip), %xmm0     # 0x8008
jne 0x42c4
jnp 0x42e2
movq %rbx, %rdi
movl %ebp, %esi
movl %r14d, %edx
callq 0x4b2b
movq 0x10(%rsp), %rax
cmpq %rax, 0x18(%rsp)
je 0x42e2
movq %rax, 0x18(%rsp)
movq $0x0, 0x70(%rsp)
movq $0x1312d00, 0x78(%rsp)  # imm = 0x1312D00
movq %r15, %rdi
movq %r15, %rsi
callq 0x3080
cmpl $-0x1, %eax
jne 0x430e
callq 0x3050
cmpl $0x4, (%rax)
je 0x42f4
cmpl $0x0, 0x7e5b(%rip)      # 0xc170
jne 0x42a8
movq 0x7cb2(%rip), %rbx      # 0xbfd0
leaq 0x3efa(%rip), %rsi      # 0x821f
movl $0x11, %edx
movq %rbx, %rdi
callq 0x31b0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x3170
movsbl %al, %esi
movq 0x7c80(%rip), %rdi      # 0xbfd0
callq 0x3040
movq %rax, %rdi
callq 0x3110
movq (%rsp), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x4714
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x31a0
jmp 0x4714
leaq 0x70(%rsp), %rdi
movl %r14d, %esi
callq 0x4c90
movb $0x1, %bpl
testl %ebx, %ebx
je 0x43b0
leaq 0x3ec1(%rip), %rsi      # 0x8263
leaq 0x48(%rsp), %rdi
callq 0x3070
testl %eax, %eax
jne 0x43c1
leaq 0x70(%rsp), %rdi
callq 0x4eea
movb $0x1, %bpl
testl %ebx, %ebx
je 0x43d6
leaq 0x3ea2(%rip), %rsi      # 0x826a
leaq 0x48(%rsp), %rdi
callq 0x3070
testl %eax, %eax
jne 0x43e7
leaq 0x70(%rsp), %rdi
callq 0x51e0
movb $0x1, %bpl
testl %ebx, %ebx
je 0x43fc
leaq 0x3e85(%rip), %rsi      # 0x8273
leaq 0x48(%rsp), %rdi
callq 0x3070
testl %eax, %eax
jne 0x4414
leaq 0x70(%rsp), %rdi
movl %r14d, %esi
callq 0x53cf
movb $0x1, %bpl
testl %ebx, %ebx
je 0x451c
leaq 0x3e60(%rip), %rsi      # 0x827b
leaq 0x48(%rsp), %rdi
callq 0x3070
testl %eax, %eax
je 0x451c
leaq 0x3e4d(%rip), %rsi      # 0x8281
leaq 0x48(%rsp), %rdi
callq 0x3070
testl %eax, %eax
je 0x4542
testb %bpl, %bpl
jne 0x454c
movq 0x7b7a(%rip), %rdi      # 0xbfd0
leaq 0x3e2d(%rip), %rsi      # 0x828a
movl $0xe, %edx
callq 0x31b0
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq 0x7b58(%rip), %rdi      # 0xbfd0
callq 0x31b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3170
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movl $0x1, %r15d
movq %rax, %rdi
callq 0x3110
jmp 0x450d
movq 0x7b1a(%rip), %rbx      # 0xbfd0
leaq 0x3d7e(%rip), %rsi      # 0x823b
movl $0x19, %edx
movq %rbx, %rdi
callq 0x31b0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x3170
movsbl %al, %esi
movq 0x7ae8(%rip), %rdi      # 0xbfd0
callq 0x3040
movq %rax, %rdi
callq 0x3110
movq (%rsp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
movq 0x30(%rsp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
xorl %r15d, %r15d
leaq 0x70(%rsp), %rdi
callq 0x5d20
jmp 0x472c
leaq 0x70(%rsp), %rdi
movl %r14d, %esi
callq 0x570f
testl %ebx, %ebx
je 0x4542
leaq 0x3d4d(%rip), %rsi      # 0x8281
leaq 0x48(%rsp), %rdi
callq 0x3070
testl %eax, %eax
jne 0x454c
leaq 0x70(%rsp), %rdi
callq 0x587e
movq 0x70(%rsp), %rbp
movq 0x78(%rsp), %rax
movq %rax, 0x88(%rsp)
cmpq %rax, %rbp
je 0x46b7
cmpl $0x0, 0x7c02(%rip)      # 0xc170
je 0x46b7
movl 0xc(%rsp), %eax
imulq $0x10624dd3, %rax, %rcx # imm = 0x10624DD3
shrq $0x26, %rcx
movq %rcx, 0x40(%rsp)
imulq $-0x3e8, %rcx, %rcx     # imm = 0xFC18
addq %rax, %rcx
imulq $0xf4240, %rcx, %rax    # imm = 0xF4240
movq %rax, 0x38(%rsp)
movzbl %r15b, %r13d
andl $0x1, %r13d
movzbl %r12b, %ebx
andl $0x1, %ebx
leaq 0x10(%rsp), %r14
movq (%rbp), %rsi
movq 0x8(%rbp), %rdx
movq 0x7a0f(%rip), %rdi      # 0xbfd0
callq 0x31b0
movq %rax, %r12
movl $0x5, %edx
movq %rax, %rdi
leaq 0x3c2f(%rip), %rsi      # 0x8207
callq 0x31b0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3170
movsbl %al, %esi
movq %r12, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3110
movq 0x20(%rbp), %r12
movq 0x28(%rbp), %r15
cmpq %r15, %r12
sete %cl
movl 0x7b57(%rip), %eax      # 0xc170
testl %eax, %eax
sete %dl
orb %cl, %dl
jne 0x46a1
movl $0xa, %edx
movq 0x79a2(%rip), %rdi      # 0xbfd0
leaq 0x3c64(%rip), %rsi      # 0x8299
callq 0x31b0
movq %r12, %rdi
movl %r13d, %esi
movl %ebx, %edx
callq 0x4b2b
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
movq %r12, %rsi
callq *0x48(%rax)
cmpl $0x0, 0xc(%rsp)
je 0x468e
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x18(%rsp)
movq %r14, %rdi
movq %r14, %rsi
callq 0x3080
cmpl $-0x1, %eax
jne 0x468e
callq 0x3050
cmpl $0x4, (%rax)
je 0x4674
addq $0x18, %r12
movl 0x7ad8(%rip), %eax      # 0xc170
cmpq %r15, %r12
je 0x46a1
testl %eax, %eax
jne 0x4622
addq $0x38, %rbp
cmpq 0x88(%rsp), %rbp
je 0x46b7
testl %eax, %eax
jne 0x45b2
movq 0x30(%rsp), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
leaq 0x70(%rsp), %rdi
callq 0x5d20
jmp 0x4714
movq 0x78fb(%rip), %rbx      # 0xbfd0
leaq 0x3af8(%rip), %rsi      # 0x81d4
movl $0x18, %edx
movq %rbx, %rdi
callq 0x31b0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x3170
movsbl %al, %esi
movq 0x78c9(%rip), %rdi      # 0xbfd0
callq 0x3040
movq %rax, %rdi
callq 0x3110
movq (%rsp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
movq 0x30(%rsp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
xorl %r15d, %r15d
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x4751
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x31a0
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x476d
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x31a0
movl %r15d, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x7847(%rip), %rbx      # 0xbfd0
leaq 0x39ee(%rip), %rsi      # 0x817e
movl $0xe, %edx
movq %rbx, %rdi
callq 0x31b0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x3170
movsbl %al, %esi
movq 0x7815(%rip), %rdi      # 0xbfd0
callq 0x3040
movq %rax, %rdi
callq 0x3110
movq (%rsp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
testl %eax, %eax
je 0x48ea
movq 0x77ef(%rip), %rbx      # 0xbfd0
leaq 0x39a5(%rip), %rsi      # 0x818d
movl $0xd, %edx
movq %rbx, %rdi
callq 0x31b0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x3170
movsbl %al, %esi
movq 0x77bd(%rip), %rdi      # 0xbfd0
callq 0x3040
movq %rax, %rdi
callq 0x3110
xorl %ebx, %ebx
movq 0x77a7(%rip), %r14      # 0xbfd0
leaq 0x394b(%rip), %r15      # 0x817b
leaq 0x3996(%rip), %r12      # 0x81cd
leaq 0x10(%rsp), %r13
movq (%rsp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
cmpl %eax, %ebx
jae 0x4729
movl $0x2, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x31b0
movq %r14, %rdi
movl %ebx, %esi
callq 0x3270
movq %rax, %rbp
movl $0x2, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x31b0
movq 0x30(%rsp), %rsi
movq (%rsi), %rax
movq %r13, %rdi
movl %ebx, %edx
callq *0x18(%rax)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %rbp, %rdi
callq 0x31b0
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x3170
movsbl %al, %esi
movq %rbp, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3110
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x48e3
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x31a0
incl %ebx
jmp 0x483c
movq 0x76df(%rip), %rbx      # 0xbfd0
leaq 0x38a3(%rip), %rsi      # 0x819b
movl $0xf, %edx
movq %rbx, %rdi
callq 0x31b0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x3170
movsbl %al, %esi
movq 0x76ad(%rip), %rdi      # 0xbfd0
callq 0x3040
movq %rax, %rdi
callq 0x3110
jmp 0x4729
jmp 0x4a55
movq %rax, %r15
movq 0xd8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x4aa3
movq 0xe8(%rsp), %rsi
jmp 0x4a73
jmp 0x4a55
jmp 0x4a96
jmp 0x4a96
movq %rax, %r15
movq 0xb8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x4a99
movq 0xc8(%rsp), %rsi
jmp 0x4a35
jmp 0x4a96
movq %rax, %r15
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
jmp 0x4a69
jmp 0x4a78
movq %rax, %r15
jmp 0x4ac8
movq %rax, %r15
jmp 0x4ae4
movq %rax, %r15
movq 0xf8(%rsp), %rdi
cmpq %r14, %rdi
je 0x49db
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x31a0
jmp 0x49db
movq %rax, %r15
movl $0x10, %esi
movq 0x30(%rsp), %rdi
jmp 0x4adf
movq %rax, %r15
movq 0x118(%rsp), %rdi
cmpq %r14, %rdi
je 0x4a0f
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x31a0
jmp 0x4a0f
movq %rax, %r15
movl $0x10, %esi
movq (%rsp), %rdi
jmp 0x4adf
jmp 0x4a96
movq %rax, %r15
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4a99
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x31a0
jmp 0x4a99
jmp 0x4a96
jmp 0x4a55
jmp 0x4a55
jmp 0x4a55
jmp 0x4a78
jmp 0x4a55
jmp 0x4a55
jmp 0x4a96
jmp 0x4a5c
jmp 0x4a5c
jmp 0x4a55
movq %rax, %r15
jmp 0x4aa3
jmp 0x4a96
movq %rax, %r15
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x4aa3
movq 0x20(%rsp), %rsi
incq %rsi
jmp 0x4a8d
movq %rax, %r15
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x4aa3
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x31a0
jmp 0x4aa3
jmp 0x4a96
movq %rax, %r15
leaq 0x70(%rsp), %rdi
callq 0x5d20
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x4ac8
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x31a0
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x4ae4
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x31a0
movq %r15, %rdi
callq 0x3280