// File: /workspace/github_cpp_makefile_star2_O2/davmac314[P]dinit/src/control.cc
// Function: control_conn_t::rm_service_dep()
bool control_conn_t::rm_service_dep()
{
    // 1 byte packet type
    // 1 byte dependency type
    // handle: "from"
    // handle: "to"

    constexpr int pkt_size = 2 + sizeof(handle_t) * 2;

    if (rbuf.get_length() < pkt_size) {
        chklen = pkt_size;
        return true;
    }

    handle_t from_handle;
    handle_t to_handle;
    rbuf.extract((char *) &from_handle, 2, sizeof(from_handle));
    rbuf.extract((char *) &to_handle, 2 + sizeof(from_handle), sizeof(to_handle));

    service_record *from_service = find_service_for_key(from_handle);
    service_record *to_service = find_service_for_key(to_handle);
    if (from_service == nullptr || to_service == nullptr || from_service == to_service) {
        // Service handle is bad
        char badreq_rep[] = { (char)cp_rply::BADREQ };
        if (! queue_packet(badreq_rep, 1)) return false;
        bad_conn_close = true;
        return true;
    }

    // Check dependency type is valid:
    int dep_type_int = rbuf[1];
    if (! contains({dependency_type::MILESTONE, dependency_type::REGULAR,
            dependency_type::WAITS_FOR}, dep_type_int)) {
        char badreqRep[] = { (char)cp_rply::BADREQ };
        if (! queue_packet(badreqRep, 1)) return false;
        bad_conn_close = true;
    }
    dependency_type dep_type = static_cast<dependency_type>(dep_type_int);

    // Remove dependency:
    bool did_remove = from_service->rm_dep(to_service, dep_type);
    services->process_queues();

    char ack_rep[] = { did_remove ? (char)cp_rply::ACK : (char)cp_rply::NAK };
    if (! queue_packet(ack_rep, 1)) return false;
    rbuf.consume(pkt_size);
    chklen = 0;
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
cmpl $0x9, 0x484(%rdi)
ja 0x247ef
movl $0xa, 0x7c(%rbx)
movb $0x1, %bpl
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x80(%rbx), %r14
leaq 0xc(%rsp), %r15
pushq $0x2
popq %rdx
pushq $0x4
popq %rbp
movq %r14, %rdi
movq %r15, %rsi
movl %ebp, %ecx
callq 0x25e18
leaq 0x8(%rsp), %r12
pushq $0x6
popq %rdx
movq %r14, %rdi
movq %r12, %rsi
movl %ebp, %ecx
callq 0x25e18
movl (%r15), %esi
movq %rbx, %rdi
callq 0x26056
movq %rax, %r15
movl (%r12), %esi
movq %rbx, %rdi
callq 0x26056
cmpq %rax, %r15
je 0x248cf
testq %r15, %r15
je 0x248cf
movq %rax, %r12
testq %rax, %rax
je 0x248cf
movl 0x480(%rbx), %eax
leal 0x1(%rax), %ecx
addl $0xfffffc01, %eax       # imm = 0xFFFFFC01
cmpl $0x400, %ecx            # imm = 0x400
cmovbl %ecx, %eax
movzbl 0x80(%rbx,%rax), %ebp
cmpl $0x3, %ebp
ja 0x248f5
cmpl $0x1, %ebp
je 0x248f5
movsbl %bpl, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x26296
movl %eax, %ebp
movq 0x70(%rbx), %rdi
callq 0xcdd2
xorb $0x33, %bpl
leaq 0x5(%rsp), %rsi
movb %bpl, (%rsi)
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x234ec
movl %eax, %ebp
testb %al, %al
je 0x247e0
pushq $0xa
popq %rsi
movq %r14, %rdi
callq 0x25df2
andl $0x0, 0x7c(%rbx)
jmp 0x247e0
leaq 0x7(%rsp), %rsi
movb $0x34, (%rsi)
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x234ec
movl %eax, %ebp
testb %al, %al
je 0x247e0
movb $0x1, 0x78(%rbx)
jmp 0x247e0
leaq 0x6(%rsp), %rsi
movb $0x34, (%rsi)
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x234ec
testb %al, %al
je 0x24915
movb $0x1, 0x78(%rbx)
jmp 0x24880
xorl %ebp, %ebp
jmp 0x247e0