// File: /workspace/github_cpp_makefile_star2_O1/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 $0x148, %rsp            # imm = 0x148
movq %rsi, %r12
movl %edi, %ebx
movl $0x10, %edi
callq 0x3190
movq %rax, %r15
leaq 0x138(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x4acc(%rip), %rsi      # 0x809b
leaq 0x4ad8(%rip), %rdx      # 0x80ae
leaq 0x128(%rsp), %rdi
movq %rax, 0x10(%rsp)
callq 0x5f90
leaq 0x128(%rsp), %rdx
movq %r15, %rdi
xorl %esi, %esi
movl $0x64, %ecx
callq 0x6ae0
movq 0x128(%rsp), %rdi
cmpq %r14, %rdi
je 0x361c
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x31a0
movl $0x10, %edi
callq 0x3190
movq %rax, %r15
leaq 0x118(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x4a73(%rip), %rsi      # 0x80af
leaq 0x4a80(%rip), %rdx      # 0x80c3
leaq 0x108(%rsp), %rdi
movq %rax, 0x40(%rsp)
callq 0x5f90
leaq 0x108(%rsp), %rdx
movq %r15, %rdi
xorl %esi, %esi
callq 0x6e62
movq 0x108(%rsp), %rdi
cmpq %r14, %rdi
je 0x3684
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x31a0
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
leaq 0x1508(%rip), %r14      # 0x4b9b
movq %r14, %rsi
xorl %edx, %edx
callq *0x30(%rax)
movq 0x40(%rsp), %rdi
movq (%rdi), %rax
movq %r14, %rsi
xorl %edx, %edx
callq *0x30(%rax)
leaq 0x70(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4a09(%rip), %rsi      # 0x80c4
leaq 0x4a05(%rip), %rdx      # 0x80c7
leaq 0x60(%rsp), %rdi
callq 0x5f90
leaq 0xb8(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x505b(%rip), %rdx      # 0x873a
leaq 0xa8(%rsp), %rdi
movq %rdx, %rsi
callq 0x5f90
cmpl $0x2, %ebx
jl 0x3ba8
movl %ebx, %r15d
movl $0xffffffff, 0x48(%rsp) # imm = 0xFFFFFFFF
movb $0x1, %al
movl %eax, 0x58(%rsp)
movl $0x1, 0xa0(%rsp)
xorl %r13d, %r13d
movl $0x1, %r14d
leaq 0x20(%rsp), %rbp
movl $0x0, 0x1c(%rsp)
movl $0x0, 0x50(%rsp)
movl $0x0, 0xc(%rsp)
movq (%r12,%r14,8), %rsi
movq %rbp, %rdi
leaq 0x80(%rsp), %rdx
callq 0x5e00
leaq 0xa8(%rsp), %rbx
movq %rbx, %rdi
leaq 0x4fda(%rip), %rsi      # 0x873a
callq 0x3070
movq 0x20(%rsp), %rcx
movb (%rcx), %cl
testl %eax, %eax
je 0x37c5
cmpb $0x2d, %cl
jne 0x38a9
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
movq 0x8840(%rip), %rdi      # 0xbfd0
callq 0x31b0
movq %rax, %rbx
movl $0x10, %edx
movq %rax, %rdi
leaq 0x4921(%rip), %rsi      # 0x80c8
callq 0x31b0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3170
jmp 0x3925
leaq 0x60(%rsp), %rdi
cmpb $0x2d, %cl
jne 0x389a
movq %rbp, %rdi
leaq 0x4966(%rip), %rsi      # 0x8143
callq 0x3070
testl %eax, %eax
je 0x3a53
movq %rbp, %rdi
leaq 0x4952(%rip), %rsi      # 0x8146
callq 0x3070
testl %eax, %eax
je 0x3a53
movq %rbp, %rdi
leaq 0x4942(%rip), %rsi      # 0x814d
callq 0x3070
testl %eax, %eax
je 0x3b64
movq %rbp, %rdi
leaq 0x492e(%rip), %rsi      # 0x8150
callq 0x3070
xorl %ebx, %ebx
testl %eax, %eax
je 0x3b7e
movq %rbp, %rdi
leaq 0x491f(%rip), %rsi      # 0x815a
callq 0x3070
testl %eax, %eax
je 0x3b73
movq %rbp, %rdi
leaq 0x490b(%rip), %rsi      # 0x815d
callq 0x3070
testl %eax, %eax
je 0x3b73
movq %rbp, %rdi
leaq 0x48fb(%rip), %rsi      # 0x8164
callq 0x3070
movl $0x2, %ebx
testl %eax, %eax
je 0x3b9d
movq %rbp, %rdi
leaq 0x48e2(%rip), %rsi      # 0x8167
callq 0x3070
leaq 0xa8(%rsp), %rdi
testl %eax, %eax
je 0x3b9d
xorl %ebx, %ebx
movq %rbp, %rsi
callq 0x30f0
jmp 0x3943
movl $0xa, %ecx
movq %rbp, %rdi
leaq 0x47d8(%rip), %rsi      # 0x8090
xorl %edx, %edx
callq 0x3250
cmpq $-0x1, %rax
je 0x3979
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
movq 0x86f0(%rip), %rdi      # 0xbfd0
callq 0x31b0
movq %rax, %rbx
movl $0x21, %edx
movq %rax, %rdi
leaq 0x47e2(%rip), %rsi      # 0x80d9
callq 0x31b0
movq 0x20(%rsp), %rsi
movq 0x28(%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, %r13d
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x395f
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x31a0
testb $0x3, %bl
jne 0x3bc9
incq %r14
cmpq %r14, %r15
jne 0x373a
jmp 0x3bc4
movq %rbx, %rdi
leaq 0x4778(%rip), %rsi      # 0x80fb
callq 0x3070
testl %eax, %eax
je 0x3aaa
movq %rbx, %rdi
leaq 0x4764(%rip), %rsi      # 0x80fe
callq 0x3070
testl %eax, %eax
je 0x3aaa
movq %rbx, %rdi
leaq 0x4754(%rip), %rsi      # 0x8105
callq 0x3070
testl %eax, %eax
je 0x3ae2
movq %rbx, %rdi
leaq 0x4740(%rip), %rsi      # 0x8108
callq 0x3070
testl %eax, %eax
je 0x3ae2
movq %rbx, %rdi
leaq 0x4748(%rip), %rsi      # 0x8127
callq 0x3070
testl %eax, %eax
je 0x3b8b
movq %rbx, %rdi
leaq 0x4734(%rip), %rsi      # 0x812a
callq 0x3070
testl %eax, %eax
je 0x3b8b
movl $0x10, %edx
movq 0x85c1(%rip), %rdi      # 0xbfd0
leaq 0x471c(%rip), %rsi      # 0x8132
callq 0x31b0
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
movq 0x859e(%rip), %rdi      # 0xbfd0
callq 0x31b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3170
jmp 0x3925
movl $0x31a, %edx            # imm = 0x31A
movq 0x8571(%rip), %rdi      # 0xbfd0
leaq 0x4902(%rip), %rsi      # 0x8368
callq 0x31b0
movq 0x855e(%rip), %rcx      # 0xbfd0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x3170
movsbl %al, %esi
movq 0x8540(%rip), %rdi      # 0xbfd0
callq 0x3040
movq %rax, %rdi
callq 0x3110
xorl %r13d, %r13d
movl $0x1, %ebx
jmp 0x3943
movq (%r12,%r14,8), %rdi
callq 0x3220
movl %eax, 0x1c(%rsp)
movl $0x4, %ebx
movq 0xb0(%rsp), %rdx
leaq 0xa8(%rsp), %rdi
xorl %esi, %esi
leaq 0x4c65(%rip), %rcx      # 0x873a
xorl %r8d, %r8d
callq 0x3210
jmp 0x3943
movq (%r12,%r14,8), %rdi
callq 0x3220
movl %eax, 0xa0(%rsp)
addl $-0x11, %eax
cmpl $-0x11, %eax
ja 0x3ab7
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
movq 0x84bf(%rip), %rdi      # 0xbfd0
callq 0x31b0
movq %rax, %rbx
movl $0x14, %edx
movq %rax, %rdi
leaq 0x45ea(%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, %r13d
jmp 0x3943
movl $0x0, 0x58(%rsp)
xorl %ebx, %ebx
jmp 0x3943
movb $0x1, %al
movl %eax, 0xc(%rsp)
jmp 0x3943
movl $0x0, 0x58(%rsp)
jmp 0x3943
movq (%r12,%r14,8), %rdi
callq 0x3220
movl %eax, 0x48(%rsp)
jmp 0x3ab7
movb $0x1, %al
movl %eax, 0x50(%rsp)
jmp 0x3943
xorl %r12d, %r12d
movb $0x1, %r15b
movl $0xffffffff, 0x48(%rsp) # imm = 0xFFFFFFFF
xorl %ecx, %ecx
movb $0x1, %al
xorl %r14d, %r14d
xorl %ebp, %ebp
xorl %r13d, %r13d
jmp 0x3bec
movl $0x2, %ebx
cmpl $0x2, %ebx
sete %al
movl 0xa0(%rsp), %r14d
decl %r14d
movl 0x58(%rsp), %r15d
movl 0xc(%rsp), %r12d
movl 0x1c(%rsp), %ebp
movl 0x50(%rsp), %ecx
testb %al, %al
je 0x497d
testb $0x1, %cl
je 0x3d21
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
testl %eax, %eax
je 0x43e1
movq 0x83b9(%rip), %rbx      # 0xbfd0
leaq 0x4550(%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 0x8387(%rip), %rdi      # 0xbfd0
callq 0x3040
movq %rax, %rdi
callq 0x3110
xorl %ebx, %ebx
movq 0x8371(%rip), %r14      # 0xbfd0
leaq 0x4515(%rip), %r15      # 0x817b
leaq 0x4560(%rip), %r12      # 0x81cd
leaq 0x20(%rsp), %r13
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
cmpl %eax, %ebx
jae 0x4427
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 0x10(%rsp), %rsi
movq (%rsi), %rax
movq %r13, %rdi
movl %ebx, %edx
callq *0x18(%rax)
movq 0x20(%rsp), %rsi
movq 0x28(%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 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x3d1a
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x31a0
incl %ebx
jmp 0x3c72
leaq 0xea7(%rip), %rbx       # 0x4bcf
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 0x4455(%rip), %rsi      # 0x81ab
leaq 0x60(%rsp), %rdi
callq 0x3070
testl %eax, %eax
je 0x4014
xorpd %xmm0, %xmm0
movapd %xmm0, 0x80(%rsp)
movq $0x0, 0x90(%rsp)
movl 0x48(%rsp), %eax
testl %eax, %eax
movl $0x1f4, %ecx            # imm = 0x1F4
cmovnsl %eax, %ecx
movl %ecx, 0x1c(%rsp)
movq 0x8236(%rip), %rdi      # 0xbfd0
leaq 0x4410(%rip), %rsi      # 0x81b1
movl $0xf, %edx
callq 0x31b0
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
movq 0x8214(%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 0x43cc(%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 0x43f1(%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 0x433c(%rip), %rsi      # 0x81c8
movl $0x7, %edx
movq %rax, %rdi
callq 0x31b0
movq %rbx, %rdi
movl 0x1c(%rsp), %esi
callq 0x3270
movq %rax, %rbx
leaq 0x4321(%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 0x40(%rsp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
testl %eax, %eax
je 0x4824
leaq 0xd8(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x434c(%rip), %rsi      # 0x8255
leaq 0x4352(%rip), %rdx      # 0x8262
leaq 0xc8(%rsp), %rdi
callq 0x5f90
movq 0x40(%rsp), %rdi
movq (%rdi), %rax
leaq 0xc8(%rsp), %rdx
movl %ebp, %esi
callq *(%rax)
movq 0xc8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x3f4e
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x31a0
movq 0x807b(%rip), %rdi      # 0xbfd0
leaq 0x429e(%rip), %rsi      # 0x81fa
movl $0x7, %edx
callq 0x31b0
movq 0x40(%rsp), %rsi
movq (%rsi), %rax
leaq 0x20(%rsp), %rdi
movl %ebp, %edx
callq *0x18(%rax)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x8047(%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 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3fd3
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x31a0
leaq 0x40ea(%rip), %rsi      # 0x80c4
leaq 0x60(%rsp), %rdi
callq 0x3070
movl %eax, %ebx
testl %eax, %eax
je 0x4596
leaq 0x4115(%rip), %rsi      # 0x810a
leaq 0x60(%rsp), %rdi
callq 0x3070
testl %eax, %eax
je 0x4596
movl $0x0, 0xc(%rsp)
jmp 0x45ac
movl 0x48(%rsp), %eax
testl %eax, %eax
movl $0x28, %ebx
cmovnsl %eax, %ebx
movq 0x7fa7(%rip), %rdi      # 0xbfd0
leaq 0x4181(%rip), %rsi      # 0x81b1
movl $0xf, %edx
callq 0x31b0
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
movq 0x7f85(%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 0x413d(%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 0x40f9(%rip), %rsi      # 0x81c8
movl $0x7, %edx
movq %rax, %rdi
callq 0x31b0
movq %r14, %rdi
movl %ebx, %esi
callq 0x3270
movq %rax, %rbx
leaq 0x40e0(%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
movl %ebp, %r14d
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movl %eax, %ebp
testl %eax, %eax
je 0x4901
leaq 0xf8(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x409e(%rip), %rsi      # 0x81ed
leaq 0x40a3(%rip), %rdx      # 0x81f9
leaq 0xe8(%rsp), %rdi
callq 0x5f90
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
leaq 0xe8(%rsp), %rdx
movl %r14d, %esi
callq *(%rax)
movq 0xe8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x4195
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x31a0
movq 0x7e34(%rip), %rdi      # 0xbfd0
leaq 0x4057(%rip), %rsi      # 0x81fa
movl $0x7, %edx
callq 0x31b0
movq 0x10(%rsp), %rsi
movq (%rsi), %rax
leaq 0x20(%rsp), %rdi
movl %r14d, %edx
callq *0x18(%rax)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x7dff(%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 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x421b
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x31a0
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq *0x48(%rax)
movq 0x7d99(%rip), %rbx      # 0xbfd0
leaq 0x3fc4(%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 0x7d67(%rip), %rdi      # 0xbfd0
callq 0x3040
movq %rax, %rdi
callq 0x3110
movq 0x7d53(%rip), %rbx      # 0xbfd0
leaq 0x3f89(%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 0x7d21(%rip), %rdi      # 0xbfd0
callq 0x3040
movq %rax, %rdi
callq 0x3110
xorpd %xmm0, %xmm0
movapd %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
cmpl $0x0, 0x7e9a(%rip)      # 0xc170
je 0x4370
leaq 0x20(%rsp), %rbx
movzbl %r15b, %r14d
andl $0x1, %r14d
movzbl %r12b, %r15d
andl $0x1, %r15d
leaq 0x80(%rsp), %r12
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rdi
movq %rbx, %rsi
callq 0x756c
ucomisd 0x3cf6(%rip), %xmm0     # 0x8008
jne 0x4316
jnp 0x4335
movq %rbx, %rdi
movl %r14d, %esi
movl %r15d, %edx
callq 0x4bda
movq 0x20(%rsp), %rax
cmpq %rax, 0x28(%rsp)
je 0x4335
movq %rax, 0x28(%rsp)
movq $0x0, 0x80(%rsp)
movq $0x1312d00, 0x88(%rsp) # imm = 0x1312D00
movq %r12, %rdi
movq %r12, %rsi
callq 0x3080
cmpl $-0x1, %eax
jne 0x4367
callq 0x3050
cmpl $0x4, (%rax)
je 0x434d
cmpl $0x0, 0x7e02(%rip)      # 0xc170
jne 0x42f9
movq 0x7c59(%rip), %rbx      # 0xbfd0
leaq 0x3ea1(%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 0x7c27(%rip), %rdi      # 0xbfd0
callq 0x3040
movq %rax, %rdi
callq 0x3110
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x4960
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x31a0
jmp 0x4960
movq 0x7be8(%rip), %rbx      # 0xbfd0
leaq 0x3d8f(%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 0x7bb6(%rip), %rdi      # 0xbfd0
callq 0x3040
movq %rax, %rdi
callq 0x3110
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
testl %eax, %eax
je 0x454b
movq 0x7b8f(%rip), %rbx      # 0xbfd0
leaq 0x3d45(%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 0x7b5d(%rip), %rdi      # 0xbfd0
callq 0x3040
movq %rax, %rdi
callq 0x3110
xorl %ebx, %ebx
movq 0x7b47(%rip), %r14      # 0xbfd0
leaq 0x3ceb(%rip), %r15      # 0x817b
leaq 0x3d36(%rip), %r12      # 0x81cd
leaq 0x20(%rsp), %r13
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
cmpl %eax, %ebx
jae 0x497a
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 0x40(%rsp), %rsi
movq (%rsi), %rax
movq %r13, %rdi
movl %ebx, %edx
callq *0x18(%rax)
movq 0x20(%rsp), %rsi
movq 0x28(%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 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x4544
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x31a0
incl %ebx
jmp 0x449c
movq 0x7a7e(%rip), %rbx      # 0xbfd0
leaq 0x3c42(%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 0x7a4c(%rip), %rdi      # 0xbfd0
callq 0x3040
movq %rax, %rdi
callq 0x3110
jmp 0x497a
movb $0x1, %al
movl %eax, 0xc(%rsp)
leaq 0x80(%rsp), %rdi
movl %r14d, %esi
callq 0x4d56
testl %ebx, %ebx
je 0x45c5
leaq 0x3cac(%rip), %rsi      # 0x8263
leaq 0x60(%rsp), %rdi
callq 0x3070
testl %eax, %eax
jne 0x45d8
movb $0x1, %al
movl %eax, 0xc(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x4fbd
testl %ebx, %ebx
je 0x45f1
leaq 0x3c87(%rip), %rsi      # 0x826a
leaq 0x60(%rsp), %rdi
callq 0x3070
testl %eax, %eax
jne 0x4604
movb $0x1, %al
movl %eax, 0xc(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x52c0
testl %ebx, %ebx
je 0x461d
leaq 0x3c64(%rip), %rsi      # 0x8273
leaq 0x60(%rsp), %rdi
callq 0x3070
testl %eax, %eax
jne 0x4633
movb $0x1, %al
movl %eax, 0xc(%rsp)
leaq 0x80(%rsp), %rdi
movl %r14d, %esi
callq 0x54bb
testl %ebx, %ebx
je 0x464c
leaq 0x3c3d(%rip), %rsi      # 0x827b
leaq 0x60(%rsp), %rdi
callq 0x3070
testl %eax, %eax
jne 0x4662
movb $0x1, %al
movl %eax, 0xc(%rsp)
leaq 0x80(%rsp), %rdi
movl %r14d, %esi
callq 0x5808
testl %ebx, %ebx
je 0x467b
leaq 0x3c14(%rip), %rsi      # 0x8281
leaq 0x60(%rsp), %rdi
callq 0x3070
testl %eax, %eax
jne 0x468e
movb $0x1, %al
movl %eax, 0xc(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x598f
cmpb $0x0, 0xc(%rsp)
je 0x488d
movq %r13, 0x50(%rsp)
movq 0x80(%rsp), %rbp
movq 0x88(%rsp), %rax
movq %rax, 0xa0(%rsp)
cmpq %rax, %rbp
je 0x480f
cmpl $0x0, 0x7aaa(%rip)      # 0xc170
je 0x480f
movslq 0x1c(%rsp), %rcx
movq %rcx, %rax
shrq $0x3, %rax
movabsq $0x20c49ba5e353f7cf, %rdx # imm = 0x20C49BA5E353F7CF
mulq %rdx
shrq $0x4, %rdx
movq %rdx, 0x58(%rsp)
imulq $-0x3e8, %rdx, %rax     # imm = 0xFC18
addq %rcx, %rax
movl %r12d, %ecx
imulq $0xf4240, %rax, %r12    # imm = 0xF4240
movzbl %r15b, %r15d
andl $0x1, %r15d
movzbl %cl, %ebx
andl $0x1, %ebx
leaq 0x20(%rsp), %r13
movq (%rbp), %rsi
movq 0x8(%rbp), %rdx
movq 0x78ac(%rip), %rdi      # 0xbfd0
callq 0x31b0
movq %rax, %r14
movl $0x5, %edx
movq %rax, %rdi
leaq 0x3acc(%rip), %rsi      # 0x8207
callq 0x31b0
movq (%r14), %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 0x20(%rbp), %r14
movq %rbp, 0x48(%rsp)
movq 0x28(%rbp), %rbp
cmpq %rbp, %r14
je 0x47ef
cmpl $0x0, 0x79f0(%rip)      # 0xc170
je 0x47ef
movl $0xa, %edx
movq 0x7842(%rip), %rdi      # 0xbfd0
leaq 0x3b04(%rip), %rsi      # 0x8299
callq 0x31b0
movq %r14, %rdi
movl %r15d, %esi
movl %ebx, %edx
callq 0x4bda
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
movq %r14, %rsi
callq *0x48(%rax)
cmpl $0x0, 0x1c(%rsp)
jle 0x47e9
movq 0x58(%rsp), %rax
movq %rax, 0x20(%rsp)
movq %r12, 0x28(%rsp)
movq %r13, %rdi
movq %r13, %rsi
callq 0x3080
cmpl $-0x1, %eax
jne 0x47e9
callq 0x3050
cmpl $0x4, (%rax)
je 0x47cf
addq $0x18, %r14
jmp 0x4774
movq 0x48(%rsp), %rbp
addq $0x38, %rbp
cmpq 0xa0(%rsp), %rbp
je 0x480f
cmpl $0x0, 0x7967(%rip)      # 0xc170
jne 0x4715
movq 0x40(%rsp), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
movq 0x50(%rsp), %r13
jmp 0x48eb
movq 0x77a5(%rip), %rbx      # 0xbfd0
leaq 0x3a09(%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 0x7773(%rip), %rdi      # 0xbfd0
callq 0x3040
movq %rax, %rdi
callq 0x3110
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
movq 0x40(%rsp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
movl $0x0, 0xc(%rsp)
xorl %r13d, %r13d
jmp 0x48eb
movq 0x773c(%rip), %rdi      # 0xbfd0
leaq 0x39ef(%rip), %rsi      # 0x828a
movl $0xe, %edx
callq 0x31b0
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
movq 0x771a(%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, %r13d
movq %rax, %rdi
callq 0x3110
leaq 0x80(%rsp), %rdi
callq 0x5e3e
cmpb $0x0, 0xc(%rsp)
jne 0x4964
jmp 0x497d
movq 0x76c8(%rip), %rbx      # 0xbfd0
leaq 0x38c5(%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 0x7696(%rip), %rdi      # 0xbfd0
callq 0x3040
movq %rax, %rdi
callq 0x3110
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
movq 0x40(%rsp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
xorl %r13d, %r13d
testl %ebp, %ebp
je 0x497d
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
movq 0x40(%rsp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
xorl %r13d, %r13d
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x49a2
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x31a0
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x49be
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x31a0
movl %r13d, %eax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4b42
jmp 0x4b1a
movq %rax, %r15
movq 0xe8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x4b52
movq 0xf8(%rsp), %rsi
jmp 0x4b38
jmp 0x4b1a
jmp 0x4b42
movq %rax, %r15
movq 0xc8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x4b45
movq 0xd8(%rsp), %rsi
jmp 0x4a5b
jmp 0x4b42
movq %rax, %r15
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
jmp 0x4b2e
jmp 0x4afd
movq %rax, %r15
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4b45
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x31a0
jmp 0x4b45
jmp 0x4b42
jmp 0x4b42
jmp 0x4b1a
movq %rax, %r15
jmp 0x4b77
movq %rax, %r15
jmp 0x4b93
movq %rax, %r15
movq 0x108(%rsp), %rdi
cmpq %r14, %rdi
je 0x4aac
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x31a0
jmp 0x4aac
movq %rax, %r15
movl $0x10, %esi
movq 0x40(%rsp), %rdi
jmp 0x4b8e
movq %rax, %r15
movq 0x128(%rsp), %rdi
cmpq %r14, %rdi
je 0x4ae0
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x31a0
jmp 0x4ae0
movq %rax, %r15
movl $0x10, %esi
movq 0x10(%rsp), %rdi
jmp 0x4b8e
jmp 0x4afd
jmp 0x4b42
jmp 0x4b42
jmp 0x4b1a
jmp 0x4b1a
jmp 0x4b1a
jmp 0x4b1a
movq %rax, %r15
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x4b52
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
jmp 0x4b3b
jmp 0x4b21
jmp 0x4b21
jmp 0x4b1a
movq %rax, %r15
jmp 0x4b52
jmp 0x4b42
movq %rax, %r15
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x4b52
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x31a0
jmp 0x4b52
movq %rax, %r15
leaq 0x80(%rsp), %rdi
callq 0x5e3e
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x4b77
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x31a0
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x4b93
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x31a0
movq %r15, %rdi
callq 0x3280