// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/control.cc
// Function: control_conn_t::process_set_trigger()
bool control_conn_t::process_set_trigger()
{
    // 1 byte packet type
    // handle: service
    // 1 byte trigger value
    constexpr int pkt_size = 2 + sizeof(handle_t);

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

    handle_t handle;
    trigger_val_t trigger_val;

    rbuf.extract(&handle, 1, sizeof(handle));
    rbuf.extract(&trigger_val, 1 + sizeof(handle), sizeof(trigger_val));
    rbuf.consume(pkt_size);
    chklen = 0;

    service_record *service = find_service_for_key(handle);
    if (service == nullptr || service->get_type() != service_type_t::TRIGGERED) {
        char nak_rep[] = { (char)cp_rply::NAK };
        return queue_packet(nak_rep, 1);
    }

    triggered_service *tservice = static_cast<triggered_service *>(service);
    tservice->set_trigger(trigger_val != 0);
    services->process_queues();

    char ack_rep[] = { (char)cp_rply::ACK };
    return queue_packet(ack_rep, 1);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
cmpl $0x5, 0x484(%rdi)
ja 0x2a631
movl $0x6, 0x7c(%rbx)
movb $0x1, %al
jmp 0x2a7a1
leaq 0x80(%rbx), %r14
movl 0x480(%rbx), %r15d
leal 0x1(%r15), %eax
addl $0xfffffc01, %r15d      # imm = 0xFFFFFC01
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %r15d
leal -0x3fd(%r15), %eax
cmpl $0xfffffbfe, %eax       # imm = 0xFFFFFBFE
ja 0x2a69a
movl $0x400, %r12d           # imm = 0x400
subl %r15d, %r12d
movl %r15d, %esi
addq %r14, %rsi
leaq 0xc(%rsp), %r13
movq %r13, %rdi
movq %r12, %rdx
callq 0x84d0
addq %r13, %r12
addl $0xfffffc04, %r15d      # imm = 0xFFFFFC04
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x84d0
jmp 0x2a6a5
movl %r15d, %eax
movl (%r14,%rax), %eax
movl %eax, 0xc(%rsp)
movl 0x480(%rbx), %r15d
leal 0x5(%r15), %eax
addl $0xfffffc05, %r15d      # imm = 0xFFFFFC05
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %r15d
leal -0x400(%r15), %eax
cmpl $0xfffffbfe, %eax       # imm = 0xFFFFFBFE
ja 0x2a707
movl $0x400, %r12d           # imm = 0x400
subl %r15d, %r12d
movl %r15d, %esi
addq %r14, %rsi
leaq 0x9(%rsp), %r13
movq %r13, %rdi
movq %r12, %rdx
callq 0x84d0
addq %r13, %r12
addl $0xfffffc01, %r15d      # imm = 0xFFFFFC01
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x84d0
jmp 0x2a712
movl %r15d, %eax
movb (%r14,%rax), %al
movb %al, 0x9(%rsp)
movl 0x480(%rbx), %eax
leal 0x6(%rax), %ecx
addl $0xfffffc06, %eax       # imm = 0xFFFFFC06
cmpl $0x400, %ecx            # imm = 0x400
cmovbl %ecx, %eax
movl %eax, 0x480(%rbx)
addl $-0x6, 0x484(%rbx)
movl $0x0, 0x7c(%rbx)
movl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0x2ba66
testq %rax, %rax
je 0x2a78c
cmpl $0x5, 0x28(%rax)
jne 0x2a78c
cmpb $0x0, 0x9(%rsp)
setne 0x208(%rax)
je 0x2a779
cmpb $0x1, 0x2c(%rax)
jne 0x2a779
testb $0x10, 0x10c(%rax)
jne 0x2a779
movq %rax, %rdi
callq 0x233ac
movq 0x70(%rbx), %rdi
callq 0xd8da
leaq 0xa(%rsp), %rsi
movb $0x32, (%rsi)
jmp 0x2a794
leaq 0xb(%rsp), %rsi
movb $0x33, (%rsi)
movq %rbx, %rdi
movl $0x1, %edx
callq 0x27fd2
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
nop