// File: /workspace/github_cpp_makefile_star2_O3/davmac314[P]dinit/src/dinitctl.cc
// Function: start_stop_service(int, cpbuffer<1024u>&, char const*, ctl_cmd, bool, bool, bool, bool, bool)
static int start_stop_service(int socknum, cpbuffer_t &rbuffer, const char *service_name,
        ctl_cmd command, bool do_pin, bool do_force, bool wait_for_service, bool ignore_unstarted,
        bool verbose)
{
    using std::cout;
    using std::cerr;

    bool do_stop = (command == ctl_cmd::STOP_SERVICE || command == ctl_cmd::RELEASE_SERVICE);

    service_state_t state;
    handle_t handle;
    
    if (command != ctl_cmd::RESTART_SERVICE && command != ctl_cmd::STOP_SERVICE
            && command != ctl_cmd::RELEASE_SERVICE) {
        ignore_unstarted = false;
    }

    if (!load_service(socknum, rbuffer, service_name, &handle, &state, !ignore_unstarted)) {
        return ignore_unstarted ? 0 : 1;
    }

    service_state_t wanted_state = do_stop ? service_state_t::STOPPED : service_state_t::STARTED;
    cp_cmd pcommand;
    switch (command) {
        case ctl_cmd::STOP_SERVICE:
        case ctl_cmd::RESTART_SERVICE:  // stop, and then start
            pcommand = cp_cmd::STOPSERVICE;
            break;
        case ctl_cmd::RELEASE_SERVICE:
            pcommand = cp_cmd::RELEASESERVICE;
            break;
        case ctl_cmd::START_SERVICE:
            pcommand = cp_cmd::STARTSERVICE;
            break;
        case ctl_cmd::WAKE_SERVICE:
            pcommand = cp_cmd::WAKESERVICE;
            break;
        default:
            // can't get here (hopefully)
            pcommand = cp_cmd::STOPSERVICE;
    }

    observed_states_t seen_states;

    // Need to issue command (eg STOPSERVICE/STARTSERVICE)
    // We'll do this regardless of the current service state / target state, since issuing
    // start/stop also sets or clears the "explicitly started" flag on the service.
    // (For other commands we could potentially avoid sending the command if we had more
    // information about the service state, but it doesn't seem worth the effort to implement
    // that optimisation).
    {
        char flags = (do_pin ? 1 : 0) | ((pcommand == cp_cmd::STOPSERVICE && !do_force) ? 2 : 0);
        if (command == ctl_cmd::RESTART_SERVICE) {
            flags |= (4 | 128); // restart, pre-ack
        }

        auto m = membuf()
                .append((char) pcommand)
                .append(flags)
                .append(handle);
        write_all_x(socknum, m);

        wait_for_reply(rbuffer, socknum, handle, &seen_states);
        cp_rply reply_pkt_h = (cp_rply)rbuffer[0];
        rbuffer.consume(1); // consume header

        if (reply_pkt_h == cp_rply::PREACK) {
            // We should consider state changes seen only after the PREACK (i.e. between the
            // PREACK and the main reply):
            seen_states.started = false;
            seen_states.stopped = false;
            seen_states.failed_start = false;

            // PREACK will be followed by a 2nd reply, get that now:
            wait_for_reply(rbuffer, socknum, handle, &seen_states);
            reply_pkt_h = (cp_rply)rbuffer[0];
            rbuffer.consume(1);
        }

        if (reply_pkt_h == cp_rply::ALREADYSS) {
            bool already = (state == wanted_state);
            if (verbose) {
                if (command == ctl_cmd::RESTART_SERVICE) {
                    cout << "Service restarted.\n";
                }
                else {
                    cout << "Service " << (already ? "(already) " : "")
                            << describe_state(do_stop) << ".\n";
                }
            }
            return 0; // success!
        }
        if (reply_pkt_h == cp_rply::PINNEDSTARTED) {
            cerr << "dinitctl: cannot stop service '" << service_name << "' as it is pinned started\n";
            return 1;
        }
        if (reply_pkt_h == cp_rply::PINNEDSTOPPED) {
            cerr << "dinitctl: cannot start service '" << service_name << "' as it is pinned stopped\n";
            return 1;
        }
        if (reply_pkt_h == cp_rply::DEPENDENTS && pcommand == cp_cmd::STOPSERVICE) {
            cerr << "dinitctl: cannot stop service '" << service_name << "' due to the following dependents:\n";
            if (command != ctl_cmd::RESTART_SERVICE) {
                cerr << "(only direct dependents are listed. Exercise caution before using '--force' !!)\n";
            }
            // size_t number, N * handle_t handles
            size_t number;
            rbuffer.fill_to(socknum, sizeof(number));
            rbuffer.extract(&number, 0, sizeof(number));
            rbuffer.consume(sizeof(number));
            std::vector<handle_t> handles;
            handles.reserve(number);
            for (size_t i = 0; i < number; i++) {
                handle_t handle;
                rbuffer.fill_to(socknum, sizeof(handle_t));
                rbuffer.extract(&handle, 0, sizeof(handle));
                handles.push_back(handle);
                rbuffer.consume(sizeof(handle));
            }
            // Print the directly affected dependents:
            cerr << " ";
            for (handle_t handle : handles) {
                cerr << " " << get_service_name(socknum, rbuffer, handle);
            }
            cerr << "\n";
            return 1;
        }
        if (reply_pkt_h == cp_rply::NAK && command == ctl_cmd::RESTART_SERVICE) {
            if (ignore_unstarted) {
                if (verbose) {
                    cout << "Service '" << service_name << "' is not currently started.\n";
                }
                return 0;
            }
            cerr << "dinitctl: cannot restart service; service not started.\n";
            return 1;
        }
        if (reply_pkt_h == cp_rply::NAK && command == ctl_cmd::WAKE_SERVICE) {
            cerr << "dinitctl: service has no active dependents, cannot wake.\n";
            return 1;
        }
        if (reply_pkt_h == cp_rply::SHUTTINGDOWN) {
            cerr << "dinitctl: cannot start/restart/wake service, shutdown is in progress.\n";
            return 1;
        }
        if (reply_pkt_h != cp_rply::ACK) {
            cerr << "dinitctl: protocol error.\n";
            return 1;
        }
    }

    if (!wait_for_service) {
        if (verbose) {
            cout << "Issued " << describe_verb(do_stop) << " command successfully for service '"
                    <<  service_name <<  "'.\n";
        }
        return 0;
    }

    if (command == ctl_cmd::RESTART_SERVICE) {
        // for restart we want to display both "stopped" and "started" statuses
        if (seen_states.stopped) {
            if (verbose) {
                cout << "Service '" << service_name << "' stopped.\n";
            }
        }
        else if (wait_service_state(socknum, rbuffer, handle, service_name, true, verbose) != 0) {
            return EXIT_FAILURE;
        }
    }

    if (seen_states.started) {
        if (verbose) {
            cout << "Service '" << service_name << "' started.\n";
        }
    }
    else if (seen_states.failed_start) {
        if (verbose) {
            cout << "Service '" << service_name << "' failed to start.\n";
            print_failure_details(seen_states.stop_reason, 0 /* not applicable */,
                    seen_states.exit_status, seen_states.exit_si_code, seen_states.exit_si_status);
        }
    }
    return wait_service_state(socknum, rbuffer, handle, service_name, do_stop, verbose);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %r9d, %r12d
movl %r8d, 0x10(%rsp)
movl %ecx, %r15d
movq %rsi, %rbx
movl %edi, %ebp
movb 0xd8(%rsp), %al
xorb $0x1, %al
leal -0x3(%r15), %ecx
testl $0xfffffffd, %ecx       # imm = 0xFFFFFFFD
sete %r13b
cmpl $0x3, %ecx
setae %cl
orb %al, %cl
movzbl %cl, %r9d
leaq 0x8c(%rsp), %rcx
leaq 0xf(%rsp), %r8
movq %rdx, 0x20(%rsp)
movq %r9, %r14
callq 0xd2a8
testb %al, %al
je 0xc376
movl %r13d, %ecx
xorb $0x1, %cl
cmpl $0x1, %r15d
movb %r13b, 0xd(%rsp)
je 0xc386
cmpl $0x2, %r15d
movl 0x10(%rsp), %esi
je 0xc37e
cmpl $0x5, %r15d
jne 0xc392
movw $0x6, %ax
jmp 0xc382
movq %r14, %r15
jmp 0xc722
movw $0x5, %ax
xorl %edx, %edx
jmp 0xc398
movw $0x3, %ax
xorl %edx, %edx
movl 0x10(%rsp), %esi
jmp 0xc398
movw $0x4, %ax
movb $0x1, %dl
addb %cl, %cl
movb %cl, 0xe(%rsp)
xorb $0x1, %r12b
movl %edx, 0x18(%rsp)
andb %dl, %r12b
addb %r12b, %r12b
orb %sil, %r12b
leal -0x7c(%r12), %ecx
movq %r15, 0x10(%rsp)
cmpl $0x4, %r15d
movw $0x0, 0x4c(%rsp)
movb $0x0, 0x4e(%rsp)
xorps %xmm0, %xmm0
movzbl %r12b, %edx
movzbl %cl, %ecx
cmovnel %edx, %ecx
movups %xmm0, 0x50(%rsp)
shll $0x8, %ecx
movzwl %ax, %eax
orl %ecx, %eax
movl 0x8c(%rsp), %r13d
movq %r13, %rcx
shlq $0x10, %rcx
movzwl %ax, %eax
orq %rcx, %rax
movl %r13d, %ecx
shrl $0x10, %ecx
leaq 0x90(%rsp), %r14
movw %cx, 0x4(%r14)
movl %eax, (%r14)
movl $0x6, %r15d
xorl %r12d, %r12d
movl %r15d, %edx
movl %ebp, %edi
movq %r14, %rsi
callq 0x4100
cmpl $-0x1, %eax
je 0xc437
addl %eax, %r12d
movslq %eax, %rcx
addq %rcx, %r14
subl %eax, %r15d
jmp 0xc445
callq 0x4040
cmpl $0x4, (%rax)
jne 0xc53b
testl %r15d, %r15d
jg 0xc417
cmpl $-0x1, %r12d
je 0xc544
leaq 0x4c(%rsp), %rcx
movq %rbx, %rdi
movl %ebp, %esi
movl %r13d, %edx
callq 0xeff8
movl 0x400(%rbx), %ecx
leal -0x400(%rcx), %eax
movl $0x400, %r14d           # imm = 0x400
cmpl %r14d, %ecx
cmovbl %ecx, %eax
movb (%rbx,%rax), %al
leal 0x1(%rcx), %edx
addl $0xfffffc01, %ecx       # imm = 0xFFFFFC01
cmpl %r14d, %edx
cmovbl %edx, %ecx
movl %ecx, 0x400(%rbx)
decl 0x404(%rbx)
cmpb $0x4f, %al
jne 0xc4eb
leaq 0x4c(%rsp), %rcx
movw $0x0, (%rcx)
movb $0x0, 0x2(%rcx)
movq %rbx, %rdi
movl %ebp, %esi
movl %r13d, %edx
callq 0xeff8
movl 0x400(%rbx), %ecx
leal -0x400(%rcx), %eax
cmpl %r14d, %ecx
cmovbl %ecx, %eax
movb (%rbx,%rax), %al
leal 0x1(%rcx), %edx
addl $0xfffffc01, %ecx       # imm = 0xFFFFFC01
cmpl %r14d, %edx
cmovbl %edx, %ecx
movl %ecx, 0x400(%rbx)
decl 0x404(%rbx)
cmpb $0x44, %al
je 0xc5b3
movzbl %al, %ecx
cmpl $0x43, %ecx
je 0xc56b
cmpl $0x3d, %ecx
jne 0xc5fb
xorl %r15d, %r15d
cmpb $0x0, 0xe0(%rsp)
movq 0x10(%rsp), %rax
je 0xc722
cmpl $0x4, %eax
jne 0xc75d
movq 0x10a7e(%rip), %rdi     # 0x1cfa8
leaq 0x9a38(%rip), %rsi      # 0x15f69
movl $0x13, %edx
jmp 0xc7db
testl %r12d, %r12d
jg 0xc454
movl $0x4, %edi
callq 0x4190
movq %rax, %rbx
callq 0x4040
movl (%rax), %eax
movl %eax, (%rbx)
leaq 0x105ef(%rip), %rsi     # 0x1cb50
movq %rbx, %rdi
xorl %edx, %edx
callq 0x44d0
movq 0x10a76(%rip), %rbx     # 0x1cfe8
leaq 0x9a53(%rip), %rsi      # 0x15fcc
movl $0x20, %edx
movq %rbx, %rdi
callq 0x4330
movq 0x20(%rsp), %r14
testq %r14, %r14
je 0xc6c6
movq %r14, %rdi
callq 0x4150
movq 0x10a45(%rip), %rdi     # 0x1cfe8
movq %r14, %rsi
movq %rax, %rdx
callq 0x4330
jmp 0xc6dd
movq 0x10a2e(%rip), %rbx     # 0x1cfe8
leaq 0x99d0(%rip), %rsi      # 0x15f91
movl $0x1f, %edx
movq %rbx, %rdi
callq 0x4330
movq 0x20(%rsp), %r14
testq %r14, %r14
je 0xc6ed
movq %r14, %rdi
callq 0x4150
movq 0x109fd(%rip), %rdi     # 0x1cfe8
movq %r14, %rsi
movq %rax, %rdx
callq 0x4330
jmp 0xc704
cmpb $0x41, %al
setne %dl
movl 0x18(%rsp), %esi
xorb $0x1, %sil
orb %dl, %sil
jne 0xc655
movq 0x109d4(%rip), %r14     # 0x1cfe8
leaq 0x9976(%rip), %rsi      # 0x15f91
movl $0x1f, %edx
movq %r14, %rdi
callq 0x4330
movq 0x20(%rsp), %r15
testq %r15, %r15
je 0xc7e5
movq %r15, %rdi
callq 0x4150
movq 0x109a3(%rip), %rdi     # 0x1cfe8
movq %r15, %rsi
movq %rax, %rdx
callq 0x4330
jmp 0xc7fd
movq 0x10(%rsp), %rdx
cmpl $0x4, %edx
jne 0xc737
cmpb $0x33, %al
jne 0xc737
cmpb $0x0, 0xd8(%rsp)
je 0xcde5
xorl %r15d, %r15d
cmpb $0x0, 0xe0(%rsp)
je 0xc722
movq 0x10917(%rip), %rbx     # 0x1cfa8
leaq 0x99e5(%rip), %rsi      # 0x1607d
movl $0x9, %edx
movq %rbx, %rdi
callq 0x4330
movq %rbx, %rdi
movq 0x20(%rsp), %rsi
callq 0x42d0
leaq 0x99ce(%rip), %rsi      # 0x16087
movl $0x1c, %edx
movq %rax, %rdi
jmp 0xc7db
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x44c0
movq 0x10904(%rip), %rdi     # 0x1cfe8
leaq 0x9902(%rip), %rsi      # 0x15fed
jmp 0xc712
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x44c0
movq 0x108dd(%rip), %rdi     # 0x1cfe8
leaq 0x989f(%rip), %rsi      # 0x15fb1
movl $0x1a, %edx
callq 0x4330
movl $0x1, %r15d
movl %r15d, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x2, %edx
jne 0xcdc0
cmpb $0x33, %al
jne 0xcdc0
movq 0x10899(%rip), %rdi     # 0x1cfe8
leaq 0x9986(%rip), %rsi      # 0x160dc
movl $0x39, %edx
jmp 0xc717
movb 0xf(%rsp), %bpl
movq 0x1083f(%rip), %rbx     # 0x1cfa8
leaq 0x980d(%rip), %rsi      # 0x15f7d
movl $0x8, %edx
movq %rbx, %rdi
callq 0x4330
xorl %r15d, %r15d
cmpb 0xe(%rsp), %bpl
leaq 0x97fa(%rip), %rax      # 0x15f86
leaq 0xa36e(%rip), %rsi      # 0x16b01
cmoveq %rax, %rsi
movl $0xa, %edx
cmovneq %r15, %rdx
movq %rbx, %rdi
callq 0x4330
leaq 0x9b52(%rip), %rax      # 0x16301
leaq 0x8ade(%rip), %rsi      # 0x15294
cmpb $0x0, 0xd(%rsp)
cmovneq %rax, %rsi
movl $0x7, %edx
movq %rbx, %rdi
callq 0x4330
leaq 0x99d2(%rip), %rsi      # 0x161a5
movl $0x2, %edx
movq %rbx, %rdi
callq 0x4330
jmp 0xc722
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x44c0
movq 0x107e4(%rip), %rdi     # 0x1cfe8
leaq 0x97fd(%rip), %rsi      # 0x16008
movl $0x23, %edx
callq 0x4330
cmpl $0x4, 0x10(%rsp)
je 0xc834
movq 0x107c5(%rip), %rdi     # 0x1cfe8
leaq 0x9802(%rip), %rsi      # 0x1602c
movl $0x50, %edx
callq 0x4330
leaq 0x400(%rbx), %rax
movq %rax, 0x10(%rsp)
movl 0x404(%rbx), %r13d
cmpl $0x7, %r13d
ja 0xc868
movq %rbx, %rdi
movl %ebp, %esi
callq 0xef52
movl 0x404(%rbx), %r13d
testl %eax, %eax
jle 0xc868
cmpl $0x8, %r13d
jb 0xc84d
movq 0x10(%rsp), %rax
movl (%rax), %r12d
leal -0x400(%r12), %r14d
cmpl $0x400, %r12d           # imm = 0x400
cmovbl %r12d, %r14d
leal -0x3f9(%r14), %eax
cmpl $0xfffffbfe, %eax       # imm = 0xFFFFFBFE
ja 0xc8d1
movl $0x400, %r15d           # imm = 0x400
subl %r14d, %r15d
movl %r14d, %esi
addq %rbx, %rsi
leaq 0x78(%rsp), %rdi
movq %r15, %rdx
callq 0x4270
leaq (%rsp,%r15), %rdi
addq $0x78, %rdi
addl $0xfffffc08, %r14d      # imm = 0xFFFFFC08
movq %rbx, %rsi
movq %r14, %rdx
callq 0x4270
leaq 0x78(%rsp), %rax
movq (%rax), %r14
jmp 0xc8dd
movl %r14d, %eax
movq (%rbx,%rax), %r14
movq %r14, 0x78(%rsp)
leal 0x8(%r12), %eax
addl $0xfffffc08, %r12d      # imm = 0xFFFFFC08
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %r12d
movl %r12d, 0x400(%rbx)
addl $-0x8, %r13d
movl %r13d, 0x404(%rbx)
xorps %xmm0, %xmm0
leaq 0x60(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq %r14, %rsi
callq 0xf3da
testq %r14, %r14
je 0xca16
movl 0x404(%rbx), %eax
xorl %r15d, %r15d
cmpl $0x3, %eax
ja 0xc94d
movq %rbx, %rdi
movl %ebp, %esi
callq 0xef52
testl %eax, %eax
jle 0xc94d
cmpl $0x4, 0x404(%rbx)
jb 0xc936
movq 0x10(%rsp), %rax
movl (%rax), %eax
leal -0x400(%rax), %r13d
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %r13d
leal -0x3fd(%r13), %eax
movl %r13d, %esi
cmpl $0xfffffbfe, %eax       # imm = 0xFFFFFBFE
ja 0xc9aa
movl $0x400, %r12d           # imm = 0x400
subl %r13d, %r12d
addq %rbx, %rsi
leaq 0x28(%rsp), %rdi
movq %r12, %rdx
callq 0x4270
leaq (%rsp,%r12), %rdi
addq $0x28, %rdi
addl $0xfffffc04, %r13d      # imm = 0xFFFFFC04
movq %rbx, %rsi
movq %r13, %rdx
callq 0x4270
jmp 0xc9b1
movl (%rbx,%rsi), %eax
movl %eax, 0x28(%rsp)
movq 0x68(%rsp), %rsi
cmpq 0x70(%rsp), %rsi
je 0xc9ce
movl 0x28(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x68(%rsp)
jmp 0xc9dd
leaq 0x60(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0xf492
movl 0x400(%rbx), %ecx
movl 0x404(%rbx), %eax
leal 0x4(%rcx), %edx
addl $0xfffffc04, %ecx       # imm = 0xFFFFFC04
cmpl $0x400, %edx            # imm = 0x400
cmovbl %edx, %ecx
movl %ecx, 0x400(%rbx)
addl $-0x4, %eax
movl %eax, 0x404(%rbx)
incq %r15
cmpq %r14, %r15
jne 0xc931
movq 0x105cb(%rip), %rdi     # 0x1cfe8
leaq 0x9cb7(%rip), %rsi      # 0x166db
movl $0x1, %edx
callq 0x4330
movq 0x60(%rsp), %r13
movq 0x68(%rsp), %rax
movq %rax, 0x18(%rsp)
cmpq %rax, %r13
je 0xcd88
movl (%r13), %r14d
movl $0x1, %edx
movq 0x10592(%rip), %rdi     # 0x1cfe8
leaq 0x9c7e(%rip), %rsi      # 0x166db
callq 0x4330
movl %r14d, %eax
shrl $0x10, %eax
shlq $0x10, %r14
orq $0xf, %r14
movw %ax, 0x84(%rsp)
movl %r14d, 0x80(%rsp)
movl $0x6, %r12d
xorl %r14d, %r14d
leaq 0x80(%rsp), %r15
movl %r12d, %edx
movl %ebp, %edi
movq %r15, %rsi
callq 0x4100
cmpl $-0x1, %eax
je 0xcab1
addl %eax, %r14d
movslq %eax, %rcx
addq %rcx, %r15
subl %eax, %r12d
jmp 0xcabb
callq 0x4040
cmpl $0x4, (%rax)
jne 0xcacb
testl %r12d, %r12d
jg 0xca91
cmpl $-0x1, %r14d
jne 0xcad4
jmp 0xd1be
testl %r14d, %r14d
jle 0xd1be
movq %rbx, %rdi
movl %ebp, %esi
callq 0xed47
movl 0x400(%rbx), %eax
leal -0x400(%rax), %ecx
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %ecx
cmpb $0x42, (%rbx,%rcx)
jne 0xd183
cmpl $0x3, 0x404(%rbx)
ja 0xcb2f
movq %rbx, %rdi
movl %ebp, %esi
callq 0xef52
testl %eax, %eax
jg 0xcafc
cmpl $-0x1, %eax
jne 0xcb27
callq 0x4040
cmpl $0x4, (%rax)
je 0xcafc
jmp 0xd198
testl %eax, %eax
je 0xd183
movq 0x10(%rsp), %rax
movl (%rax), %r14d
leal 0x2(%r14), %eax
leal -0x3fe(%r14), %r15d
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %r15d
leal -0x3ff(%r15), %eax
movl %r15d, %esi
cmpl $0xfffffbfe, %eax       # imm = 0xFFFFFBFE
movq %r13, 0x20(%rsp)
ja 0xcb9c
movl $0x400, %r12d           # imm = 0x400
subl %r15d, %r12d
addq %rbx, %rsi
leaq 0x4a(%rsp), %r13
movq %r13, %rdi
movq %r12, %rdx
callq 0x4270
leaq (%rsp,%r12), %rdi
addq $0x4a, %rdi
addl $0xfffffc02, %r15d      # imm = 0xFFFFFC02
movq %rbx, %rsi
movq %r15, %rdx
callq 0x4270
movq %r13, %rsi
jmp 0xcb9f
addq %rbx, %rsi
movzwl (%rsi), %r13d
leal 0x4(%r14), %eax
addl $0xfffffc04, %r14d      # imm = 0xFFFFFC04
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %r14d
movl %r14d, 0x400(%rbx)
movl 0x404(%rbx), %eax
addl $-0x4, %eax
movl %eax, 0x404(%rbx)
leaq 0x38(%rsp), %rcx
movq %rcx, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
movb $0x0, 0x38(%rsp)
xorl %edx, %edx
testl %eax, %eax
jne 0xcc21
jmp 0xcbfb
callq 0x4040
cmpl $0x4, (%rax)
jne 0xd08d
movq %rbx, %rdi
movl %ebp, %esi
callq 0xef52
testl %eax, %eax
je 0xd07b
jle 0xcbed
movl 0x400(%rbx), %r14d
movl 0x404(%rbx), %eax
movq 0x30(%rsp), %rdx
movl %eax, %ecx
movq %r13, %r12
subq %rdx, %r12
cmpq %rcx, %r12
cmovaeq %rcx, %r12
leal -0x400(%r14), %ecx
cmpl $0x400, %r14d           # imm = 0x400
cmovbl %r14d, %ecx
leaq (%rbx,%rcx), %rsi
testl %eax, %eax
je 0xcc6d
leal (%rax,%r14), %edx
cmpl $0x400, %edx            # imm = 0x400
leal -0x400(%rax,%r14), %edi
cmovbl %edx, %edi
leal (%rbx,%rdi), %eax
cmpl %ecx, %edi
cmovbel 0x10(%rsp), %eax
subl %esi, %eax
jmp 0xcc6f
xorl %eax, %eax
movl %eax, %r14d
movq %r12, %r15
subq %r14, %r15
jb 0xcd0d
leaq 0x28(%rsp), %r12
movq %r12, %rdi
movq %r14, %rdx
callq 0x4070
movl 0x400(%rbx), %eax
addl %r14d, %eax
movl $0xfffffc00, %esi       # imm = 0xFFFFFC00
leal (%rax,%rsi), %ecx
movl $0x400, %edx            # imm = 0x400
cmpl %edx, %eax
cmovbl %eax, %ecx
movl %ecx, 0x400(%rbx)
subl %r14d, 0x404(%rbx)
addl %ecx, %esi
cmpl %edx, %ecx
cmovbl %ecx, %esi
addq %rbx, %rsi
movq %r12, %rdi
movq %r15, %rdx
callq 0x4070
movl 0x400(%rbx), %ecx
movl 0x404(%rbx), %eax
leal (%rcx,%r15), %edx
cmpl $0x400, %edx            # imm = 0x400
leal -0x400(%rcx,%r15), %r14d
cmovbl %edx, %r14d
movl %r14d, 0x400(%rbx)
subl %r15d, %eax
movl %eax, 0x404(%rbx)
movq 0x30(%rsp), %rdx
cmpq %r13, %rdx
jb 0xcbe7
jmp 0xcd47
leaq 0x28(%rsp), %rdi
movq %r12, %rdx
callq 0x4070
movl 0x400(%rbx), %eax
leal (%rax,%r12), %ecx
cmpl $0x400, %ecx            # imm = 0x400
leal -0x400(%rax,%r12), %eax
cmovbl %ecx, %eax
movl %eax, 0x400(%rbx)
subl %r12d, 0x404(%rbx)
movq 0x30(%rsp), %rdx
movq 0x28(%rsp), %rsi
movq 0x10295(%rip), %rdi     # 0x1cfe8
callq 0x4330
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
movq 0x20(%rsp), %r13
je 0xcd79
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42f0
addq $0x4, %r13
cmpq 0x18(%rsp), %r13
jne 0xca46
movq 0x10259(%rip), %rdi     # 0x1cfe8
leaq 0x9d6a(%rip), %rsi      # 0x16b00
movl $0x1, %edx
callq 0x4330
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0xc71c
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x42f0
jmp 0xc71c
cmpb $0x32, %al
je 0xcdfd
movq 0x1021d(%rip), %rdi     # 0x1cfe8
cmpl $0x45, %ecx
jne 0xce8b
leaq 0x933b(%rip), %rsi      # 0x16116
movl $0x46, %edx
jmp 0xc717
movq 0x101fc(%rip), %rdi     # 0x1cfe8
leaq 0x92b1(%rip), %rsi      # 0x160a4
movl $0x37, %edx
jmp 0xc717
cmpb $0x0, 0xd0(%rsp)
je 0xce97
movzbl 0xe0(%rsp), %r14d
cmpl $0x4, %edx
movq 0x20(%rsp), %r12
jne 0xcf8f
cmpb $0x1, 0x4d(%rsp)
jne 0xcf2b
cmpb $0x0, 0xe0(%rsp)
movb 0xd(%rsp), %r15b
je 0xd12f
movq 0x10161(%rip), %rdi     # 0x1cfa8
leaq 0x922f(%rip), %rsi      # 0x1607d
movl $0x9, %edx
callq 0x4330
movq 0x10149(%rip), %rdi     # 0x1cfa8
movq %r12, %rsi
callq 0x42d0
leaq 0x933a(%rip), %rsi      # 0x161a8
movl $0xb, %edx
movq %rax, %rdi
callq 0x4330
cmpb $0x0, 0x4c(%rsp)
jne 0xcfa9
jmp 0xcff1
leaq 0x92cb(%rip), %rsi      # 0x1615d
jmp 0xc712
xorl %r15d, %r15d
cmpb $0x0, 0xe0(%rsp)
je 0xc722
movq 0x100f9(%rip), %rbx     # 0x1cfa8
leaq 0x92c2(%rip), %rsi      # 0x16178
movl $0x7, %edx
movq %rbx, %rdi
callq 0x4330
leaq 0x8397(%rip), %rax      # 0x15261
leaq 0x990a(%rip), %rsi      # 0x167db
movb 0xd(%rsp), %cl
testb %cl, %cl
cmovneq %rax, %rsi
movzbl %cl, %edx
xorq $0x5, %rdx
movq %rbx, %rdi
callq 0x4330
leaq 0x928f(%rip), %rsi      # 0x16180
movl $0x23, %edx
movq %rbx, %rdi
callq 0x4330
movq 0x20(%rsp), %r14
testq %r14, %r14
je 0xd04c
movq %r14, %rdi
callq 0x4150
movq 0x1008d(%rip), %rdi     # 0x1cfa8
movq %r14, %rsi
movq %rax, %rdx
callq 0x4330
jmp 0xd063
leaq 0x28(%rsp), %rdi
leaq 0x60(%rsp), %rdx
movq %r12, %rsi
callq 0xebda
leaq 0x28(%rsp), %rcx
movl %ebp, %edi
movq %rbx, %rsi
movl %r13d, %edx
movl $0x1, %r8d
movl %r14d, 0x18(%rsp)
movl %r14d, %r9d
callq 0xd2f3
movl %eax, %r14d
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xcf7b
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42f0
movl $0x1, %r15d
testl %r14d, %r14d
movl 0x18(%rsp), %r14d
jne 0xc722
cmpb $0x0, 0x4c(%rsp)
movb 0xd(%rsp), %r15b
je 0xcff1
cmpb $0x0, 0xe0(%rsp)
je 0xd12f
movl %r14d, 0x18(%rsp)
movq 0xfff3(%rip), %r14      # 0x1cfa8
leaq 0x90c1(%rip), %rsi      # 0x1607d
movl $0x9, %edx
movq %r14, %rdi
callq 0x4330
testq %r12, %r12
je 0xd0b0
movq %r12, %rdi
callq 0x4150
movq 0xffc7(%rip), %rdi      # 0x1cfa8
movq %r12, %rsi
movq %rax, %rdx
callq 0x4330
jmp 0xd0c8
movb 0xe0(%rsp), %al
andb 0x4e(%rsp), %al
cmpb $0x1, %al
jne 0xd12f
movl %r14d, 0x18(%rsp)
movq 0xff98(%rip), %r14      # 0x1cfa8
leaq 0x9066(%rip), %rsi      # 0x1607d
movl $0x9, %edx
movq %r14, %rdi
callq 0x4330
testq %r12, %r12
je 0xd0e2
movq %r12, %rdi
callq 0x4150
movq 0xff6c(%rip), %rdi      # 0x1cfa8
movq %r12, %rsi
movq %rax, %rdx
callq 0x4330
jmp 0xd0fa
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x44c0
movq 0xff3e(%rip), %rdi      # 0x1cfa8
leaq 0x9133(%rip), %rsi      # 0x161a4
movl $0x3, %edx
jmp 0xc7db
movl $0x4, %edi
callq 0x4190
movl $0x0, (%rax)
jmp 0xd09f
movq %rax, %r14
movl $0x4, %edi
callq 0x4190
movl (%r14), %ecx
movl %ecx, (%rax)
leaq 0xfa9a(%rip), %rsi      # 0x1cb40
movq %rax, %rdi
xorl %edx, %edx
callq 0x44d0
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x44c0
movq 0xfed9(%rip), %rdi      # 0x1cfa8
leaq 0x90de(%rip), %rsi      # 0x161b4
movl $0xb, %edx
callq 0x4330
jmp 0xd12a
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x44c0
movq 0xfea7(%rip), %rdi      # 0x1cfa8
leaq 0x90b8(%rip), %rsi      # 0x161c0
movl $0x13, %edx
callq 0x4330
movl 0x50(%rsp), %edi
movl 0x54(%rsp), %edx
movl 0x58(%rsp), %ecx
movl 0x5c(%rsp), %r8d
xorl %esi, %esi
callq 0xd4b4
movl 0x18(%rsp), %r14d
leaq 0x28(%rsp), %rdi
leaq 0x60(%rsp), %rdx
movq %r12, %rsi
callq 0xebda
xorl %r8d, %r8d
movb %r15b, %r8b
leaq 0x28(%rsp), %rcx
movl %ebp, %edi
movq %rbx, %rsi
movl %r13d, %edx
movl %r14d, %r9d
callq 0xd2f3
movl %eax, %r15d
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xc722
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42f0
jmp 0xc722
movl $0x4, %edi
callq 0x4190
movq %rax, %rbx
movl $0x0, (%rax)
jmp 0xd1ad
movq %rax, %r14
movl $0x4, %edi
callq 0x4190
movq %rax, %rbx
movl (%r14), %eax
movl %eax, (%rbx)
leaq 0xf98c(%rip), %rsi      # 0x1cb40
movq %rbx, %rdi
xorl %edx, %edx
callq 0x44d0
movl $0x4, %edi
callq 0x4190
movq %rax, %rbx
callq 0x4040
movl (%rax), %eax
movl %eax, (%rbx)
leaq 0xf975(%rip), %rsi      # 0x1cb50
jmp 0xd1b4
jmp 0xd1e1
jmp 0xd1fc
movq %rax, %rbx
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xd24c
movq 0x38(%rsp), %rsi
incq %rsi
jmp 0xd247
movq %rax, %rbx
jmp 0xd24c
jmp 0xd20f
jmp 0xd20f
jmp 0xd216
jmp 0xd216
jmp 0xd20f
jmp 0xd20f
jmp 0xd20f
movq %rax, %rbx
jmp 0xd235
jmp 0xd216
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0xd235
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42f0
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0xd24c
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x42f0
movq %rbx, %rdi
callq 0x44f0