// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinitctl.cc
// Function: service_status(int, cpbuffer<1024u>&, char const*, ctl_cmd, unsigned short, bool)
static int service_status(int socknum, cpbuffer_t &rbuffer, const char *service_name,
        ctl_cmd command, uint16_t proto_version, bool verbose)
{
    using std::cout;
    using std::cerr;

    bool is_status = command == ctl_cmd::SERVICE_STATUS;

    if (issue_load_service(socknum, service_name, true) == 1) {
        return 1;
    }

    wait_for_reply(rbuffer, socknum);

    handle_t handle;

    if (rbuffer[0] == (char)cp_rply::NOSERVICE) {
        if (is_status) {
            cerr << "dinitctl: service not loaded.\n";
        }
        return 1;
    }

    if (check_load_reply(socknum, rbuffer, &handle, nullptr, is_status) != 0) {
        return 1;
    }

    // Issue STATUS request
    {
        char status_req_id = proto_version < 5 ? (char)cp_cmd::SERVICESTATUS : (char)cp_cmd::SERVICESTATUS5;
        unsigned status_buf_size = proto_version < 5 ? STATUS_BUFFER_SIZE : STATUS_BUFFER5_SIZE;

        auto m = membuf()
                .append(status_req_id)
                .append(handle);
        write_all_x(socknum, m);

        wait_for_reply(rbuffer, socknum);
        if (rbuffer[0] != (char)cp_rply::SERVICESTATUS) {
            cerr << "dinitctl: protocol error.\n";
            return 1;
        }
        rbuffer.consume(1);

        fill_buffer_to(rbuffer, socknum, status_buf_size + 1 /* reserved */);
        rbuffer.consume(1);

        service_state_t current = static_cast<service_state_t>(rbuffer[0]);
        service_state_t target = static_cast<service_state_t>(rbuffer[1]);

        int console_flags = rbuffer[2];
        bool has_console = (console_flags & 2) != 0;
        bool waiting_console = (console_flags & 1) != 0;
        bool was_skipped = (console_flags & 4) != 0;
        bool marked_active = (console_flags & 8) != 0;
        bool has_pid = (console_flags & 16) != 0;

        stopped_reason_t stop_reason = static_cast<stopped_reason_t>(rbuffer[3]);

        pid_t service_pid = -1;
        int exit_status = 0;
        int exit_si_code = 0;
        int exit_si_status = 0;
        if (has_pid) {
            // 6 = current state (1) + target state (1) + flags (1)
            //                       + stop reason (1) + exec failure stage (2)
            rbuffer.extract((char *)&service_pid, 6, sizeof(service_pid));
        }
        else {
            if (proto_version < 5) {
                rbuffer.extract((char *)&exit_status, 6, sizeof(exit_status));
            }
            else {
                rbuffer.extract((char *)&exit_si_code, 6, sizeof(exit_si_code));
                rbuffer.extract((char *)&exit_si_status, 6 + sizeof(int), sizeof(exit_si_status));
            }
        }

        switch (command) {
        case ctl_cmd::IS_STARTED:
        case ctl_cmd::IS_FAILED:
            if (verbose) {
                switch (current) {
                case service_state_t::STOPPED:
                    cout << "STOPPED\n";
                    break;
                case service_state_t::STARTING:
                    cout << "STARTING\n";
                    break;
                case service_state_t::STARTED:
                    cout << "STARTED\n";
                    break;
                case service_state_t::STOPPING:
                    cout << "STOPPING\n";
                }
            }
            if (command == ctl_cmd::IS_STARTED) {
                // return 0 (success) for started
                return current != service_state_t::STARTED;
            }
            // IS_FAILED:
            // return 0 (success) for specific stopped reasons
            if (current == service_state_t::STOPPED) {
                switch (stop_reason) {
                case stopped_reason_t::DEPFAILED:
                case stopped_reason_t::FAILED:
                case stopped_reason_t::EXECFAILED:
                case stopped_reason_t::TIMEDOUT:
                    return 0;
                default:
                    break;
                }
            }
            return 1;
        default:
            /* status */
            break;
        }

        cout << "Service: " << service_name << "\n"
                "    State: ";

        switch (current) {
        case service_state_t::STOPPED:
            cout << "STOPPED";
            switch (stop_reason) {
            case stopped_reason_t::DEPRESTART:
                cout << " (dependency restarted)";
                break;
            case stopped_reason_t::DEPFAILED:
                cout << " (dependency failed/terminated)";
                break;
            case stopped_reason_t::FAILED:
                cout << " (failed to start";
                if (proto_version < 5) {
                    if (exit_status != 0) {
                        cout << "; ";
                        print_termination_details(exit_status);
                    }
                }
                else {
                    if (exit_si_status != 0) {
                        cout << "; ";
                        print_termination_details(exit_si_code, exit_si_status);
                    }
                }
                cout << ")";
                break;
            case stopped_reason_t::EXECFAILED:
                uint16_t launch_stage;
                rbuffer.extract((char *)&launch_stage, 4, 2);
                if (exit_status == 0) {
                    // (Protocol version 5+)
                    exit_status = exit_si_code;
                }
                cout << " (could not be launched)\n";
                cout << "        Stage: " << exec_stage_descriptions[launch_stage] << "\n";
                cout << "        Error: " << strerror(exit_status);
                break;
            case stopped_reason_t::TERMINATED:
                cout << " (terminated";
                if (proto_version < 5) {
                    if (exit_status != 0) {
                        cout << "; ";
                        print_termination_details(exit_status);
                    }
                }
                else {
                    if (exit_si_status != 0) {
                        cout << "; ";
                        print_termination_details(exit_si_code, exit_si_status);
                    }
                }
                cout << ")";
                break;
            case stopped_reason_t::TIMEDOUT:
                cout << " (start timed out)";
                break;
            case stopped_reason_t::NORMAL:
                break;
            }
            break;
        case service_state_t::STARTING:
            cout << "STARTING";
            if (target == service_state_t::STOPPED) {
                cout << " (target state: STOPPED)";
            }
            break;
        case service_state_t::STARTED:
            cout << "STARTED";
            if (was_skipped) {
                cout << " (startup skipped)";
            }
            break;
        case service_state_t::STOPPING:
            cout << "STOPPING";
            if (target == service_state_t::STARTED) {
                cout << " (target state: STARTED)";
            }
            if (proto_version < 5) {
                if (exit_status != 0) {
                    cout << "(terminated ;";
                    print_termination_details(exit_status);
                    cout << ")";
                }
            }
            else {
                if (exit_si_status != 0) {
                    cout << "(terminated ;";
                    print_termination_details(exit_si_code, exit_si_status);
                    cout << ")";
                }
            }
        }
        if (has_console) {
            cout << " (holding console)";
        }
        if (waiting_console) {
            cout << " (waiting for console)";
        }
        cout << "\n";

        if (target == service_state_t::STARTED) {
            cout << "    Activation: ";
            if (marked_active) {
                cout << "explicitly started\n";
            }
            else {
                cout << "start due to dependent(s)\n";
            }
        }

        if (service_pid != -1) {
            cout << "    Process ID: " << service_pid << "\n";
        }
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r9d, 0x20(%rsp)
movl %r8d, %r15d
movl %ecx, %r12d
movq %rdx, %rbx
movq %rsi, %r14
movl %edi, %r13d
movl $0x1, %ebp
movq %rdx, %rsi
movl $0x1, %edx
callq 0xd59c
movq %r14, %rdi
movl %r13d, %esi
callq 0xedbd
movl 0x400(%r14), %eax
leal -0x400(%rax), %ecx
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %ecx
cmpb $0x3c, (%r14,%rcx)
jne 0xa913
cmpl $0xa, %r12d
jne 0xb15d
movq 0x126eb(%rip), %rdi     # 0x1cfe8
leaq 0xbcdd(%rip), %rsi      # 0x165e1
movl $0x1e, %edx
callq 0x4330
jmp 0xb15d
movq %rbx, 0x38(%rsp)
xorl %r8d, %r8d
cmpl $0xa, %r12d
sete %r8b
xorl %ebx, %ebx
leaq 0x24(%rsp), %rdx
movl %r13d, %edi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0xd69a
testl %eax, %eax
jne 0xb15d
movq %r12, 0x30(%rsp)
movl 0x24(%rsp), %eax
movl %eax, %ecx
shll $0x8, %ecx
xorl %edx, %edx
movl %r15d, 0x10(%rsp)
cmpw $0x5, %r15w
setae %dl
leal (%rcx,%rdx,8), %ecx
addl $0x12, %ecx
shrl $0x18, %eax
leaq 0x40(%rsp), %rbp
movb %al, 0x4(%rbp)
movl %ecx, (%rbp)
movl $0x5, %r15d
movl %r15d, %edx
movl %r13d, %edi
movq %rbp, %rsi
callq 0x4100
cmpl $-0x1, %eax
je 0xa998
addl %eax, %ebx
movslq %eax, %rcx
addq %rcx, %rbp
subl %eax, %r15d
xorl %ecx, %ecx
jmp 0xa9b8
callq 0x4040
movl $0x2, %ecx
cmpl $0x4, (%rax)
je 0xa9b8
testl %ebx, %ebx
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
cmovgl %ebx, %r12d
movl $0x1, %ecx
testb $0x1, %cl
jne 0xa9c4
testl %r15d, %r15d
jg 0xa976
jmp 0xa9c7
movl %r12d, %ebx
cmpl $-0x1, %ebx
je 0xb249
movq %r14, %rdi
movl %r13d, %esi
callq 0xedbd
movl 0x400(%r14), %eax
leal -0x400(%rax), %ecx
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %ecx
cmpb $0x46, (%r14,%rcx)
movl 0x10(%rsp), %edx
jne 0xab56
xorl %ecx, %ecx
cmpw $0x5, %dx
setae %cl
leal 0x1(%rax), %edx
addl $0xfffffc01, %eax       # imm = 0xFFFFFC01
cmpl $0x400, %edx            # imm = 0x400
cmovbl %edx, %eax
movl %eax, 0x400(%r14)
decl 0x404(%r14)
leal 0xb(,%rcx,4), %ebx
movl $0x1, %r15d
cmpl %ebx, 0x404(%r14)
jae 0xaa52
movq %r14, %rdi
movl %r13d, %esi
callq 0xeffc
testl %eax, %eax
cmovlel %eax, %ebp
movl %ebp, %r15d
jg 0xaa2e
cmpl $-0x1, %r15d
je 0xaa62
testl %r15d, %r15d
jne 0xaa70
jmp 0xb214
callq 0x4040
cmpl $0x4, (%rax)
jne 0xb226
cmpl $-0x1, %r15d
je 0xaa2e
movl 0x400(%r14), %r13d
leal 0x1(%r13), %ecx
movl $0xfffffc01, %edx       # imm = 0xFFFFFC01
addl %edx, %r13d
movl $0x400, %eax            # imm = 0x400
cmpl %eax, %ecx
cmovbl %ecx, %r13d
movl %r13d, 0x400(%r14)
decl 0x404(%r14)
leal -0x400(%r13), %ecx
cmpl %eax, %r13d
cmovbl %r13d, %ecx
movzbl (%r14,%rcx), %r15d
leal 0x1(%r13), %ecx
addl %r13d, %edx
cmpl %eax, %ecx
cmovbl %ecx, %edx
movb (%r14,%rdx), %bl
leal 0x2(%r13), %ecx
leal -0x3fe(%r13), %edx
cmpl %eax, %ecx
cmovbl %ecx, %edx
movzbl (%r14,%rdx), %edi
leal 0x3(%r13), %edx
movl $0xfffffc03, %ecx       # imm = 0xFFFFFC03
leal (%rcx,%r13), %esi
cmpl %eax, %edx
cmovbl %edx, %esi
leal 0x6(%r13), %edx
addl $0xfffffc06, %r13d      # imm = 0xFFFFFC06
cmpl %eax, %edx
cmovbl %edx, %r13d
addl %r13d, %ecx
xorl %eax, %eax
movzbl (%r14,%rsi), %edx
movq %rdx, 0x28(%rsp)
movl $0xffffffff, 0x1c(%rsp) # imm = 0xFFFFFFFF
movl %eax, 0x4(%rsp)
movl %eax, 0xc(%rsp)
movl %eax, 0x8(%rsp)
movl %edi, 0x18(%rsp)
testb $0x10, %dil
jne 0xab78
cmpw $0x4, 0x10(%rsp)
ja 0xab98
cmpl $0xfffffbfe, %ecx       # imm = 0xFFFFFBFE
ja 0xabe5
movl $0x400, %ebp            # imm = 0x400
subl %r13d, %ebp
movl %r13d, %esi
addq %r14, %rsi
leaq 0x4(%rsp), %r12
jmp 0xac3d
movq 0x1248b(%rip), %rdi     # 0x1cfe8
leaq 0xb60e(%rip), %rsi      # 0x16172
movl $0x1a, %edx
callq 0x4330
movl $0x1, %ebp
jmp 0xb15d
cmpl $0xfffffbfe, %ecx       # imm = 0xFFFFFBFE
ja 0xabd8
movl $0x400, %ebp            # imm = 0x400
subl %r13d, %ebp
movl %r13d, %esi
addq %r14, %rsi
leaq 0x1c(%rsp), %r12
jmp 0xac3d
cmpl $0xfffffbfe, %ecx       # imm = 0xFFFFFBFE
ja 0xabf2
movl $0x400, %ebp            # imm = 0x400
subl %r13d, %ebp
movl %r13d, %esi
addq %r14, %rsi
leaq 0xc(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rdx
callq 0x4270
addq %r12, %rbp
addl $0xfffffc04, %r13d      # imm = 0xFFFFFC04
movq %rbp, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x4270
jmp 0xabfd
movl %r13d, %eax
movl (%r14,%rax), %eax
movl %eax, 0x1c(%rsp)
jmp 0xac60
movl %r13d, %eax
movl (%r14,%rax), %eax
movl %eax, 0x4(%rsp)
jmp 0xac60
movl %r13d, %eax
movl (%r14,%rax), %eax
movl %eax, 0xc(%rsp)
movl 0x400(%r14), %r13d
leal 0xa(%r13), %eax
addl $0xfffffc0a, %r13d      # imm = 0xFFFFFC0A
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %r13d
leal -0x3fd(%r13), %eax
movl %r13d, %esi
cmpl $0xfffffbfe, %eax       # imm = 0xFFFFFBFE
ja 0xad8f
movl $0x400, %ebp            # imm = 0x400
subl %r13d, %ebp
addq %r14, %rsi
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rdx
callq 0x4270
addq %r12, %rbp
addl $0xfffffc04, %r13d      # imm = 0xFFFFFC04
movq %rbp, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x4270
movq 0x30(%rsp), %rax
addl $-0x19, %eax
cmpl $-0x2, %eax
jae 0xacb1
movl %r15d, %ebp
movq 0x12331(%rip), %r15     # 0x1cfa8
leaq 0xbb0f(%rip), %rsi      # 0x1678d
movl $0x9, %edx
movq %r15, %rdi
callq 0x4330
movq 0x38(%rsp), %r13
testq %r13, %r13
je 0xacf1
movq %r13, %rdi
callq 0x4150
movq 0x12304(%rip), %rdi     # 0x1cfa8
movq %r13, %rsi
movq %rax, %rdx
callq 0x4330
jmp 0xad09
cmpb $0x0, 0x20(%rsp)
movq 0x30(%rsp), %rbx
je 0xaf09
cmpl $0x3, %r15d
ja 0xaf09
movl %r15d, %eax
leaq 0xa37b(%rip), %rcx      # 0x15050
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x122c3(%rip), %rdi     # 0x1cfa8
leaq 0xba7b(%rip), %rsi      # 0x16767
jmp 0xae8f
movq (%r15), %rax
movq -0x18(%rax), %rax
leaq (%r15,%rax), %rdi
movl 0x20(%r15,%rax), %esi
orl $0x1, %esi
callq 0x44c0
movq 0x12298(%rip), %rdi     # 0x1cfa8
leaq 0xba80(%rip), %rsi      # 0x16797
movl $0xc, %edx
callq 0x4330
cmpl $0x3, %ebp
ja 0xb06f
movl %ebp, %eax
leaq 0xa32d(%rip), %rcx      # 0x15060
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x12265(%rip), %rdi     # 0x1cfa8
leaq 0xba5a(%rip), %rsi      # 0x167a4
movl $0x7, %edx
callq 0x4330
movq 0x28(%rsp), %rax
decl %eax
cmpl $0x5, %eax
ja 0xb06f
movq %rax, %rcx
leaq 0xa302(%rip), %rax      # 0x15070
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq 0x1222a(%rip), %rdi     # 0x1cfa8
leaq 0xba27(%rip), %rsi      # 0x167ac
movl $0x17, %edx
jmp 0xb06a
movl (%r14,%rsi), %eax
movl %eax, 0x8(%rsp)
jmp 0xac60
movq 0x12205(%rip), %rdi     # 0x1cfa8
leaq 0xbaab(%rip), %rsi      # 0x16855
movl $0x7, %edx
callq 0x4330
testb $0x4, 0x18(%rsp)
je 0xb06f
movq 0x121e2(%rip), %rdi     # 0x1cfa8
leaq 0xba90(%rip), %rsi      # 0x1685d
jmp 0xaf41
movq 0x121cf(%rip), %rdi     # 0x1cfa8
leaq 0xba90(%rip), %rsi      # 0x16870
movl $0x8, %edx
callq 0x4330
cmpb $0x2, %bl
jne 0xae07
movq 0x121b2(%rip), %rdi     # 0x1cfa8
leaq 0xba7c(%rip), %rsi      # 0x16879
movl $0x18, %edx
callq 0x4330
cmpw $0x4, 0x10(%rsp)
ja 0xaea6
cmpl $0x0, 0x4(%rsp)
je 0xb06f
movl %ebx, %ebp
movq 0x12181(%rip), %rbx     # 0x1cfa8
leaq 0xba64(%rip), %rsi      # 0x16892
movl $0xd, %edx
movq %rbx, %rdi
callq 0x4330
movl 0x4(%rsp), %edi
callq 0xdde6
jmp 0xaedb
movq 0x12158(%rip), %rdi     # 0x1cfa8
leaq 0xb9dc(%rip), %rsi      # 0x16833
movl $0x8, %edx
callq 0x4330
testb %bl, %bl
jne 0xb06f
movq 0x12138(%rip), %rdi     # 0x1cfa8
leaq 0xb9c5(%rip), %rsi      # 0x1683c
movl $0x18, %edx
jmp 0xb06a
movq 0x12120(%rip), %rdi     # 0x1cfa8
leaq 0xb8eb(%rip), %rsi      # 0x1677a
movl $0x8, %edx
jmp 0xaf04
movq 0x1210b(%rip), %rdi     # 0x1cfa8
leaq 0xb8df(%rip), %rsi      # 0x16783
jmp 0xaeff
cmpl $0x0, 0x8(%rsp)
je 0xb06f
movl %ebx, %ebp
movq 0x120ee(%rip), %rbx     # 0x1cfa8
leaq 0xb9d1(%rip), %rsi      # 0x16892
movl $0xd, %edx
movq %rbx, %rdi
callq 0x4330
movl 0xc(%rsp), %edi
movl 0x8(%rsp), %esi
callq 0xdd76
leaq 0xbfa1(%rip), %rsi      # 0x16e83
movl $0x1, %edx
movq %rbx, %rdi
movl %ebp, %ebx
jmp 0xb06a
movq 0x120b0(%rip), %rdi     # 0x1cfa8
leaq 0xb871(%rip), %rsi      # 0x16770
movl $0x9, %edx
callq 0x4330
cmpl $0x17, %ebx
jne 0xaf1a
cmpl $0x2, %r15d
setne %al
jmp 0xb15a
testl %r15d, %r15d
setne %cl
movq 0x28(%rsp), %rax
addb $-0x6, %al
cmpb $-0x4, %al
setb %al
orb %cl, %al
jmp 0xb15a
movq 0x1206e(%rip), %rdi     # 0x1cfa8
leaq 0xb8df(%rip), %rsi      # 0x16820
movl $0x12, %edx
jmp 0xb06a
movq 0x12056(%rip), %rdi     # 0x1cfa8
leaq 0xb88b(%rip), %rsi      # 0x167e4
movl $0x11, %edx
jmp 0xaff4
movl %ebx, %r13d
movl 0x400(%r14), %ebx
leal 0x4(%rbx), %eax
addl $0xfffffc04, %ebx       # imm = 0xFFFFFC04
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %ebx
leal -0x3ff(%rbx), %eax
cmpl $0xfffffbfe, %eax       # imm = 0xFFFFFBFE
ja 0xb16e
movl $0x400, %r15d           # imm = 0x400
subl %ebx, %r15d
movl %ebx, %esi
addq %r14, %rsi
leaq 0x16(%rsp), %r12
movq %r12, %rdi
movq %r15, %rdx
callq 0x4270
addq %r12, %r15
addl $0xfffffc02, %ebx       # imm = 0xFFFFFC02
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x4270
jmp 0xb17a
movq 0x11fd8(%rip), %rdi     # 0x1cfa8
leaq 0xb7ed(%rip), %rsi      # 0x167c4
movl $0x1f, %edx
jmp 0xb06a
movq 0x11fc0(%rip), %rdi     # 0x1cfa8
leaq 0xb824(%rip), %rsi      # 0x16813
movl $0xc, %edx
callq 0x4330
cmpw $0x4, 0x10(%rsp)
ja 0xb02b
cmpl $0x0, 0x4(%rsp)
je 0xb057
movq 0x11f99(%rip), %rdi     # 0x1cfa8
leaq 0xb7e0(%rip), %rsi      # 0x167f6
movl $0x2, %edx
callq 0x4330
movl 0x4(%rsp), %edi
callq 0xdde6
jmp 0xb057
cmpl $0x0, 0x8(%rsp)
je 0xb057
movq 0x11f6f(%rip), %rdi     # 0x1cfa8
leaq 0xb7b6(%rip), %rsi      # 0x167f6
movl $0x2, %edx
callq 0x4330
movl 0xc(%rsp), %edi
movl 0x8(%rsp), %esi
callq 0xdd76
movq 0x11f4a(%rip), %rdi     # 0x1cfa8
leaq 0xbe1e(%rip), %rsi      # 0x16e83
movl $0x1, %edx
callq 0x4330
testb $0x2, 0x18(%rsp)
je 0xb08e
movq 0x11f2b(%rip), %rdi     # 0x1cfa8
leaq 0xb81c(%rip), %rsi      # 0x168a0
movl $0x12, %edx
callq 0x4330
testb $0x1, 0x18(%rsp)
je 0xb0ad
movq 0x11f0c(%rip), %rdi     # 0x1cfa8
leaq 0xb684(%rip), %rsi      # 0x16727
movl $0x16, %edx
callq 0x4330
movq 0x11ef4(%rip), %rdi     # 0x1cfa8
leaq 0xba5a(%rip), %rsi      # 0x16b15
movl $0x1, %edx
callq 0x4330
cmpb $0x2, %bl
jne 0xb116
movq 0x11ed7(%rip), %rdi     # 0x1cfa8
leaq 0xb7db(%rip), %rsi      # 0x168b3
movl $0x10, %edx
callq 0x4330
testb $0x8, 0x18(%rsp)
jne 0xb0fe
movq 0x11eb8(%rip), %rdi     # 0x1cfa8
leaq 0xb7e1(%rip), %rsi      # 0x168d8
movl $0x1a, %edx
jmp 0xb111
movq 0x11ea3(%rip), %rdi     # 0x1cfa8
leaq 0xb7b8(%rip), %rsi      # 0x168c4
movl $0x13, %edx
callq 0x4330
cmpl $-0x1, 0x1c(%rsp)
je 0xb158
movq 0x11e84(%rip), %rbx     # 0x1cfa8
leaq 0xb7c8(%rip), %rsi      # 0x168f3
movl $0x10, %edx
movq %rbx, %rdi
callq 0x4330
movl 0x1c(%rsp), %esi
movq %rbx, %rdi
callq 0x44e0
leaq 0xb9ca(%rip), %rsi      # 0x16b15
movl $0x1, %edx
movq %rax, %rdi
callq 0x4330
xorl %eax, %eax
movzbl %al, %ebp
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %ebx, %eax
movzwl (%r14,%rax), %eax
movw %ax, 0x16(%rsp)
cmpl $0x0, 0x4(%rsp)
jne 0xb189
movl 0xc(%rsp), %eax
movl %eax, 0x4(%rsp)
movq 0x11e18(%rip), %rbx     # 0x1cfa8
leaq 0xb662(%rip), %rsi      # 0x167f9
movl $0x19, %edx
movq %rbx, %rdi
callq 0x4330
leaq 0xb24b(%rip), %rsi      # 0x163f6
movl $0xf, %edx
movq %rbx, %rdi
callq 0x4330
movzwl 0x16(%rsp), %eax
leaq 0x11a7c(%rip), %rcx     # 0x1cc40
movq (%rcx,%rax,8), %rsi
movq %rbx, %rdi
callq 0x42d0
leaq 0xb93e(%rip), %rsi      # 0x16b15
movl $0x1, %edx
movq %rax, %rdi
callq 0x4330
leaq 0xb21b(%rip), %rsi      # 0x16406
movl $0xf, %edx
movq %rbx, %rdi
callq 0x4330
movl 0x4(%rsp), %edi
callq 0x40f0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x42d0
movl %r13d, %ebx
jmp 0xb06f
movl $0x4, %edi
callq 0x4190
movl $0x0, (%rax)
jmp 0xb238
movq %rax, %rbp
movl $0x4, %edi
callq 0x4190
movl (%rbp), %ecx
movl %ecx, (%rax)
leaq 0x11901(%rip), %rsi     # 0x1cb40
movq %rax, %rdi
xorl %edx, %edx
callq 0x44d0
movl $0x4, %edi
callq 0x4190
movq %rax, %rbx
callq 0x4040
movl (%rax), %eax
movl %eax, (%rbx)
leaq 0x118ea(%rip), %rsi     # 0x1cb50
movq %rbx, %rdi
jmp 0xb242