// File: davmac314[P]dinit/src/dinit.cc
// Function: process_commandline_arg(char**, int, int&, options&)
static int process_commandline_arg(char **argv, int argc, int &i, options &opts)
{
    using std::cerr;
    using std::cout;
    using std::endl;
    using std::list;

    const char * &env_file = opts.env_file;
    bool &control_socket_path_set = opts.control_socket_path_set;
    bool &env_file_set = opts.env_file_set;
    bool &log_specified = opts.log_specified;
    service_dir_opt &service_dir_opts = opts.service_dir_opts;
    list<const char *> &services_to_start = opts.services_to_start;

    auto arg_to_loglevel = [&](const char *option_name, loglevel_t &wanted_level) {
        if (++i < argc && argv[i][0] != '\0') {
            if (strcmp(argv[i], "none") == 0) {
                wanted_level = loglevel_t::ZERO;
            }
            else if (strcmp(argv[i], "error") == 0) {
                wanted_level = loglevel_t::ERROR;
            }
            else if (strcmp(argv[i], "warn") == 0) {
                wanted_level = loglevel_t::WARN;
            }
            else if (strcmp(argv[i], "info") == 0) {
                wanted_level = loglevel_t::NOTICE;
            }
            else if (strcmp(argv[i], "debug") == 0) {
                wanted_level = loglevel_t::DEBUG;
            }
            else {
                cerr << "dinit: '" << option_name << "' accepts only arguments: 'none', 'error', 'warn', 'info', 'debug'\n";
                return false;
            }
            return true;
        }
        else {
            cerr << "dinit: '" << option_name << "' requires an argument\n";
            return false;
        }
    };

    if (argv[i][0] == '-') {
        // An option...
        if (strcmp(argv[i], "--env-file") == 0 || strcmp(argv[i], "-e") == 0) {
            if (++i < argc && argv[i][0] != '\0') {
                env_file_set = true;
                env_file = argv[i];
            }
            else {
                cerr << "dinit: '--env-file' (-e) requires an argument\n";
                return 1;
            }
        }
        else if (strcmp(argv[i], "--services-dir") == 0 || strcmp(argv[i], "-d") == 0) {
            if (++i < argc && argv[i][0] != '\0') {
                service_dir_opts.set_specified_service_dir(argv[i]);
            }
            else {
                cerr << "dinit: '--services-dir' (-d) requires an argument\n";
                return 1;
            }
        }
        else if (strcmp(argv[i], "--system") == 0 || strcmp(argv[i], "-s") == 0) {
            am_system_init = true;
        }
        else if (strcmp(argv[i], "--system-mgr") == 0 || strcmp(argv[i], "-m") == 0) {
            am_system_mgr = true;
            opts.process_sys_args = false;
        }
        else if (strcmp(argv[i], "--user") == 0 || strcmp(argv[i], "-u") == 0) {
            am_system_init = false;
        }
        else if (strcmp(argv[i], "--container") == 0 || strcmp(argv[i], "-o") == 0) {
            am_system_mgr = false;
            opts.process_sys_args = false;
        }
        else if (strcmp(argv[i], "--auto-recovery") == 0 || strcmp(argv[i], "-r") == 0) {
            auto_recovery = true;
        }
        else if (strcmp(argv[i], "--socket-path") == 0 || strcmp(argv[i], "-p") == 0) {
            if (++i < argc && argv[i][0] != '\0') {
                control_socket_path = argv[i];
                control_socket_path_set = true;
            }
            else {
                cerr << "dinit: '--socket-path' (-p) requires an argument\n";
                return 1;
            }
        }
        else if (strcmp(argv[i], "--ready-fd") == 0 || strcmp(argv[i], "-F") == 0) {
            if (++i < argc) {
                char *endp = nullptr;
                auto fdn = strtoul(argv[i], &endp, 10);
                if (endp == argv[i] || *endp) {
                    cerr << "dinit: '--ready-fd' (-F) requires a numerical argument\n";
                    return 1;
                }
                socket_ready_fd = int(fdn);
                auto fl = fcntl(socket_ready_fd, F_GETFD);
                // We also want to make sure stdin is not allowed
                if (socket_ready_fd == 0 || fl < 0) {
                    cerr << "dinit: '--ready-fd' (-F) requires an open file descriptor\n";
                    return 1;
                }
                // Leave standard file descriptors alone, but make sure
                // anything else is not leaked to child processes
                if (socket_ready_fd > 2) {
                    fcntl(socket_ready_fd, F_SETFD, FD_CLOEXEC | fl);
                }
            }
            else {
                cerr << "dinit: '--ready-fd' (-F) requires an argument\n";
                return 1;
            }
        }
        else if (strcmp(argv[i], "--log-file") == 0 || strcmp(argv[i], "-l") == 0) {
            if (++i < argc && argv[i][0] != '\0') {
                log_path = argv[i];
                log_is_syslog = false;
                log_specified = true;
            }
            else {
                cerr << "dinit: '--log-file' (-l) requires an argument\n";
                return 1;
            }
        }
        else if (strcmp(argv[i], "--quiet") == 0 || strcmp(argv[i], "-q") == 0) {
            console_service_status = false;
            log_level[DLOG_CONS] = loglevel_t::ZERO;
        }
        else if (strcmp(argv[i], "--console-level") == 0) {
            loglevel_t wanted_level;
            if (!arg_to_loglevel("--console-level", wanted_level)) return 1;
            log_level[DLOG_CONS] = wanted_level;
        }
        else if (strcmp(argv[i], "--log-level") == 0) {
            loglevel_t wanted_level;
            if (!arg_to_loglevel("--log-level", wanted_level)) return 1;
            log_level[DLOG_MAIN] = wanted_level;
        }
        #if SUPPORT_CGROUPS
        else if (strcmp(argv[i], "--cgroup-path") == 0 || strcmp(argv[i], "-b") == 0) {
            if (++i < argc && argv[i][0] != '\0') {
                cgroups_path = argv[i];
                have_cgroups_path = true;
            }
            else {
                cerr << "dinit: '--cgroup-path' (-b) requires an argument\n";
                return 1;
            }
        }
        #endif
        else if (strcmp(argv[i], "--service") == 0 || strcmp(argv[i], "-t") == 0) {
            if (++i < argc && argv[i][0] != '\0') {
                services_to_start.push_back(argv[i]);
            }
            else {
                cerr << "dinit: '--service' (-t) requires an argument\n";
                return 1;
            }
        }
        else if (strcmp(argv[i], "--version") == 0) {
            printVersion();
            return -1;
        }
        else if (strcmp(argv[i], "--help") == 0) {
            cout << "dinit: init/service manager daemon\n"
                    " --help                       display (this) help\n"
                    " --version                    display version\n"
                    " --env-file <file>, -e <file>\n"
                    "                              environment variable initialisation file\n"
                    " --services-dir <dir>, -d <dir>\n"
                    "                              set base directory for service description\n"
                    "                              files, can be specified multiple times\n"
                    " --system, -s                 run as the system service manager\n"
                    " --system-mgr, -m             run as system manager (perform shutdown etc)\n"
                    " --user, -u                   run as a user service manager\n"
                    " --container, -o              run in container mode (do not manage system)\n"
                    " --auto-recovery, -r          auto-run recovery service on system manager boot failure\n"
                    " --socket-path <path>, -p <path>\n"
                    "                              path to control socket\n"
                    " --ready-fd <fd>, -F <fd>\n"
                    "                              file descriptor to report readiness\n"
                    #if SUPPORT_CGROUPS
                    " --cgroup-path <path>, -b <path>\n"
                    "                              cgroup base path (for resolving relative paths)\n"
                    #endif
                    " --log-file <file>, -l <file> log to the specified file\n"
                    " --quiet, -q                  disable output to standard output\n"
                    " <service-name>, --service <service-name>, -t <service-name>\n"
                    "                              start service with name <service-name>\n";
            return -1;
        }
        else {
            // unrecognized
            if (!opts.process_sys_args) {
                cerr << "dinit: unrecognized option: " << argv[i] << endl;
                return 1;
            }
        }
    }
    else {
        if (argv[i][0] == '\0') {
            cerr << "dinit: error: empty command-line argument\n";
            return 1;
        }
#ifdef __linux__
        // If we are running as init (PID=1), the Linux kernel gives us all command line arguments it was
        // given but didn't recognize, and, uh, *some* that it did recognize, which means we can't assume
        // that anything is a service name (for example "nopti" seems to get passed through to init).
        // However, we can look for special names that we know aren't kernel parameters, such as "single".
        //
        // (Note this may have been fixed in recent kernels: see changelog for 5.15.46/5.18.3,
        // "x86: Fix return value of __setup handlers")
        //
        // LILO puts "auto" on the command line for unattended boots, but we don't care about that and want
        // it filtered.
        //
        // We don't expect to see options beginning with '-' appear on the kernel command line either, so we
        // can interpret those as dinit arguments. In particular if we see -m or -o, we assume that every
        // name we see from then is a service name (i.e. process_sys_args is set false when we seem them,
        // see above).
        //
        // (Note, you can give "--" on the kernel command line to pass every option from that point to init
        // directly, but init doesn't see the "--" itself, which makes it less useful, since we still can't
        // tell whether a "name" was intended as a kernel parameter or init parameter).

        // So, long story short: if we think we're PID 1 and we haven't seen -m or -c options yet, only
        // recognise "single" as a service name and ignore everything else.

        if (!opts.process_sys_args || strcmp(argv[i], "single") == 0) {
            services_to_start.push_back(argv[i]);
        }
#else
        services_to_start.push_back(argv[i]);
#endif
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
addq $0x9, %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
addq $0xa, %rax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq -0x14(%rbp), %rax
movq %rax, -0x68(%rbp)
leaq -0x10(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0xcc60
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69ec6(%rip), %rsi     # 0x7625d
callq 0xaa50
cmpl $0x0, %eax
je 0xc3c1
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69eb1(%rip), %rsi     # 0x76268
callq 0xaa50
cmpl $0x0, %eax
jne 0xc42b
movq -0x20(%rbp), %rcx
movl (%rcx), %eax
addl $0x1, %eax
movl %eax, (%rcx)
cmpl -0x14(%rbp), %eax
jge 0xc407
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xc407
movq -0x40(%rbp), %rax
movb $0x1, (%rax)
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
jmp 0xc426
movq 0x9bbda(%rip), %rdi     # 0xa7fe8
leaq 0x69e56(%rip), %rsi     # 0x7626b
callq 0xa6e0
movl $0x1, -0x4(%rbp)
jmp 0xcce1
jmp 0xcc5e
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69e59(%rip), %rsi     # 0x7629a
callq 0xaa50
cmpl $0x0, %eax
je 0xc46b
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69e48(%rip), %rsi     # 0x762a9
callq 0xaa50
cmpl $0x0, %eax
jne 0xc4d0
movq -0x20(%rbp), %rcx
movl (%rcx), %eax
addl $0x1, %eax
movl %eax, (%rcx)
cmpl -0x14(%rbp), %eax
jge 0xc4ac
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xc4ac
movq -0x50(%rbp), %rdi
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x15790
jmp 0xc4cb
movq 0x9bb35(%rip), %rdi     # 0xa7fe8
leaq 0x69df2(%rip), %rsi     # 0x762ac
callq 0xa6e0
movl $0x1, -0x4(%rbp)
jmp 0xcce1
jmp 0xcc5c
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69cd3(%rip), %rsi     # 0x761b9
callq 0xaa50
cmpl $0x0, %eax
je 0xc510
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69dd9(%rip), %rsi     # 0x762df
callq 0xaa50
cmpl $0x0, %eax
jne 0xc51c
movb $0x1, 0x9c92a(%rip)     # 0xa8e41
jmp 0xcc5a
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69db0(%rip), %rsi     # 0x762e2
callq 0xaa50
cmpl $0x0, %eax
je 0xc55c
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69d9d(%rip), %rsi     # 0x762ef
callq 0xaa50
cmpl $0x0, %eax
jne 0xc570
movb $0x1, 0x9c8dd(%rip)     # 0xa8e40
movq -0x28(%rbp), %rax
movb $0x0, 0xb(%rax)
jmp 0xcc58
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69d6c(%rip), %rsi     # 0x762f2
callq 0xaa50
cmpl $0x0, %eax
je 0xc5b0
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69d53(%rip), %rsi     # 0x762f9
callq 0xaa50
cmpl $0x0, %eax
jne 0xc5bc
movb $0x0, 0x9c88a(%rip)     # 0xa8e41
jmp 0xcc56
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69d2a(%rip), %rsi     # 0x762fc
callq 0xaa50
cmpl $0x0, %eax
je 0xc5fc
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69d16(%rip), %rsi     # 0x76308
callq 0xaa50
cmpl $0x0, %eax
jne 0xc610
movb $0x0, 0x9c83d(%rip)     # 0xa8e40
movq -0x28(%rbp), %rax
movb $0x0, 0xb(%rax)
jmp 0xcc54
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69ce5(%rip), %rsi     # 0x7630b
callq 0xaa50
cmpl $0x0, %eax
je 0xc650
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69b6a(%rip), %rsi     # 0x761b0
callq 0xaa50
cmpl $0x0, %eax
jne 0xc65c
movb $0x1, 0x9c7f9(%rip)     # 0xa8e50
jmp 0xcc52
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69ca9(%rip), %rsi     # 0x7631b
callq 0xaa50
cmpl $0x0, %eax
je 0xc69c
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69b24(%rip), %rsi     # 0x761b6
callq 0xaa50
cmpl $0x0, %eax
jne 0xc706
movq -0x20(%rbp), %rcx
movl (%rcx), %eax
addl $0x1, %eax
movl %eax, (%rcx)
cmpl -0x14(%rbp), %eax
jge 0xc6e2
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xc6e2
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x9c037(%rip)     # 0xa8710
movq -0x38(%rbp), %rax
movb $0x1, (%rax)
jmp 0xc701
movq 0x9b8ff(%rip), %rdi     # 0xa7fe8
leaq 0x69c39(%rip), %rsi     # 0x76329
callq 0xa6e0
movl $0x1, -0x4(%rbp)
jmp 0xcce1
jmp 0xcc50
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69c3f(%rip), %rsi     # 0x7635b
callq 0xaa50
cmpl $0x0, %eax
je 0xc74a
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69c2a(%rip), %rsi     # 0x76366
callq 0xaa50
cmpl $0x0, %eax
jne 0xc861
movq -0x20(%rbp), %rcx
movl (%rcx), %eax
addl $0x1, %eax
movl %eax, (%rcx)
cmpl -0x14(%rbp), %eax
jge 0xc83d
movq $0x0, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq -0x78(%rbp), %rsi
movl $0xa, %edx
callq 0xa1d0
movq %rax, -0x80(%rbp)
movq -0x78(%rbp), %rax
movq -0x10(%rbp), %rcx
movq -0x20(%rbp), %rdx
movslq (%rdx), %rdx
cmpq (%rcx,%rdx,8), %rax
je 0xc7a5
movq -0x78(%rbp), %rax
cmpb $0x0, (%rax)
je 0xc7c4
movq 0x9b83c(%rip), %rdi     # 0xa7fe8
leaq 0x69bb6(%rip), %rsi     # 0x76369
callq 0xa6e0
movl $0x1, -0x4(%rbp)
jmp 0xcce1
movq -0x80(%rbp), %rax
movl %eax, 0x9bf32(%rip)     # 0xa8700
movl 0x9bf2c(%rip), %edi     # 0xa8700
movl $0x1, %esi
movb $0x0, %al
callq 0xa3f0
movl %eax, -0x84(%rbp)
cmpl $0x0, 0x9bf13(%rip)     # 0xa8700
je 0xc7f8
cmpl $0x0, -0x84(%rbp)
jge 0xc817
movq 0x9b7e9(%rip), %rdi     # 0xa7fe8
leaq 0x69b9b(%rip), %rsi     # 0x763a1
callq 0xa6e0
movl $0x1, -0x4(%rbp)
jmp 0xcce1
cmpl $0x2, 0x9bee2(%rip)     # 0xa8700
jle 0xc83b
movl 0x9beda(%rip), %edi     # 0xa8700
movl -0x84(%rbp), %edx
orl $0x1, %edx
movl $0x2, %esi
movb $0x0, %al
callq 0xa3f0
jmp 0xc85c
movq 0x9b7a4(%rip), %rdi     # 0xa7fe8
leaq 0x69b91(%rip), %rsi     # 0x763dc
callq 0xa6e0
movl $0x1, -0x4(%rbp)
jmp 0xcce1
jmp 0xcc4e
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69b94(%rip), %rsi     # 0x7640b
callq 0xaa50
cmpl $0x0, %eax
je 0xc8a1
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69b7f(%rip), %rsi     # 0x76416
callq 0xaa50
cmpl $0x0, %eax
jne 0xc912
movq -0x20(%rbp), %rcx
movl (%rcx), %eax
addl $0x1, %eax
movl %eax, (%rcx)
cmpl -0x14(%rbp), %eax
jge 0xc8ee
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xc8ee
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x9be42(%rip)     # 0xa8720
movb $0x0, 0x9be33(%rip)     # 0xa8718
movq -0x48(%rbp), %rax
movb $0x1, (%rax)
jmp 0xc90d
movq 0x9b6f3(%rip), %rdi     # 0xa7fe8
leaq 0x69b1d(%rip), %rsi     # 0x76419
callq 0xa6e0
movl $0x1, -0x4(%rbp)
jmp 0xcce1
jmp 0xcc4c
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69b20(%rip), %rsi     # 0x76448
callq 0xaa50
cmpl $0x0, %eax
je 0xc952
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69b08(%rip), %rsi     # 0x76450
callq 0xaa50
cmpl $0x0, %eax
jne 0xc96f
leaq 0x9bea7(%rip), %rax     # 0xa8800
movb $0x0, (%rax)
leaq 0x9be95(%rip), %rax     # 0xa87f8
movl $0x4, 0x4(%rax)
jmp 0xcc4a
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69ace(%rip), %rsi     # 0x76453
callq 0xaa50
cmpl $0x0, %eax
jne 0xc9cb
leaq -0x70(%rbp), %rdi
leaq 0x69ab9(%rip), %rsi     # 0x76453
leaq -0x88(%rbp), %rdx
callq 0xe6f0
testb $0x1, %al
jne 0xc9b6
movl $0x1, -0x4(%rbp)
jmp 0xcce1
movl -0x88(%rbp), %ecx
leaq 0x9be35(%rip), %rax     # 0xa87f8
movl %ecx, 0x4(%rax)
jmp 0xcc48
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69a82(%rip), %rsi     # 0x76463
callq 0xaa50
cmpl $0x0, %eax
jne 0xca26
leaq -0x70(%rbp), %rdi
leaq 0x69a6d(%rip), %rsi     # 0x76463
leaq -0x8c(%rbp), %rdx
callq 0xe6f0
testb $0x1, %al
jne 0xca12
movl $0x1, -0x4(%rbp)
jmp 0xcce1
movl -0x8c(%rbp), %ecx
leaq 0x9bdd9(%rip), %rax     # 0xa87f8
movl %ecx, (%rax)
jmp 0xcc46
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69a33(%rip), %rsi     # 0x7646f
callq 0xaa50
cmpl $0x0, %eax
je 0xca66
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69a21(%rip), %rsi     # 0x7647d
callq 0xaa50
cmpl $0x0, %eax
jne 0xcad5
movq -0x20(%rbp), %rcx
movl (%rcx), %eax
addl $0x1, %eax
movl %eax, (%rcx)
cmpl -0x14(%rbp), %eax
jge 0xcab1
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xcab1
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0x9c2cd(%rip), %rdi     # 0xa8d70
callq 0xaa00
movb $0x1, 0x9c2e1(%rip)     # 0xa8d90
jmp 0xcad0
movq 0x9b530(%rip), %rdi     # 0xa7fe8
leaq 0x699c1(%rip), %rsi     # 0x76480
callq 0xa6e0
movl $0x1, -0x4(%rbp)
jmp 0xcce1
jmp 0xcc44
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x699c7(%rip), %rsi     # 0x764b2
callq 0xaa50
cmpl $0x0, %eax
je 0xcb15
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x699b1(%rip), %rsi     # 0x764bc
callq 0xaa50
cmpl $0x0, %eax
jne 0xcb7d
movq -0x20(%rbp), %rcx
movl (%rcx), %eax
addl $0x1, %eax
movl %eax, (%rcx)
cmpl -0x14(%rbp), %eax
jge 0xcb59
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xcb59
movq -0x58(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rax
movslq (%rax), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x157c0
jmp 0xcb78
movq 0x9b488(%rip), %rdi     # 0xa7fe8
leaq 0x69958(%rip), %rsi     # 0x764bf
callq 0xa6e0
movl $0x1, -0x4(%rbp)
jmp 0xcce1
jmp 0xcc42
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x6995a(%rip), %rsi     # 0x764ed
callq 0xaa50
cmpl $0x0, %eax
jne 0xcbae
callq 0xe8d0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xcce1
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69933(%rip), %rsi     # 0x764f7
callq 0xaa50
cmpl $0x0, %eax
jne 0xcbed
movq 0x9b393(%rip), %rdi     # 0xa7f68
leaq 0x69922(%rip), %rsi     # 0x764fe
callq 0xa6e0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xcce1
movq -0x28(%rbp), %rax
testb $0x1, 0xb(%rax)
jne 0xcc3c
movq 0x9b3ea(%rip), %rdi     # 0xa7fe8
leaq 0x69e14(%rip), %rsi     # 0x76a19
callq 0xa6e0
movq %rax, %rdi
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rsi
callq 0xa6e0
movq %rax, %rdi
movq 0x9b2f5(%rip), %rsi     # 0xa7f20
callq 0xa750
movl $0x1, -0x4(%rbp)
jmp 0xcce1
jmp 0xcc3e
jmp 0xcc40
jmp 0xcc42
jmp 0xcc44
jmp 0xcc46
jmp 0xcc48
jmp 0xcc4a
jmp 0xcc4c
jmp 0xcc4e
jmp 0xcc50
jmp 0xcc52
jmp 0xcc54
jmp 0xcc56
jmp 0xcc58
jmp 0xcc5a
jmp 0xcc5c
jmp 0xcc5e
jmp 0xccda
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0xcc93
movq 0x9b36a(%rip), %rdi     # 0xa7fe8
leaq 0x69db1(%rip), %rsi     # 0x76a36
callq 0xa6e0
movl $0x1, -0x4(%rbp)
jmp 0xcce1
movq -0x28(%rbp), %rax
testb $0x1, 0xb(%rax)
je 0xccbd
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x69dae(%rip), %rsi     # 0x76a61
callq 0xaa50
cmpl $0x0, %eax
jne 0xccd8
movq -0x58(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rax
movslq (%rax), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x157c0
jmp 0xccda
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)