// File: davmac314[P]dinit/src/baseproc-service.cc
// Function: base_process_service::start_ps_process(std::vector<char const*, std::allocator<char const*>> const&, bool)
bool base_process_service::start_ps_process(const std::vector<const char *> &cmd, bool on_console) noexcept
{
    // In general, you can't tell whether fork/exec is successful. We use a pipe to communicate
    // success/failure from the child to the parent. The pipe is set CLOEXEC so a successful
    // exec closes the pipe, and the parent sees EOF. If the exec is unsuccessful, the errno
    // is written to the pipe, and the parent can read it.

    event_loop.get_time(last_start_time, clock_type::MONOTONIC);

    int pipefd[2];
    if (bp_sys::pipe2(pipefd, O_CLOEXEC)) {
        log(loglevel_t::ERROR, get_name(), ": can't create status check pipe: ", strerror(errno));
        return false;
    }

    int input_fd;
    if (!get_input_fd(&input_fd)) {
        return false;
    }

    const char * logfile = this->logfile.c_str();
    if (this->log_type == log_type_id::LOGFILE || this->log_type == log_type_id::NONE) {
        // Note: if log_type == NONE, logfile should be empty.
        if (*logfile == 0) {
            logfile = "/dev/null";
        }
    }
    else /* log_type_id::BUFFER or ::PIPE */ {
        if (this->log_output_fd == -1) {
            int logfd[2];
            // Note: we set CLOEXEC on the file descriptors here; when the output file descriptor is dup'd
            // to stdout, this will be effectively removed for the output end
            if (bp_sys::pipe2(logfd, O_CLOEXEC)) {
                log(loglevel_t::ERROR, get_name(), ": can't create output pipe: ", strerror(errno));
                goto out_p;
            }
            this->log_input_fd = logfd[0];
            this->log_output_fd = logfd[1];
            if (this->log_type == log_type_id::BUFFER) {
                try {
                    this->log_output_listener.add_watch(event_loop, logfd[0], dasynq::IN_EVENTS,
                            false /* not enabled */);
                }
                catch (...) {
                    log(loglevel_t::ERROR, get_name(), ": can't add output watch (insufficient resources)");
                    bp_sys::close(this->log_input_fd);
                    bp_sys::close(this->log_output_fd);
                    this->log_input_fd = -1;
                    this->log_output_fd = -1;
                    goto out_p;
                }
            }
        }
        // (More is done below, after we have performed additional setup)
    }

    {
        bool child_status_registered = false;
        control_conn_t *control_conn = nullptr;

        int control_socket[2] = {-1, -1};
        int notify_pipe[2] = {-1, -1};
        bool have_notify = !notification_var.empty() || force_notification_fd != -1;
        ready_notify_watcher * rwatcher = have_notify ? get_ready_watcher() : nullptr;
        bool ready_watcher_registered = false;

        if (onstart_flags.pass_cs_fd) {
            if (dinit_socketpair(AF_UNIX, SOCK_STREAM, /* protocol */ 0, control_socket, SOCK_NONBLOCK)) {
                log(loglevel_t::ERROR, get_name(), ": can't create control socket: ", strerror(errno));
                goto out_lfd;
            }

            // Make the server side socket close-on-exec:
            int fdflags = bp_sys::fcntl(control_socket[0], F_GETFD);
            bp_sys::fcntl(control_socket[0], F_SETFD, fdflags | FD_CLOEXEC);

            try {
                control_conn = new control_conn_t(event_loop, services, control_socket[0]);
            }
            catch (std::exception &exc) {
                log(loglevel_t::ERROR, get_name(), ": can't launch process; out of memory");
                goto out_cs;
            }
        }

        if (have_notify) {
            // Create a notification pipe:
            if (bp_sys::pipe2(notify_pipe, 0) != 0) {
                log(loglevel_t::ERROR, get_name(), ": can't create notification pipe: ", strerror(errno));
                goto out_cs_h;
            }

            // Set the read side as close-on-exec:
            int fdflags = bp_sys::fcntl(notify_pipe[0], F_GETFD);
            bp_sys::fcntl(notify_pipe[0], F_SETFD, fdflags | FD_CLOEXEC);

            // add, but don't yet enable, readiness watcher:
            try {
                rwatcher->add_watch(event_loop, notify_pipe[0], dasynq::IN_EVENTS, false);
                ready_watcher_registered = true;
            }
            catch (std::exception &exc) {
                log(loglevel_t::ERROR, get_name(), ": can't add notification watch: ", exc.what());
                goto out_cs_h;
            }
        }

        if (log_type == log_type_id::BUFFER) {
            // Set watcher enabled if space in buffer
            if (log_buf_size > 0) {
                // Append a "restarted" message to buffer contents
                const char *restarting_msg = "\n(dinit: note: service restarted)\n";
                unsigned restarting_msg_len = strlen(restarting_msg);
                bool trailing_nl = log_buffer[log_buf_size - 1] == '\n';
                if (trailing_nl) {
                    ++restarting_msg; // trim leading newline
                    --restarting_msg_len;
                }
                if (log_buf_size + restarting_msg_len >= log_buf_max) {
                    goto skip_enable_log_watch;
                }
                if (!ensure_log_buffer_backing(log_buf_size + restarting_msg_len)) {
                    goto skip_enable_log_watch;
                }
                memcpy(log_buffer.data() + log_buf_size, restarting_msg, restarting_msg_len);
                log_buf_size += restarting_msg_len;
            }
            log_output_listener.set_enabled(event_loop, true);
        }
        skip_enable_log_watch: ;

        // Set up complete, now fork and exec:

        pid_t forkpid;

        try {
            child_status_listener.add_watch(event_loop, pipefd[0], dasynq::IN_EVENTS);
            child_status_registered = true;

            // We specify a high priority (i.e. low priority value) so that process termination is
            // handled early. This means we have always recorded that the process is terminated by the
            // time that we handle events that might otherwise cause us to signal the process, so we
            // avoid sending a signal to an invalid (and possibly recycled) process ID.
            forkpid = child_listener.fork(event_loop, reserved_child_watch, dasynq::DEFAULT_PRIORITY - 10);
            reserved_child_watch = true;
        }
        catch (std::exception &e) {
            log(loglevel_t::ERROR, get_name(), ": could not fork: ", e.what());
            goto out_cs_h;
        }

        if (forkpid == 0) {
            const char * working_dir_c = service_dsc_dir;
            if (!working_dir.empty()) working_dir_c = working_dir.c_str();
            after_fork(getpid());
            run_proc_params run_params{cmd.data(), working_dir_c, logfile, pipefd[1], run_as_uid, run_as_gid, rlimits};
            run_params.on_console = on_console;
            run_params.in_foreground = !onstart_flags.shares_console;
            run_params.unmask_sigint = onstart_flags.unmask_intr;
            run_params.csfd = control_socket[1];
            run_params.socket_fd = socket_fd;
            run_params.notify_fd = notify_pipe[1];
            run_params.force_notify_fd = force_notification_fd;
            run_params.notify_var = notification_var.c_str();
            run_params.env_file = env_file.c_str();
            run_params.output_fd = log_output_fd;
            run_params.input_fd = input_fd;
            run_params.nice_is_set = nice_is_set;
            run_params.nice = nice;
            #if SUPPORT_CGROUPS
            run_params.run_in_cgroup = run_in_cgroup.c_str();
            #endif
            #if SUPPORT_CAPABILITIES
            run_params.cap_iab = cap_iab.get();
            run_params.secbits = secbits;
            run_params.no_new_privs = onstart_flags.no_new_privs;
            #endif
            #if SUPPORT_IOPRIO
            run_params.ioprio = ioprio;
            #endif
            #if SUPPORT_OOM_ADJ
            run_params.oom_adj_is_set = oom_adj_is_set;
            run_params.oom_adj = oom_adj;
            #endif
            run_child_proc(run_params);
        }
        else {
            // Parent process
            pid = forkpid;

            bp_sys::close(pipefd[1]); // close the 'other end' fd
            if (control_socket[1] != -1) bp_sys::close(control_socket[1]);
            if (notify_pipe[1] != -1) bp_sys::close(notify_pipe[1]);
            notification_fd = notify_pipe[0];
            waiting_for_execstat = true;
            return true;
        }

        // Failure exit:

        out_cs_h:
        if (child_status_registered) {
            child_status_listener.deregister(event_loop);
        }

        if (notify_pipe[0] != -1) bp_sys::close(notify_pipe[0]);
        if (notify_pipe[1] != -1) bp_sys::close(notify_pipe[1]);
        if (ready_watcher_registered) {
            rwatcher->deregister(event_loop);
        }

        if (onstart_flags.pass_cs_fd) {
            delete control_conn;

            out_cs:
            bp_sys::close(control_socket[0]);
            bp_sys::close(control_socket[1]);
        }
    }

    out_lfd:
    if (log_input_fd != -1) {
        log_output_listener.deregister(event_loop);
        bp_sys::close(log_input_fd);
        bp_sys::close(log_output_fd);
        log_input_fd = -1;
        log_output_fd = -1;
    }

    out_p:
    bp_sys::close(pipefd[0]);
    bp_sys::close(pipefd[1]);

    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2d0, %rsp            # imm = 0x2D0
movb %dl, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
movq -0x10(%rbp), %rsi
movq %rsi, -0x1e8(%rbp)
addq $0x438, %rsi            # imm = 0x438
leaq 0x5372d(%rip), %rdi     # 0xa8b60
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x53720
leaq -0x24(%rbp), %rdi
movl $0x80000, %esi          # imm = 0x80000
callq 0xa490
cmpl $0x0, %eax
je 0x5549a
movq -0x1e8(%rbp), %rdi
callq 0x2d420
movq %rax, -0x1f0(%rbp)
callq 0xa060
movl (%rax), %edi
callq 0xa1f0
movq -0x1f0(%rbp), %rsi
movq %rax, -0x30(%rbp)
movl $0x3, %edi
leaq 0x23971(%rip), %rdx     # 0x78df9
leaq -0x30(%rbp), %rcx
callq 0x56110
movb $0x0, -0x1(%rbp)
jmp 0x56052
movq -0x1e8(%rbp), %rdi
movq (%rdi), %rax
leaq -0x34(%rbp), %rsi
callq *0x80(%rax)
testb $0x1, %al
jne 0x554bb
movb $0x0, -0x1(%rbp)
jmp 0x56052
movq -0x1e8(%rbp), %rdi
addq $0x2a0, %rdi            # imm = 0x2A0
callq 0xa250
movq %rax, %rcx
movq -0x1e8(%rbp), %rax
movq %rcx, -0x40(%rbp)
cmpl $0x1, 0x298(%rax)
je 0x554f5
movq -0x1e8(%rbp), %rax
cmpl $0x0, 0x298(%rax)
jne 0x55511
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x5550c
leaq 0x23706(%rip), %rax     # 0x78c0e
movq %rax, -0x40(%rbp)
jmp 0x55665
movq -0x1e8(%rbp), %rax
cmpl $-0x1, 0x4ec(%rax)
jne 0x55663
leaq -0x48(%rbp), %rdi
movl $0x80000, %esi          # imm = 0x80000
callq 0xa490
cmpl $0x0, %eax
je 0x5557c
movq -0x1e8(%rbp), %rdi
callq 0x2d420
movq %rax, -0x1f8(%rbp)
callq 0xa060
movl (%rax), %edi
callq 0xa1f0
movq -0x1f8(%rbp), %rsi
movq %rax, -0x50(%rbp)
movl $0x3, %edi
leaq 0x238ae(%rip), %rdx     # 0x78e1c
leaq -0x50(%rbp), %rcx
callq 0x56150
jmp 0x5603a
movq -0x1e8(%rbp), %rax
movl -0x48(%rbp), %ecx
movl %ecx, 0x4f0(%rax)
movl -0x44(%rbp), %ecx
movl %ecx, 0x4ec(%rax)
cmpl $0x2, 0x298(%rax)
jne 0x55661
movq -0x1e8(%rbp), %rdi
addq $0x408, %rdi            # imm = 0x408
movl -0x48(%rbp), %edx
leaq 0x535a6(%rip), %rsi     # 0xa8b60
movl $0x1, %ecx
xorl %r8d, %r8d
movl $0x32, %r9d
callq 0xf690
jmp 0x555cf
jmp 0x5565f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
movq -0x58(%rbp), %rdi
callq 0xa240
movq -0x1e8(%rbp), %rdi
callq 0x2d420
movq %rax, %rsi
leaq 0x2383a(%rip), %rdx     # 0x78e39
movl $0x3, %edi
callq 0x56190
movq -0x1e8(%rbp), %rax
movl 0x4f0(%rax), %edi
callq 0xad80
jmp 0x5561d
movq -0x1e8(%rbp), %rax
movl 0x4ec(%rax), %edi
callq 0xad80
jmp 0x55631
movq -0x1e8(%rbp), %rax
movl $0xffffffff, 0x4f0(%rax) # imm = 0xFFFFFFFF
movl $0xffffffff, 0x4ec(%rax) # imm = 0xFFFFFFFF
movl $0x2, -0x60(%rbp)
callq 0xac30
jmp 0x5565a
jmp 0x5603a
jmp 0x55661
jmp 0x55663
jmp 0x55665
movq -0x1e8(%rbp), %rdi
movb $0x0, -0x61(%rbp)
movq $0x0, -0x70(%rbp)
movq 0x23a89(%rip), %rax     # 0x79108
movq %rax, -0x78(%rbp)
movq 0x23a7e(%rip), %rax     # 0x79108
movq %rax, -0x80(%rbp)
addq $0x4b8, %rdi            # imm = 0x4B8
callq 0xac70
movb %al, %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x1f9(%rbp)
jne 0x556ab
jmp 0x556c2
movq -0x1e8(%rbp), %rax
cmpl $-0x1, 0x4b0(%rax)
setne %al
movb %al, -0x1f9(%rbp)
movb -0x1f9(%rbp), %al
andb $0x1, %al
movb %al, -0x81(%rbp)
testb $0x1, -0x81(%rbp)
je 0x556f2
movq -0x1e8(%rbp), %rdi
movq (%rdi), %rax
callq *0x90(%rax)
movq %rax, -0x208(%rbp)
jmp 0x556fd
xorl %eax, %eax
movq %rax, -0x208(%rbp)
jmp 0x556fd
movq -0x1e8(%rbp), %rax
movq -0x208(%rbp), %rcx
movq %rcx, -0x90(%rbp)
movb $0x0, -0x91(%rbp)
movw 0x2e(%rax), %ax
shrw $0x6, %ax
andw $0x1, %ax
testw $0x1, %ax
je 0x558a7
movl $0x1, %esi
xorl %edx, %edx
leaq -0x78(%rbp), %rcx
movl $0x800, %r8d            # imm = 0x800
movl %esi, %edi
callq 0x561c0
movl %eax, -0x20c(%rbp)
jmp 0x5574f
movl -0x20c(%rbp), %eax
cmpl $0x0, %eax
je 0x557a4
movq -0x1e8(%rbp), %rdi
callq 0x2d420
movq %rax, -0x218(%rbp)
callq 0xa060
movl (%rax), %edi
callq 0xa1f0
movq -0x218(%rbp), %rsi
movq %rax, -0xa0(%rbp)
movl $0x3, %edi
leaq 0x236d8(%rip), %rdx     # 0x78e6b
leaq -0xa0(%rbp), %rcx
callq 0x56200
jmp 0x55fcb
movl -0x78(%rbp), %edi
xorl %eax, %eax
movl $0x1, %esi
callq 0xa3f0
movl %eax, -0x21c(%rbp)
jmp 0x557bb
movl -0x21c(%rbp), %eax
movl %eax, -0xa4(%rbp)
movl -0x78(%rbp), %edi
movl -0xa4(%rbp), %edx
orl $0x1, %edx
xorl %eax, %eax
movl $0x2, %esi
callq 0xa3f0
jmp 0x557e1
movl $0x510, %edi            # imm = 0x510
callq 0xa700
movq %rax, -0x228(%rbp)
jmp 0x557f4
movq -0x228(%rbp), %rdi
movq -0x1e8(%rbp), %rax
movq 0x148(%rax), %rdx
movl -0x78(%rbp), %ecx
leaq 0x5334d(%rip), %rsi     # 0xa8b60
callq 0x11200
jmp 0x5581a
movq -0x228(%rbp), %rax
movq %rax, -0x70(%rbp)
jmp 0x558a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x55852
movq -0x228(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
movl $0x510, %esi            # imm = 0x510
callq 0xa720
movl -0x5c(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x56068
movq -0x58(%rbp), %rdi
callq 0xa240
movq -0x1e8(%rbp), %rdi
movq %rax, -0xb0(%rbp)
callq 0x2d420
movq %rax, %rsi
leaq 0x23603(%rip), %rdx     # 0x78e8b
movl $0x3, %edi
callq 0x56240
movl $0x4, -0x60(%rbp)
callq 0xac30
jmp 0x558a0
jmp 0x55fb3
jmp 0x558a7
testb $0x1, -0x81(%rbp)
je 0x55a07
leaq -0x80(%rbp), %rdi
xorl %esi, %esi
callq 0xa490
cmpl $0x0, %eax
je 0x5590e
movq -0x1e8(%rbp), %rdi
callq 0x2d420
movq %rax, -0x230(%rbp)
callq 0xa060
movl (%rax), %edi
callq 0xa1f0
movq -0x230(%rbp), %rsi
movq %rax, -0xb8(%rbp)
movl $0x3, %edi
leaq 0x235b4(%rip), %rdx     # 0x78eb1
leaq -0xb8(%rbp), %rcx
callq 0x56110
jmp 0x55f1a
movl -0x80(%rbp), %edi
xorl %eax, %eax
movl $0x1, %esi
callq 0xa3f0
movl %eax, -0x234(%rbp)
jmp 0x55925
movl -0x234(%rbp), %eax
movl %eax, -0xbc(%rbp)
movl -0x80(%rbp), %edi
movl -0xbc(%rbp), %edx
orl $0x1, %edx
xorl %eax, %eax
movl $0x2, %esi
callq 0xa3f0
jmp 0x5594b
movq -0x90(%rbp), %rdi
movl -0x80(%rbp), %edx
leaq 0x53204(%rip), %rsi     # 0xa8b60
movl $0x1, %ecx
xorl %r8d, %r8d
movl $0x32, %r9d
callq 0xf690
jmp 0x55971
movb $0x1, -0x91(%rbp)
jmp 0x55a05
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x56068
movq -0x58(%rbp), %rdi
callq 0xa240
movq -0x1e8(%rbp), %rdi
movq %rax, -0xc8(%rbp)
callq 0x2d420
movq %rax, -0x240(%rbp)
movq -0xc8(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq -0x240(%rbp), %rsi
movq %rax, -0xd0(%rbp)
leaq 0x234f3(%rip), %rdx     # 0x78ed4
movl $0x3, %edi
leaq -0xd0(%rbp), %rcx
callq 0x56270
movl $0x5, -0x60(%rbp)
callq 0xac30
jmp 0x55a00
jmp 0x55f1a
jmp 0x55a07
movq -0x1e8(%rbp), %rax
cmpl $0x2, 0x298(%rax)
jne 0x55b60
movq -0x1e8(%rbp), %rax
cmpl $0x0, 0x2d0(%rax)
jbe 0x55b41
leaq 0x234bf(%rip), %rax     # 0x78ef5
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rdi
callq 0xa280
movq %rax, %rcx
movq -0x1e8(%rbp), %rax
movl %ecx, -0xdc(%rbp)
movq %rax, %rdi
addq $0x2d8, %rdi            # imm = 0x2D8
movl 0x2d0(%rax), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x18f40
movsbl (%rax), %eax
cmpl $0xa, %eax
sete %al
andb $0x1, %al
movb %al, -0xdd(%rbp)
testb $0x1, -0xdd(%rbp)
je 0x55ab0
movq -0xd8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xd8(%rbp)
movl -0xdc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xdc(%rbp)
movq -0x1e8(%rbp), %rcx
movl 0x2d0(%rcx), %eax
addl -0xdc(%rbp), %eax
cmpl 0x2cc(%rcx), %eax
jb 0x55ad0
jmp 0x55b62
movq -0x1e8(%rbp), %rdi
movl 0x2d0(%rdi), %esi
addl -0xdc(%rbp), %esi
callq 0x562b0
testb $0x1, %al
jne 0x55aee
jmp 0x55b62
movq -0x1e8(%rbp), %rdi
addq $0x2d8, %rdi            # imm = 0x2D8
callq 0x18f20
movq %rax, %rdi
movq -0x1e8(%rbp), %rax
movl 0x2d0(%rax), %eax
addq %rax, %rdi
movq -0xd8(%rbp), %rsi
movl -0xdc(%rbp), %eax
movl %eax, %edx
callq 0xa5b0
movq -0x1e8(%rbp), %rax
movl -0xdc(%rbp), %ecx
addl 0x2d0(%rax), %ecx
movl %ecx, 0x2d0(%rax)
movq -0x1e8(%rbp), %rdi
addq $0x408, %rdi            # imm = 0x408
leaq 0x5300a(%rip), %rsi     # 0xa8b60
movl $0x1, %edx
callq 0x17c00
jmp 0x55b62
movq -0x1e8(%rbp), %rdi
addq $0x380, %rdi            # imm = 0x380
movl -0x24(%rbp), %edx
leaq 0x52fe6(%rip), %rsi     # 0xa8b60
movl $0x1, %r8d
movl $0x32, %r9d
movl %r8d, %ecx
callq 0xf690
jmp 0x55b90
movq -0x1e8(%rbp), %rax
movb $0x1, -0x61(%rbp)
movq %rax, %rdi
addq $0x338, %rdi            # imm = 0x338
movzbl 0x4f4(%rax), %edx
shrl $0x2, %edx
andl $0x1, %edx
leaq 0x52fa7(%rip), %rsi     # 0xa8b60
movl $0x28, %ecx
callq 0x52e80
movl %eax, -0x244(%rbp)
jmp 0x55bcb
movq -0x1e8(%rbp), %rax
movl -0x244(%rbp), %ecx
movl %ecx, -0xe4(%rbp)
movb 0x4f4(%rax), %cl
andb $-0x5, %cl
orb $0x4, %cl
movb %cl, 0x4f4(%rax)
jmp 0x55c7d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x56068
movq -0x58(%rbp), %rdi
callq 0xa240
movq -0x1e8(%rbp), %rdi
movq %rax, -0xf0(%rbp)
callq 0x2d420
movq %rax, -0x250(%rbp)
movq -0xf0(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq -0x250(%rbp), %rsi
movq %rax, -0xf8(%rbp)
leaq 0x232bf(%rip), %rdx     # 0x78f18
movl $0x3, %edi
leaq -0xf8(%rbp), %rcx
callq 0x56410
movl $0x5, -0x60(%rbp)
callq 0xac30
jmp 0x55c78
jmp 0x55f1a
cmpl $0x0, -0xe4(%rbp)
jne 0x55ea6
movq -0x1e8(%rbp), %rdi
movq 0x100(%rdi), %rax
movq %rax, -0x100(%rbp)
addq $0x258, %rdi            # imm = 0x258
callq 0xac70
testb $0x1, %al
jne 0x55cc9
movq -0x1e8(%rbp), %rdi
addq $0x258, %rdi            # imm = 0x258
callq 0xa250
movq %rax, -0x100(%rbp)
callq 0xab00
movq -0x1e8(%rbp), %rdi
movl %eax, %esi
movq (%rdi), %rax
movq 0x60(%rax), %rax
callq *%rax
movq -0x18(%rbp), %rdi
callq 0x52fb0
movq -0x1e8(%rbp), %r10
movq %rax, %rsi
movq -0x100(%rbp), %rdx
movq -0x40(%rbp), %rcx
movl -0x20(%rbp), %r8d
movl 0x4a8(%r10), %r9d
movl 0x4ac(%r10), %edi
addq $0x300, %r10            # imm = 0x300
movq %rsp, %rax
movq %r10, 0x8(%rax)
movl %edi, (%rax)
leaq -0x170(%rbp), %rdi
callq 0x52fd0
jmp 0x55d2e
movq -0x1e8(%rbp), %rdi
movb -0x19(%rbp), %al
andb $0x1, %al
movb %al, -0x148(%rbp)
movw 0x2e(%rdi), %ax
shrw $0x4, %ax
andw $0x1, %ax
xorb $-0x1, %al
andb $0x1, %al
movb %al, -0x147(%rbp)
movw 0x2e(%rdi), %ax
shrw $0x5, %ax
andw $0x1, %ax
andb $0x1, %al
movb %al, -0x146(%rbp)
movl -0x74(%rbp), %eax
movl %eax, -0x138(%rbp)
movl 0x4e4(%rdi), %eax
movl %eax, -0x134(%rbp)
movl -0x7c(%rbp), %eax
movl %eax, -0x130(%rbp)
movl 0x4b0(%rdi), %eax
movl %eax, -0x12c(%rbp)
addq $0x4b8, %rdi            # imm = 0x4B8
callq 0xa250
movq -0x1e8(%rbp), %rdi
movq %rax, -0x120(%rbp)
addq $0x278, %rdi            # imm = 0x278
callq 0xa250
movq -0x1e8(%rbp), %rdi
movq %rax, -0x158(%rbp)
movl 0x4ec(%rdi), %eax
movl %eax, -0x128(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x108(%rbp)
movb 0x2f0(%rdi), %al
andb $0x1, %al
movb %al, -0x145(%rbp)
movl 0x2f4(%rdi), %eax
movl %eax, -0x144(%rbp)
addq $0x318, %rdi            # imm = 0x318
callq 0xa250
movq %rax, %rcx
movq -0x1e8(%rbp), %rax
movq %rcx, -0x150(%rbp)
movb 0x2f8(%rax), %cl
andb $0x1, %cl
movb %cl, -0x140(%rbp)
movw 0x2fa(%rax), %ax
movw %ax, -0x13e(%rbp)
leaq -0x1e0(%rbp), %rdi
leaq -0x170(%rbp), %rsi
movl $0x70, %edx
callq 0xa5b0
movq -0x1e8(%rbp), %rdi
movups -0x180(%rbp), %xmm0
movq %rsp, %rax
movups %xmm0, 0x60(%rax)
movups -0x190(%rbp), %xmm0
movups %xmm0, 0x50(%rax)
movups -0x1a0(%rbp), %xmm0
movups %xmm0, 0x40(%rax)
movups -0x1e0(%rbp), %xmm0
movups -0x1d0(%rbp), %xmm1
movups -0x1c0(%rbp), %xmm2
movups -0x1b0(%rbp), %xmm3
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x6ceb0
jmp 0x55f18
movq -0x1e8(%rbp), %rax
movl -0xe4(%rbp), %ecx
movl %ecx, 0x4d8(%rax)
movl -0x20(%rbp), %edi
callq 0xad80
jmp 0x55ec3
cmpl $-0x1, -0x74(%rbp)
je 0x55ed5
movl -0x74(%rbp), %edi
callq 0xad80
jmp 0x55ed3
jmp 0x55ed5
cmpl $-0x1, -0x7c(%rbp)
je 0x55ee7
movl -0x7c(%rbp), %edi
callq 0xad80
jmp 0x55ee5
jmp 0x55ee7
movq -0x1e8(%rbp), %rax
movl -0x80(%rbp), %ecx
movl %ecx, 0x4e8(%rax)
movl 0x10c(%rax), %ecx
andl $0xffffff7f, %ecx       # imm = 0xFFFFFF7F
orl $0x80, %ecx
movl %ecx, 0x10c(%rax)
movb $0x1, -0x1(%rbp)
jmp 0x56052
jmp 0x55f1a
testb $0x1, -0x61(%rbp)
je 0x55f3a
movq -0x1e8(%rbp), %rdi
addq $0x380, %rdi            # imm = 0x380
leaq 0x52c2b(%rip), %rsi     # 0xa8b60
callq 0x17d20
cmpl $-0x1, -0x80(%rbp)
je 0x55f4c
movl -0x80(%rbp), %edi
callq 0xad80
jmp 0x55f4a
jmp 0x55f4c
cmpl $-0x1, -0x7c(%rbp)
je 0x55f5e
movl -0x7c(%rbp), %edi
callq 0xad80
jmp 0x55f5c
jmp 0x55f5e
testb $0x1, -0x91(%rbp)
je 0x55f7a
movq -0x90(%rbp), %rdi
leaq 0x52beb(%rip), %rsi     # 0xa8b60
callq 0x17d20
movq -0x1e8(%rbp), %rax
movw 0x2e(%rax), %ax
shrw $0x6, %ax
andw $0x1, %ax
testw $0x1, %ax
je 0x55fc9
movq -0x70(%rbp), %rax
movq %rax, -0x258(%rbp)
cmpq $0x0, %rax
je 0x55fb1
movq -0x258(%rbp), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
jmp 0x55fb3
movl -0x78(%rbp), %edi
callq 0xad80
jmp 0x55fbd
movl -0x74(%rbp), %edi
callq 0xad80
jmp 0x55fc7
jmp 0x55fc9
jmp 0x55fcb
movq -0x1e8(%rbp), %rax
cmpl $-0x1, 0x4f0(%rax)
je 0x56038
movq -0x1e8(%rbp), %rdi
addq $0x408, %rdi            # imm = 0x408
leaq 0x52b70(%rip), %rsi     # 0xa8b60
callq 0x17d20
movq -0x1e8(%rbp), %rax
movl 0x4f0(%rax), %edi
callq 0xad80
jmp 0x56009
movq -0x1e8(%rbp), %rax
movl 0x4ec(%rax), %edi
callq 0xad80
jmp 0x5601d
movq -0x1e8(%rbp), %rax
movl $0xffffffff, 0x4f0(%rax) # imm = 0xFFFFFFFF
movl $0xffffffff, 0x4ec(%rax) # imm = 0xFFFFFFFF
jmp 0x5603a
movl -0x24(%rbp), %edi
callq 0xad80
jmp 0x56044
movl -0x20(%rbp), %edi
callq 0xad80
jmp 0x5604e
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x2d0, %rsp            # imm = 0x2D0
popq %rbp
retq
movq %rax, %rdi
callq 0xfa30
movq -0x58(%rbp), %rdi
callq 0xfa30
nopw %cs:(%rax,%rax)