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

    handle_t handle;
    
    // Build buffer;
    if (! load_service(socknum, rbuffer, service_name, &handle, nullptr)) {
        return 1;
    }
    
    // Issue UNPIN command.
    {
        auto m = membuf()
                .append((char)cp_cmd::UNPINSERVICE)
                .append(handle);
        write_all_x(socknum, m);
        
        wait_for_reply(rbuffer, socknum);
        if (rbuffer[0] != (char)cp_rply::ACK) {
            cerr << "dinitctl: protocol error.\n";
            return 1;
        }
        rbuffer.consume(1);
    }

    if (verbose) {
        cout << "Service '" << service_name << "' unpinned.\n";
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %ebp
movq %rdx, %rbx
movq %rsi, %r14
movl %edi, %r15d
xorl %r13d, %r13d
leaq 0x4(%rsp), %rcx
movl $0x1, %r12d
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0xd198
testb %al, %al
je 0x9af0
movl %ebp, (%rsp)
movq %rbx, 0x8(%rsp)
movl 0x4(%rsp), %eax
movq %rax, %rcx
shlq $0x8, %rcx
orq $0x7, %rcx
shrl $0x18, %eax
leaq 0x10(%rsp), %r12
movb %al, 0x4(%r12)
movl %ecx, (%r12)
movl $0x5, %ebp
movl %ebp, %edx
movl %r15d, %edi
movq %r12, %rsi
callq 0x4100
cmpl $-0x1, %eax
je 0x99c6
addl %eax, %r13d
movslq %eax, %rcx
addq %rcx, %r12
subl %eax, %ebp
xorl %ecx, %ecx
jmp 0x99e6
callq 0x4040
movl $0x2, %ecx
cmpl $0x4, (%rax)
je 0x99e6
testl %r13d, %r13d
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmovgl %r13d, %ebx
movl $0x1, %ecx
testb $0x1, %cl
jne 0x99f1
testl %ebp, %ebp
jg 0x99a5
jmp 0x99f4
movl %ebx, %r13d
cmpl $-0x1, %r13d
je 0x9b02
movq %r14, %rdi
movl %r15d, %esi
callq 0xedbd
movl 0x400(%r14), %eax
leal -0x400(%rax), %ecx
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %ecx
movb (%r14,%rcx), %bl
cmpb $0x32, %bl
movl (%rsp), %ebp
jne 0x9a4b
leal 0x1(%rax), %ecx
addl $0xfffffc01, %eax       # imm = 0xFFFFFC01
cmpl $0x400, %ecx            # imm = 0x400
cmovbl %ecx, %eax
movl %eax, 0x400(%r14)
decl 0x404(%r14)
jmp 0x9a63
movq 0x13596(%rip), %rdi     # 0x1cfe8
leaq 0xc719(%rip), %rsi      # 0x16172
movl $0x1a, %edx
callq 0x4330
xorl %r12d, %r12d
cmpb $0x32, %bl
setne %al
sete %cl
andb %bpl, %cl
cmpb $0x1, %cl
jne 0x9ab8
movq 0x1352a(%rip), %r14     # 0x1cfa8
leaq 0xc60d(%rip), %rsi      # 0x16092
movl $0x9, %edx
movq %r14, %rdi
callq 0x4330
movq 0x8(%rsp), %rbx
testq %rbx, %rbx
je 0x9abd
movq %rbx, %rdi
callq 0x4150
movq 0x134fd(%rip), %rdi     # 0x1cfa8
movq %rbx, %rsi
movq %rax, %rdx
callq 0x4330
jmp 0x9ad5
movb %al, %r12b
jmp 0x9af0
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x44c0
movq 0x134cc(%rip), %rdi     # 0x1cfa8
leaq 0xcaf1(%rip), %rsi      # 0x165d4
movl $0xc, %edx
callq 0x4330
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x4, %edi
callq 0x4190
movq %rax, %rbx
callq 0x4040
movl (%rax), %eax
movl %eax, (%rbx)
leaq 0x13031(%rip), %rsi     # 0x1cb50
movq %rbx, %rdi
xorl %edx, %edx
callq 0x44d0