// File: /workspace/github_cpp_makefile_star2_O3/davmac314[P]dinit/src/dinit-monitor.cc
// Function: dinit_monitor_main(int, char**)
int dinit_monitor_main(int argc, char **argv)
{
    bool show_help = argc < 2;
    std::string control_socket_str;
    const char *control_socket_path = nullptr;
    bool user_dinit = (getuid() != 0);  // communicate with user daemon
    bool issue_init = false;  // request initial service state
    bool use_environ = false;  // listening on activation environment changes
    bool exit_after = false;  // exit after first issued command
    const char *str_started = "started";
    const char *str_stopped = "stopped";
    const char *str_failed = "failed";
    const char *str_set = "set";
    const char *str_unset = "unset";

    const char *command_str = nullptr;
    std::vector<const char *> services;

    for (int i = 1; i < argc; i++) {
        if (argv[i][0] == '-') {
            if (strcmp(argv[i], "--help") == 0) {
                show_help = true;
                break;
            }
            else if (strcmp(argv[i], "--version") == 0) {
                std::cout << "Dinit version " << DINIT_VERSION << ".\n";
                return 0;
            }
            else if (strcmp(argv[i], "--exit") == 0 || strcmp(argv[i], "-e") == 0) {
                exit_after = true;
            }
            else if (strcmp(argv[i], "--env") == 0 || strcmp(argv[i], "-E") == 0) {
                use_environ = true;
            }
            else if (strcmp(argv[i], "--system") == 0 || strcmp(argv[i], "-s") == 0) {
                user_dinit = false;
            }
            else if (strcmp(argv[i], "--user") == 0 || strcmp(argv[i], "-u") == 0) {
                user_dinit = true;
            }
            else if (strcmp(argv[i], "--initial") == 0 || strcmp(argv[i], "-i") == 0) {
                issue_init = true;
            }
            else if (strcmp(argv[i], "--socket-path") == 0 || strcmp(argv[i], "-p") == 0) {
                ++i;
                if (i == argc) {
                    std::cerr << "dinit-monitor: --socket-path/-p should be followed by socket path\n";
                    return 1;
                }
                control_socket_str = argv[i];
            }
            else if (strcmp(argv[i], "--str-started") == 0) {
                ++i;
                if (i == argc) {
                    std::cerr << "dinit-monitor: --str-started should be followed by an argument\n";
                    return 1;
                }
                str_started = argv[i];
            }
            else if (strcmp(argv[i], "--str-stopped") == 0) {
                ++i;
                if (i == argc) {
                    std::cerr << "dinit-monitor: --str-stopped should be followed by an argument\n";
                    return 1;
                }
                str_stopped = argv[i];
            }
            else if (strcmp(argv[i], "--str-failed") == 0) {
                ++i;
                if (i == argc) {
                    std::cerr << "dinit-monitor: --str-failed should be followed by an argument\n";
                    return 1;
                }
                str_failed = argv[i];
            }
            else if (strcmp(argv[i], "--str-set") == 0) {
                ++i;
                if (i == argc) {
                    std::cerr << "dinit-monitor: --str-set should be followed by an argument\n";
                    return 1;
                }
                str_set = argv[i];
            }
            else if (strcmp(argv[i], "--str-unset") == 0) {
                ++i;
                if (i == argc) {
                    std::cerr << "dinit-monitor: --str-unset should be followed by an argument\n";
                    return 1;
                }
                str_unset = argv[i];
            }
            else if (strcmp(argv[i], "-c") == 0 || strcmp(argv[i], "--command") == 0) {
                ++i;
                if (i == argc) {
                    std::cerr << "dinit-monitor: --command/-c should be followed by command\n";
                    return 1;
                }
                command_str = argv[i];
            }
        }
        else {
            services.emplace_back(argv[i]);
        }
    }

    if (show_help) {
        std::cout << "dinit-monitor:   monitor Dinit services\n"
                "\n"
                "Usage:\n"
                "    dinit-monitor [options] <service-names|environ-names...>\n"
                "\n"
                "Options:\n"
                "  --help           : show this help\n"
                "  -e, --exit       : exit after the first issued command\n"
                "  -E, --env        : monitor activation environment changes\n"
                "  -s, --system     : monitor system daemon (default if run as root)\n"
                "  -u, --user       : monitor user daemon\n"
                "  -i, --initial    : also execute command for initial service state\n"
                "  --str-started <started-text>\n"
                "                   : specify text describing status when service starts\n"
                "  --str-stopped <stopped-text>\n"
                "                   : specify text describing status when service stops\n"
                "  --str-failed <failed-text>\n"
                "                   : specify text describing status when service fails\n"
                "  --socket-path <path>, -p <path>\n"
                "                   : specify socket for communication with daemon\n"
                "  -c, --command    : specify command to execute on service status change\n"
                "                     (%n for service name, %s for status)\n";
        return 1;
    }

    if (services.empty() && !use_environ) {
        std::cerr << "dinit-monitor: specify at least one service name\n";
        return 1;
    }

    if (command_str == nullptr) {
        std::cerr << "dinit-monitor: command must specified\n";
        return 1;
    }

    std::vector<stringview> command_parts = split_command(command_str);
    if (command_parts.size() == 0) {
        std::cerr << "dinit-monitor: specified command is empty\n";
        return 1;
    }

    // Ignore SIGPIPE to avoid dying due to it, and set up a SIGCHLD handler (but mask it)
    sigset_t signal_mask;
    sigprocmask(SIG_SETMASK, nullptr, &signal_mask);
    sigaddset(&signal_mask, SIGCHLD);
    sigprocmask(SIG_SETMASK, &signal_mask, nullptr);
    signal(SIGPIPE, SIG_IGN);
    signal(SIGCHLD, sigchld_handler);

    // Locate control socket
    if (! control_socket_str.empty()) {
        control_socket_path = control_socket_str.c_str();
    }
    else {
        control_socket_path = get_default_socket_path(control_socket_str, user_dinit);
        if (control_socket_path == nullptr) {
            std::cerr << "dinit-monitor: cannot locate user home directory (set XDG_RUNTIME_DIR, "
                    "HOME, check /etc/passwd file, or specify socket path via -p)\n";
            return 1;
        }
    }

    try {
        int socknum = connect_to_daemon(control_socket_path);

        // Start by querying protocol version:
        cpbuffer_t rbuffer;
        uint16_t protocol_ver = check_protocol_version(min_cp_version, max_cp_version, rbuffer, socknum);

        // Load all services
        std::unordered_map<handle_t, const char *> service_map;
        std::unordered_set<std::string> environ_set;
        std::vector<std::pair<const char *, service_state_t>> service_init_state;
        std::string env_value;

        for (const char *service_name : services) {

            handle_t hndl;
            service_state_t state;

            if (use_environ) {
                environ_set.emplace(service_name);
                continue;
            }

            if (!load_service(socknum, rbuffer, service_name, &hndl, &state)) {
                std::cerr << "dinit-monitor: cannot load service: " << service_name << "\n";
                return 1;
            }

            service_map.emplace(hndl, service_name);
            service_init_state.push_back(std::make_pair(service_name, state));
        }

        if (use_environ) {
            // Request listening on environ events
            request_environ(socknum, rbuffer, protocol_ver);
            if (issue_init) {
                // Get the whole block and see if it's already set
                auto envsz = get_allenv(socknum, rbuffer);
                while (envsz > 0) {
                    bool issued;
                    envsz = read_var_and_issue(socknum, rbuffer, envsz, environ_set, env_value, command_parts, issued, str_set, str_unset);
                    if (issued && exit_after) {
                        return 0;
                    }
                }
            }
        }
        else if (issue_init) {
            // Issue initial status commands if requested
            for (auto state : service_init_state ) {
                if (state.second == service_state_t::STARTED) {
                    issue_command(state.first, nullptr, str_started, command_parts);
                    if (exit_after) {
                        return 0;
                    }
                }
                else if (state.second == service_state_t::STOPPED) {
                    issue_command(state.first, nullptr, str_stopped, command_parts);
                    if (exit_after) {
                        return 0;
                    }
                }
            }
        }

        // Watch information packets; execute notification

        int r = rbuffer.fill_to(socknum, 2);
        while (r > 0) {
            if (rbuffer[0] >= 100) {
                int pktlen = (unsigned char) rbuffer[1];
                fill_buffer_to(rbuffer, socknum, pktlen);

                if (use_environ && rbuffer[0] == (char)cp_info::ENVEVENT) {
                    envvar_len_t envln;
                    rbuffer.extract((char *) &envln, 3, sizeof(envln));
                    rbuffer.consume(pktlen);
                    // this will return 0, we don't want to consume after this
                    bool issued;
                    pktlen = read_var_and_issue(socknum, rbuffer, envln, environ_set, env_value, command_parts, issued, str_set, str_unset);
                    if (issued && exit_after) {
                        return 0;
                    }
                }
                else if (!use_environ && rbuffer[0] == (char)cp_info::SERVICEEVENT) {
                    handle_t ev_handle;
                    rbuffer.extract((char *) &ev_handle, 2, sizeof(ev_handle));
                    service_event_t event = static_cast<service_event_t>(rbuffer[2 + sizeof(ev_handle)]);

                    const char *service_name = service_map.at(ev_handle);
                    const char *event_str;

                    if (event == service_event_t::STARTED) {
                        event_str = str_started;
                    }
                    else if (event == service_event_t::STOPPED) {
                        event_str = str_stopped;
                    }
                    else if (event == service_event_t::FAILEDSTART) {
                        event_str = str_failed;
                    }
                    else {
                        goto consume_packet;
                    }
                    issue_command(service_name, nullptr, event_str, command_parts);
                    if (exit_after) {
                        return 0;
                    }
                }

                consume_packet:

                rbuffer.consume(pktlen);
                r = rbuffer.fill_to(socknum, 2);
            }
            else {
                // Not an information packet?
                std::cerr << "dinit-monitor: protocol error\n";
                return 1;
            }
        }

        if (r == -1) {
            perror("dinit-monitor: read");
        }
        else {
            std::cerr << "dinit-monitor: connection closed by server\n";
        }
        return 1;
    }
    catch (cp_old_client_exception &e) {
        std::cerr << "dinit-monitor: too old (server reports newer protocol version)\n";
    }
    catch (cp_old_server_exception &e) {
        std::cerr << "dinit-monitor: server too old or protocol error\n";
    }
    catch (cp_read_exception &e) {
        std::cerr << "dinit-monitor: control socket read failure or protocol error\n";
    }
    catch (cp_write_exception &e) {
        std::cerr << "dinit-monitor: control socket write error: " << std::strerror(e.errcode) << "\n";
    }
    catch (dinit_protocol_error &e) {
        std::cerr << "dinit-monitor: protocol error\n";
    }
    catch (general_error &ge) {
        std::cerr << "dinit-monitor";
        if (ge.get_action() != nullptr) {
            std::cerr << ": " << ge.get_action();
            std::string &arg = ge.get_arg();
            if (!arg.empty()) {
                std::cerr << " " << arg;
            }
        }
        if (ge.get_err() != 0) {
            std::cerr << ": " << strerror(ge.get_err());
        }
        std::cerr << '\n';
    }

    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x5f8, %rsp            # imm = 0x5F8
movq %rsi, %rbx
movl %edi, %ebp
leaq 0xd0(%rsp), %rax
movq %rax, -0x10(%rax)
xorl %r14d, %r14d
movq %r14, -0x8(%rax)
movb $0x0, (%rax)
callq 0x2110
movq %r14, 0xb0(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0xa0(%rsp)
movl $0x3d9, %edx            # imm = 0x3D9
leaq 0x3c80(%rip), %rsi      # 0x625c
movq 0x69ed(%rip), %rdi      # 0x8fd0
cmpl $0x2, %ebp
jl 0x2bbf
testl %eax, %eax
setne %al
movl %eax, 0x18(%rsp)
movl $0x1, %r14d
leaq 0x3bd1(%rip), %rax      # 0x61d3
movq %rax, 0x90(%rsp)
leaq 0x3b7c(%rip), %rax      # 0x618d
movq %rax, 0x98(%rsp)
leaq 0x3b21(%rip), %rax      # 0x6141
movq %rax, 0xb8(%rsp)
leaq 0x3ac4(%rip), %rax      # 0x60f3
movq %rax, 0x80(%rsp)
leaq 0x3a67(%rip), %rax      # 0x60a5
movq %rax, 0x88(%rsp)
movq $0x0, 0x58(%rsp)
leaq 0xa0(%rsp), %r15
movq $0x0, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
xorl %r12d, %r12d
movslq %r14d, %rax
movq (%rbx,%rax,8), %r13
cmpb $0x2d, (%r13)
jne 0x2852
movq %r13, %rdi
leaq 0x397c(%rip), %rsi      # 0x6004
callq 0x22e0
testl %eax, %eax
je 0x2b44
movq %r13, %rdi
leaq 0x396c(%rip), %rsi      # 0x600b
callq 0x22e0
testl %eax, %eax
je 0x2b59
movq %r13, %rdi
leaq 0x3971(%rip), %rsi      # 0x6027
callq 0x22e0
testl %eax, %eax
je 0x2863
cmpb $0x65, 0x1(%r13)
jne 0x26d5
cmpb $0x0, 0x2(%r13)
je 0x2863
movq %r13, %rdi
leaq 0x394f(%rip), %rsi      # 0x602e
callq 0x22e0
testl %eax, %eax
je 0x286f
cmpb $0x45, 0x1(%r13)
jne 0x26fe
cmpb $0x0, 0x2(%r13)
je 0x286f
movq %r13, %rdi
leaq 0x392c(%rip), %rsi      # 0x6034
callq 0x22e0
testl %eax, %eax
je 0x287b
cmpb $0x73, 0x1(%r13)
jne 0x2727
cmpb $0x0, 0x2(%r13)
je 0x287b
movq %r13, %rdi
leaq 0x390c(%rip), %rsi      # 0x603d
callq 0x22e0
testl %eax, %eax
je 0x2888
cmpb $0x75, 0x1(%r13)
jne 0x2750
cmpb $0x0, 0x2(%r13)
je 0x2888
movq %r13, %rdi
leaq 0x38ea(%rip), %rsi      # 0x6044
callq 0x22e0
testl %eax, %eax
je 0x2893
cmpb $0x69, 0x1(%r13)
jne 0x2779
cmpb $0x0, 0x2(%r13)
je 0x2893
movq %r13, %rdi
leaq 0x38cb(%rip), %rsi      # 0x604e
callq 0x22e0
testl %eax, %eax
je 0x289f
cmpb $0x70, 0x1(%r13)
jne 0x27a2
cmpb $0x0, 0x2(%r13)
je 0x289f
movq %r13, %rdi
leaq 0x38f3(%rip), %rsi      # 0x609f
callq 0x22e0
testl %eax, %eax
je 0x28e6
movq %r13, %rdi
leaq 0x392a(%rip), %rsi      # 0x60ed
callq 0x22e0
testl %eax, %eax
je 0x2903
movq %r13, %rdi
leaq 0x3961(%rip), %rsi      # 0x613b
callq 0x22e0
testl %eax, %eax
je 0x2920
movq %r13, %rdi
leaq 0x3996(%rip), %rsi      # 0x6187
callq 0x22e0
testl %eax, %eax
je 0x293d
movq %r13, %rdi
leaq 0x39c5(%rip), %rsi      # 0x61cd
callq 0x22e0
testl %eax, %eax
je 0x295a
cmpb $0x63, 0x1(%r13)
jne 0x2823
cmpb $0x0, 0x2(%r13)
je 0x283a
movq %r13, %rdi
leaq 0x39ea(%rip), %rsi      # 0x6217
callq 0x22e0
testl %eax, %eax
jne 0x2975
incl %r14d
cmpl %ebp, %r14d
je 0x359d
movslq %r14d, %rax
movq (%rbx,%rax,8), %r12
jmp 0x2975
leaq (%rbx,%rax,8), %rsi
movq %r15, %rdi
callq 0x439c
jmp 0x2975
movb $0x1, %al
movq %rax, 0x20(%rsp)
jmp 0x2975
movb $0x1, %al
movq %rax, 0x28(%rsp)
jmp 0x2975
movl $0x0, 0x18(%rsp)
jmp 0x2975
movb $0x1, %al
movl %eax, 0x18(%rsp)
jmp 0x2975
movb $0x1, %al
movq %rax, 0x58(%rsp)
jmp 0x2975
incl %r14d
cmpl %ebp, %r14d
je 0x348b
movslq %r14d, %rax
movq (%rbx,%rax,8), %r13
movq 0xc8(%rsp), %rax
movq %rax, 0x78(%rsp)
movq %r13, %rdi
callq 0x20e0
leaq 0xc0(%rsp), %rdi
xorl %esi, %esi
movq 0x78(%rsp), %rdx
movq %r13, %rcx
movq %rax, %r8
callq 0x2340
jmp 0x2975
incl %r14d
cmpl %ebp, %r14d
je 0x3546
movslq %r14d, %rax
movq (%rbx,%rax,8), %rax
movq %rax, 0x88(%rsp)
jmp 0x2975
incl %r14d
cmpl %ebp, %r14d
je 0x3565
movslq %r14d, %rax
movq (%rbx,%rax,8), %rax
movq %rax, 0x80(%rsp)
jmp 0x2975
incl %r14d
cmpl %ebp, %r14d
je 0x3573
movslq %r14d, %rax
movq (%rbx,%rax,8), %rax
movq %rax, 0xb8(%rsp)
jmp 0x2975
incl %r14d
cmpl %ebp, %r14d
je 0x3581
movslq %r14d, %rax
movq (%rbx,%rax,8), %rax
movq %rax, 0x98(%rsp)
jmp 0x2975
incl %r14d
cmpl %ebp, %r14d
je 0x358f
movslq %r14d, %rax
movq (%rbx,%rax,8), %rax
movq %rax, 0x90(%rsp)
incl %r14d
cmpl %ebp, %r14d
jl 0x266c
cmpl $0x2, %ebp
movq 0x6645(%rip), %rdi      # 0x8fd0
movl $0x3d9, %edx            # imm = 0x3D9
leaq 0x38c5(%rip), %rsi      # 0x625c
jl 0x2bbf
movq 0xa0(%rsp), %rax
cmpq 0xa8(%rsp), %rax
setne %al
orb 0x28(%rsp), %al
movq 0x6635(%rip), %rdi      # 0x8ff0
testb $0x1, %al
je 0x2ba5
testq %r12, %r12
je 0x2bb3
callq 0x22d0
movq %rax, %rbx
xorps %xmm0, %xmm0
leaq 0x40(%rsp), %r14
movaps %xmm0, (%r14)
movq $0x0, 0x10(%r14)
movb (%r12), %r15b
testb %r15b, %r15b
je 0x2ac5
movq %r12, %r13
movq %r12, %rbp
movq %rbx, %rdi
callq 0x20d0
movq 0x30(%rax), %rax
movzbl %r15b, %ecx
testb $0x20, 0x1(%rax,%rcx,2)
je 0x2a26
movb 0x1(%rbp), %r15b
incq %rbp
incq %r13
testb %r15b, %r15b
jne 0x29fb
jmp 0x2ac5
movb (%rbp), %r15b
testb %r15b, %r15b
je 0x2ac5
movq %rbp, %r12
movq %rbx, %rdi
callq 0x20d0
movq 0x30(%rax), %rax
movzbl %r15b, %ecx
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x2a73
cmpb $0x22, (%r12)
jne 0x2a66
movzbl 0x1(%r12), %eax
incq %r12
testl %eax, %eax
je 0x2a66
cmpl $0x22, %eax
jne 0x2a54
movb 0x1(%r12), %r15b
incq %r12
testb %r15b, %r15b
jne 0x2a36
movq %r12, %rax
subq %r13, %rax
movq %rbp, 0x170(%rsp)
movq %rax, 0x178(%rsp)
movq 0x48(%rsp), %rsi
cmpq 0x50(%rsp), %rsi
je 0x2aa8
movups 0x170(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x10, 0x48(%rsp)
jmp 0x2ab8
movq %r14, %rdi
leaq 0x170(%rsp), %rdx
callq 0x513e
movb (%r12), %r15b
testb %r15b, %r15b
jne 0x29ec
movq 0x48(%rsp), %rax
cmpq 0x40(%rsp), %rax
je 0x2c1f
leaq 0x578(%rsp), %rbx
movl $0x2, %edi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x20f0
movq %rbx, %rdi
movl $0x11, %esi
callq 0x2320
movl $0x2, %edi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x20f0
movl $0x1, %esi
movl $0xd, %edi
callq 0x2250
leaq 0xf0a(%rip), %rsi       # 0x3a28
movl $0x11, %edi
callq 0x2250
cmpq $0x0, 0xc8(%rsp)
je 0x2c41
movq 0xc0(%rsp), %rdi
jmp 0x2c62
movq 0x6485(%rip), %rdi      # 0x8fd0
movl $0x3d9, %edx            # imm = 0x3D9
leaq 0x3705(%rip), %rsi      # 0x625c
jmp 0x2bbf
movq 0x6470(%rip), %rdi      # 0x8fd0
leaq 0x34ae(%rip), %rsi      # 0x6015
movl $0xe, %edx
callq 0x2230
movq 0x6458(%rip), %rdi      # 0x8fd0
leaq 0x3e99(%rip), %rsi      # 0x6a18
movl $0x9, %edx
callq 0x2230
xorl %ebp, %ebp
movq 0x643e(%rip), %rdi      # 0x8fd0
leaq 0x348b(%rip), %rsi      # 0x6024
movl $0x2, %edx
callq 0x2230
jmp 0x2bc9
movl $0x31, %edx
leaq 0x3a85(%rip), %rsi      # 0x6636
jmp 0x2bbf
movl $0x26, %edx
leaq 0x3aa9(%rip), %rsi      # 0x6668
movl $0x1, %ebp
callq 0x2230
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x2be6
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2200
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x2c0b
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x2200
movl %ebp, %eax
addq $0x5f8, %rsp            # imm = 0x5F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %ebp
movq 0x63c5(%rip), %rdi      # 0x8ff0
leaq 0x3a5d(%rip), %rsi      # 0x668f
movl $0x2a, %edx
callq 0x2230
jmp 0x3526
movzbl 0x18(%rsp), %esi
andl $0x1, %esi
leaq 0xc0(%rsp), %rdi
callq 0x43d3
movq %rax, %rdi
testq %rax, %rax
je 0x3465
callq 0x44bc
movl %eax, %ebp
leaq 0x170(%rsp), %rdx
movq $0x0, 0x400(%rdx)
movl $0x1, %edi
movl $0x5, %esi
movl %eax, %ecx
callq 0x4703
movw %ax, 0x78(%rsp)
leaq 0x168(%rsp), %rax
movq %rax, -0x30(%rax)
movl $0x1, %ecx
movq %rcx, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, %edx       # imm = 0x3F800000
movl %edx, -0x10(%rax)
movups %xmm0, -0x8(%rax)
leaq 0x130(%rsp), %rax
movq %rax, -0x30(%rax)
movq %rcx, -0x28(%rax)
movups %xmm0, -0x20(%rax)
movl %edx, -0x10(%rax)
movups %xmm0, -0x8(%rax)
xorl %eax, %eax
movq %rax, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
leaq 0xf0(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb $0x0, (%rcx)
movq 0xa0(%rsp), %r12
movq 0xa8(%rsp), %rax
movq %rax, 0x18(%rsp)
cmpq %rax, %r12
je 0x2f42
movq (%r12), %rbx
movq %rbx, 0x10(%rsp)
testb $0x1, 0x28(%rsp)
je 0x2d39
leaq 0x100(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x54c6
jmp 0x2f33
movq %rbx, %rdi
callq 0x20e0
movq %rax, %r15
movzwl %r15w, %r14d
addl $0x3, %r14d
movq %r14, %rdi
callq 0x2030
movq %rax, %r13
movb $0x2, (%rax)
movw %r15w, 0x1(%rax)
movq %rax, %rdi
addq $0x3, %rdi
movzwl %r15w, %edx
movq %rbx, %rsi
callq 0x2180
xorl %r15d, %r15d
movq %r13, %rbx
movl %r14d, %edx
movl %ebp, %edi
movq %rbx, %rsi
callq 0x20a0
cmpl $-0x1, %eax
je 0x2d98
addl %eax, %r15d
movslq %eax, %rcx
addq %rcx, %rbx
subl %eax, %r14d
jmp 0x2da2
callq 0x2040
cmpl $0x4, (%rax)
jne 0x2db2
testl %r14d, %r14d
jg 0x2d78
cmpl $-0x1, %r15d
jne 0x2dbb
jmp 0x35f3
testl %r15d, %r15d
jle 0x35f3
movq %r13, %rdi
callq 0x2290
leaq 0x170(%rsp), %rdi
movl %ebp, %esi
callq 0x4a5b
movl 0x570(%rsp), %eax
leal -0x400(%rax), %ecx
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %ecx
movzbl 0x170(%rsp,%rcx), %eax
cmpl $0x3b, %eax
jne 0x341b
leaq 0x170(%rsp), %r13
cmpl $0x5, 0x574(%rsp)
ja 0x2e34
movq %r13, %rdi
movl %ebp, %esi
callq 0x5396
testl %eax, %eax
jg 0x2e00
cmpl $-0x1, %eax
jne 0x2e2c
callq 0x2040
cmpl $0x4, (%rax)
je 0x2e00
jmp 0x35bf
testl %eax, %eax
je 0x35d2
movl 0x570(%rsp), %r15d
leal 0x2(%r15), %eax
leal -0x3fe(%r15), %ebx
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %ebx
leal -0x3fd(%rbx), %ecx
movl %ebx, %eax
cmpl $0xfffffbfe, %ecx       # imm = 0xFFFFFBFE
ja 0x2e9b
movl $0x400, %r14d           # imm = 0x400
subl %ebx, %r14d
leaq (%rsp,%rax), %rsi
addq $0x170, %rsi            # imm = 0x170
leaq 0xc(%rsp), %rdi
movq %r14, %rdx
callq 0x2180
leaq (%rsp,%r14), %rdi
addq $0xc, %rdi
addl $0xfffffc04, %ebx       # imm = 0xFFFFFC04
movq %r13, %rsi
movq %rbx, %rdx
callq 0x2180
jmp 0x2ea6
movl 0x170(%rsp,%rax), %eax
movl %eax, 0xc(%rsp)
leaq 0xc(%rsp), %rsi
leal 0x1(%r15), %eax
leal -0x3ff(%r15), %ecx
movl $0x400, %edx            # imm = 0x400
cmpl %edx, %eax
cmovbl %eax, %ecx
movb 0x170(%rsp,%rcx), %bl
leal 0x7(%r15), %eax
addl $0xfffffc07, %r15d      # imm = 0xFFFFFC07
cmpl %edx, %eax
cmovbl %eax, %r15d
movl %r15d, 0x570(%rsp)
addl $-0x7, 0x574(%rsp)
leaq 0x138(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x57fa
movq 0x10(%rsp), %rax
movq %rax, 0x30(%rsp)
movb %bl, 0x38(%rsp)
movq 0x68(%rsp), %rsi
cmpq 0x70(%rsp), %rsi
je 0x2f24
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x10, 0x68(%rsp)
jmp 0x2f33
leaq 0x60(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x5a98
addq $0x8, %r12
cmpq 0x18(%rsp), %r12
jne 0x2d12
testb $0x1, 0x28(%rsp)
je 0x2fea
movzwl 0x78(%rsp), %edx
leaq 0x170(%rsp), %rsi
movl %ebp, %edi
callq 0x3a29
testb $0x1, 0x58(%rsp)
je 0x3055
leaq 0x170(%rsp), %rsi
movl %ebp, %edi
callq 0x3b2f
testq %rax, %rax
je 0x3055
leaq 0x30(%rsp), %r13
leaq 0x170(%rsp), %rbx
leaq 0x100(%rsp), %r14
leaq 0xe0(%rsp), %r15
leaq 0x40(%rsp), %r12
subq $0x8, %rsp
movl %ebp, %edi
movq %rbx, %rsi
movq %rax, %rdx
movq %r14, %rcx
movq %r15, %r8
movq %r12, %r9
pushq 0x98(%rsp)
pushq 0xa8(%rsp)
pushq %r13
callq 0x3cd4
addq $0x20, %rsp
movq 0x20(%rsp), %rcx
testb %cl, 0x30(%rsp)
jne 0x3487
testq %rax, %rax
jne 0x2fa6
jmp 0x3055
testb $0x1, 0x58(%rsp)
je 0x3055
movq 0x60(%rsp), %rbx
movq 0x68(%rsp), %r14
cmpq %r14, %rbx
je 0x3055
movq (%rbx), %rdi
movzbl 0x8(%rbx), %eax
testl %eax, %eax
je 0x302b
cmpl $0x2, %eax
jne 0x304f
movq 0x40(%rsp), %rcx
movq 0x48(%rsp), %r8
xorl %esi, %esi
movq 0x88(%rsp), %rdx
callq 0x401b
jmp 0x3044
movq 0x40(%rsp), %rcx
movq 0x48(%rsp), %r8
xorl %esi, %esi
movq 0x80(%rsp), %rdx
callq 0x401b
testb $0x1, 0x20(%rsp)
jne 0x3487
addq $0x10, %rbx
jmp 0x2ffb
leaq 0x170(%rsp), %rbx
cmpl $0x2, 0x574(%rsp)
jae 0x308f
movq %rbx, %rdi
movl %ebp, %esi
callq 0x5396
testl %eax, %eax
jg 0x305d
cmpl $-0x1, %eax
je 0x3554
movl $0x2b, %edx
leaq 0x370d(%rip), %rsi      # 0x6797
jmp 0x3405
movl 0x570(%rsp), %eax
leal -0x400(%rax), %ecx
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %ecx
movl $0x1e, %edx
leaq 0x36b4(%rip), %rsi      # 0x6764
cmpb $0x64, 0x170(%rsp,%rcx)
jl 0x3405
leaq 0x170(%rsp), %r15
leaq 0x10(%rsp), %rbx
leal 0x1(%rax), %ecx
addl $0xfffffc01, %eax       # imm = 0xFFFFFC01
cmpl $0x400, %ecx            # imm = 0x400
cmovbl %ecx, %eax
movzbl 0x170(%rsp,%rax), %r12d
cmpl %r12d, 0x574(%rsp)
jae 0x3119
movq %r15, %rdi
movl %ebp, %esi
callq 0x5396
testl %eax, %eax
jg 0x30e5
cmpl $-0x1, %eax
jne 0x3111
callq 0x2040
cmpl $0x4, (%rax)
je 0x30e5
jmp 0x3635
testl %eax, %eax
je 0x364a
movl 0x570(%rsp), %r14d
leal -0x400(%r14), %eax
cmpl $0x400, %r14d           # imm = 0x400
cmovbl %r14d, %eax
movb 0x170(%rsp,%rax), %al
testb $0x1, 0x28(%rsp)
je 0x31bb
cmpb $0x66, %al
jne 0x3381
leal 0x3(%r14), %eax
leal -0x3fd(%r14), %r13d
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %r13d
leal -0x3ff(%r13), %eax
cmpl $0xfffffbfe, %eax       # imm = 0xFFFFFBFE
ja 0x3234
movl $0x400, %ebx            # imm = 0x400
subl %r13d, %ebx
movl %r13d, %eax
leaq (%rsp,%rax), %rsi
addq $0x170, %rsi            # imm = 0x170
leaq 0x30(%rsp), %rdi
movq %rbx, %rdx
callq 0x2180
leaq (%rsp,%rbx), %rdi
addq $0x30, %rdi
leaq 0x10(%rsp), %rbx
addl $0xfffffc02, %r13d      # imm = 0xFFFFFC02
movq %r15, %rsi
movq %r13, %rdx
callq 0x2180
movzwl 0x30(%rsp), %eax
jmp 0x3244
cmpb $0x64, %al
jne 0x3381
leal 0x2(%r14), %eax
leal -0x3fe(%r14), %r13d
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %r13d
leal -0x3fd(%r13), %eax
cmpl $0xfffffbfe, %eax       # imm = 0xFFFFFBFE
ja 0x32b8
movl $0x400, %ebx            # imm = 0x400
subl %r13d, %ebx
movl %r13d, %eax
leaq (%rsp,%rax), %rsi
addq $0x170, %rsi            # imm = 0x170
leaq 0x30(%rsp), %rdi
movq %rbx, %rdx
callq 0x2180
leaq (%rsp,%rbx), %rdi
addq $0x30, %rdi
leaq 0x10(%rsp), %rbx
addl $0xfffffc04, %r13d      # imm = 0xFFFFFC04
movq %r15, %rsi
movq %r13, %rdx
callq 0x2180
movl 0x30(%rsp), %edi
jmp 0x32c6
movl %r13d, %eax
movzwl 0x170(%rsp,%rax), %eax
movw %ax, 0x30(%rsp)
leal (%r14,%r12), %ecx
cmpl $0x400, %ecx            # imm = 0x400
leal -0x400(%r14,%r12), %edx
cmovbl %ecx, %edx
movl %edx, 0x570(%rsp)
subl %r12d, 0x574(%rsp)
movzwl %ax, %edx
subq $0x8, %rsp
movl %ebp, %edi
movq %r15, %rsi
leaq 0x108(%rsp), %rcx
leaq 0xe8(%rsp), %r8
leaq 0x48(%rsp), %r9
pushq 0x98(%rsp)
pushq 0xa8(%rsp)
pushq %rbx
callq 0x3cd4
addq $0x20, %rsp
movq %rax, %r12
movq 0x20(%rsp), %rax
testb %al, 0x10(%rsp)
je 0x3381
jmp 0x3487
movl %r13d, %eax
movl 0x170(%rsp,%rax), %edi
movl %edi, 0x30(%rsp)
leal 0x6(%r14), %eax
addl $0xfffffc06, %r14d      # imm = 0xFFFFFC06
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %r14d
movl %edi, %eax
movq 0x138(%rsp), %rsi
movq 0x140(%rsp), %r9
xorl %edx, %edx
divq %r9
movq (%rsi,%rdx,8), %rax
testq %rax, %rax
je 0x366b
movq %rdx, %rcx
movzbl 0x170(%rsp,%r14), %r8d
movq (%rax), %r10
cmpl 0x8(%r10), %edi
je 0x3338
movq (%r10), %r10
testq %r10, %r10
je 0x366b
movl 0x8(%r10), %esi
movq %rsi, %rax
xorl %edx, %edx
divq %r9
cmpq %rcx, %rdx
jne 0x366b
cmpl %esi, %edi
jne 0x3313
movq 0x10(%r10), %rdi
movq 0x88(%rsp), %rdx
testl %r8d, %r8d
je 0x3365
movq 0x80(%rsp), %rdx
cmpl $0x1, %r8d
je 0x3365
cmpl $0x2, %r8d
jne 0x3381
movq 0xb8(%rsp), %rdx
movq 0x40(%rsp), %rcx
movq 0x48(%rsp), %r8
xorl %esi, %esi
callq 0x401b
testb $0x1, 0x20(%rsp)
jne 0x3487
movl 0x570(%rsp), %eax
movl 0x574(%rsp), %ecx
leal (%rax,%r12), %edx
cmpl $0x400, %edx            # imm = 0x400
leal -0x400(%rax,%r12), %eax
cmovbl %edx, %eax
movl %eax, 0x570(%rsp)
subl %r12d, %ecx
movl %ecx, 0x574(%rsp)
cmpl $0x1, %ecx
ja 0x33d6
movq %r15, %rdi
movl %ebp, %esi
callq 0x5396
testl %eax, %eax
jle 0x3075
cmpl $0x1, 0x574(%rsp)
jbe 0x33ba
movl 0x570(%rsp), %eax
leal -0x400(%rax), %ecx
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %ecx
cmpb $0x63, 0x170(%rsp,%rcx)
jg 0x30cb
movl $0x1e, %edx
leaq 0x335f(%rip), %rsi      # 0x6764
movl $0x1, %ebp
movq 0x5bdf(%rip), %rdi      # 0x8ff0
callq 0x2230
jmp 0x34d0
cmpl $0x3c, %eax
jne 0x361a
movq 0x5bc5(%rip), %rbx      # 0x8ff0
leaq 0x330d(%rip), %rsi      # 0x673f
movl $0x24, %edx
movq %rbx, %rdi
callq 0x2230
movq 0x10(%rsp), %r14
testq %r14, %r14
je 0x349c
movq %r14, %rdi
callq 0x20e0
movq 0x5b98(%rip), %rdi      # 0x8ff0
movq %r14, %rsi
movq %rax, %rdx
callq 0x2230
jmp 0x34b3
movl $0x1, %ebp
movq 0x5b7f(%rip), %rdi      # 0x8ff0
leaq 0x3242(%rip), %rsi      # 0x66ba
movl $0x84, %edx
callq 0x2230
jmp 0x3526
xorl %ebp, %ebp
jmp 0x34d0
movl $0x42, %edx
leaq 0x2bc5(%rip), %rsi      # 0x605c
jmp 0x35a9
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x2380
movq 0x5b36(%rip), %rdi      # 0x8ff0
leaq 0x33e9(%rip), %rsi      # 0x68aa
movl $0x1, %edx
callq 0x2230
movl $0x1, %ebp
movq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0x34f5
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x350c
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x2200
leaq 0x100(%rsp), %rdi
callq 0x4bee
leaq 0x138(%rsp), %rdi
callq 0x4c8c
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x2bc9
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2200
jmp 0x2bc9
movl $0x3f, %edx
leaq 0x2b5b(%rip), %rsi      # 0x60ad
jmp 0x35a9
leaq 0x3228(%rip), %rdi      # 0x6783
callq 0x21a0
jmp 0x34cb
movl $0x3f, %edx
leaq 0x2b8a(%rip), %rsi      # 0x60fb
jmp 0x35a9
movl $0x3e, %edx
leaq 0x2bc9(%rip), %rsi      # 0x6148
jmp 0x35a9
movl $0x3b, %edx
leaq 0x2c04(%rip), %rsi      # 0x6191
jmp 0x35a9
movl $0x3d, %edx
leaq 0x2c3e(%rip), %rsi      # 0x61d9
jmp 0x35a9
movl $0x3a, %edx
leaq 0x2c78(%rip), %rsi      # 0x6221
movl $0x1, %ebp
movq 0x5a3b(%rip), %rdi      # 0x8ff0
callq 0x2230
jmp 0x2bc9
movq %rax, %rbx
movl $0x4, %edi
callq 0x2100
movl (%rbx), %ecx
movl %ecx, (%rax)
jmp 0x35e2
movl $0x4, %edi
callq 0x2100
movl $0x0, (%rax)
leaq 0x577f(%rip), %rsi      # 0x8d68
movq %rax, %rdi
xorl %edx, %edx
callq 0x2390
movl $0x4, %edi
callq 0x2100
movq %rax, %rbx
callq 0x2040
movl (%rax), %eax
movl %eax, (%rbx)
leaq 0x5768(%rip), %rsi      # 0x8d78
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2390
movl $0x1, %edi
callq 0x2100
leaq 0x56fd(%rip), %rsi      # 0x8d28
movq %rax, %rdi
xorl %edx, %edx
callq 0x2390
movq %rax, %r13
movl $0x4, %edi
callq 0x2100
movl (%r13), %ecx
movl %ecx, (%rax)
jmp 0x365a
movl $0x4, %edi
callq 0x2100
movl $0x0, (%rax)
leaq 0x5707(%rip), %rsi      # 0x8d68
movq %rax, %rdi
xorl %edx, %edx
callq 0x2390
leaq 0x3398(%rip), %rdi      # 0x6a0a
callq 0x2300
jmp 0x36d6
jmp 0x36d6
jmp 0x36d6
jmp 0x36d6
jmp 0x36b3
jmp 0x36b3
jmp 0x36d6
jmp 0x36b3
jmp 0x3689
movq %rdx, %r14
movq %rax, %r15
jmp 0x3742
jmp 0x36d6
jmp 0x39db
jmp 0x36d6
jmp 0x36d6
jmp 0x36d6
jmp 0x36de
jmp 0x36d6
jmp 0x39db
jmp 0x36d6
jmp 0x36b3
jmp 0x39db
movq %rax, %r15
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x39de
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2200
jmp 0x39de
movq %rdx, %r14
movq %rax, %r15
jmp 0x36ec
movq %rdx, %r14
movq %rax, %r15
movq %r13, %rdi
callq 0x2290
movq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0x3711
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x3728
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x2200
leaq 0x100(%rsp), %rdi
callq 0x4bee
leaq 0x138(%rsp), %rdi
callq 0x4c8c
cmpl $0x6, %r14d
jne 0x3777
movq %r15, %rdi
callq 0x20c0
movq 0x5899(%rip), %rdi      # 0x8ff0
leaq 0x310e(%rip), %rsi      # 0x686c
movl $0x3f, %edx
callq 0x2230
movl $0x1, %ebp
callq 0x2370
jmp 0x3526
cmpl $0x5, %r14d
jne 0x37ac
movq %r15, %rdi
callq 0x20c0
movq 0x5864(%rip), %rdi      # 0x8ff0
leaq 0x30a8(%rip), %rsi      # 0x683b
movl $0x30, %edx
callq 0x2230
movl $0x1, %ebp
callq 0x2370
jmp 0x3526
cmpl $0x4, %r14d
jne 0x37e1
movq %r15, %rdi
callq 0x20c0
movq 0x582f(%rip), %rdi      # 0x8ff0
leaq 0x3035(%rip), %rsi      # 0x67fd
movl $0x3d, %edx
callq 0x2230
movl $0x1, %ebp
callq 0x2370
jmp 0x3526
cmpl $0x3, %r14d
jne 0x3843
movq %r15, %rdi
callq 0x20c0
movq %rax, %rbx
movq 0x57f7(%rip), %rdi      # 0x8ff0
leaq 0x2fd1(%rip), %rsi      # 0x67d1
movl $0x2b, %edx
callq 0x2230
movl (%rbx), %edi
callq 0x2090
movq 0x57d8(%rip), %rdi      # 0x8ff0
movq %rax, %rsi
callq 0x21e0
leaq 0x3083(%rip), %rsi      # 0x68aa
movl $0x1, %edx
movq %rax, %rdi
callq 0x2230
movl $0x1, %ebp
callq 0x2370
jmp 0x3526
cmpl $0x2, %r14d
jne 0x3878
movq %r15, %rdi
callq 0x20c0
movq 0x5798(%rip), %rdi      # 0x8ff0
leaq 0x2f05(%rip), %rsi      # 0x6764
movl $0x1e, %edx
callq 0x2230
movl $0x1, %ebp
callq 0x2370
jmp 0x3526
cmpl $0x1, %r14d
jne 0x36b6
movq %r15, %rdi
callq 0x20c0
movq %rax, %rbx
movq 0x575c(%rip), %rdi      # 0x8ff0
leaq 0x2f28(%rip), %rsi      # 0x67c3
movl $0xd, %edx
callq 0x2230
cmpq $0x0, 0x8(%rbx)
je 0x3907
movq 0x573d(%rip), %rdi      # 0x8ff0
leaq 0x2ea7(%rip), %rsi      # 0x6761
movl $0x2, %edx
callq 0x2230
movq 0x8(%rbx), %rsi
movq 0x5721(%rip), %rdi      # 0x8ff0
callq 0x21e0
cmpq $0x0, 0x18(%rbx)
je 0x3907
movq 0x570e(%rip), %rdi      # 0x8ff0
leaq 0x2e79(%rip), %rsi      # 0x6762
movl $0x1, %edx
callq 0x2230
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdx
movq 0x56ee(%rip), %rdi      # 0x8ff0
callq 0x2230
cmpl $0x0, (%rbx)
je 0x393a
movq 0x56dd(%rip), %rdi      # 0x8ff0
leaq 0x2e47(%rip), %rsi      # 0x6761
movl $0x2, %edx
callq 0x2230
movl (%rbx), %edi
callq 0x2090
movq 0x56be(%rip), %rdi      # 0x8ff0
movq %rax, %rsi
callq 0x21e0
leaq 0x170(%rsp), %rsi
movb $0xa, (%rsi)
movq 0x56a4(%rip), %rdi      # 0x8ff0
movl $0x1, %edx
callq 0x2230
movl $0x1, %ebp
callq 0x2370
jmp 0x3526
jmp 0x3995
jmp 0x36b3
jmp 0x36b3
movq %rax, %r15
callq 0x2370
jmp 0x36b6
jmp 0x36b3
jmp 0x36b3
movq %rax, %r15
callq 0x2370
jmp 0x36b6
movq %rax, %r15
callq 0x2370
jmp 0x36b6
movq %rax, %r15
callq 0x2370
jmp 0x36b6
jmp 0x36b3
movq %rax, %r15
callq 0x2370
jmp 0x36b6
jmp 0x36b3
movq %rax, %r15
callq 0x2370
jmp 0x36b6
movq %rax, %rdi
callq 0x4960
movq %rax, %r15
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x39fb
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2200
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x3a20
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x2200
movq %r15, %rdi
callq 0x23b0