// File: /workspace/github_cpp_makefile_star2_O1/lega911[P]ijson/src/connect.cpp
// Function: Connect::on_send()
void Connect::on_send() {
    if(send_buffer.size()) {
        int sent = this->raw_send(send_buffer.ptr(), send_buffer.size());
        if(sent < 0) THROW("Not implemented: sent < 0");
        send_buffer.remove_left(sent);
    } else if(!direct_message.empty()) {
        if(server->log & 32) this->start_time = get_time();
        auto *dm = direct_message.front();
        direct_message.pop_front();
        GC gc(dm, GC::DirectMessage);

        int sent = this->raw_send(dm->data.ptr(), dm->data.size());
        if(sent < 0) THROW("Not implemented: sent < 0");

        if(sent != dm->data.size()) send_buffer.add(&dm->data.ptr()[sent], dm->data.size() - sent);
    }

    if(send_buffer.size() == 0) {
        if(this->keep_alive) {
            this->write_mode(false);
        } else {
            this->close();
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movl 0x28(%rdi), %edx
testq %rdx, %rdx
je 0x8b3d
movq 0x20(%rbx), %rsi
movl 0xc(%rbx), %edi
xorl %ecx, %ecx
callq 0x8180
testl %eax, %eax
jle 0x8b05
movl %eax, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq 0x30(%rbx), %rdx
addq %rcx, 0x98(%rdx)
testl %eax, %eax
js 0x8c31
je 0x8bf1
movl 0x28(%rbx), %ecx
subl %eax, %ecx
jle 0x8bea
movl %ecx, 0x28(%rbx)
movq 0x20(%rbx), %rdi
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addq %rdi, %rax
movslq %ecx, %rdx
movq %rax, %rsi
callq 0x8440
jmp 0x8bf1
movq 0x1c0(%rbx), %rax
cmpq 0x1a0(%rbx), %rax
je 0x8bf1
leaq 0x190(%rbx), %r15
movq 0x48(%rbx), %rax
testb $0x20, 0x20(%rax)
je 0x8b6e
callq 0x164e8
movq %rax, 0x1e0(%rbx)
movq 0x1a0(%rbx), %rax
movq (%rax), %r14
movq %r15, %rdi
callq 0xc00e
leaq -0x30(%rbp), %rdi
movq %r14, %rsi
movl $0x2, %edx
callq 0xc066
movq 0x28(%r14), %rsi
movl 0x30(%r14), %edx
movl 0xc(%rbx), %edi
xorl %ecx, %ecx
callq 0x8180
testl %eax, %eax
jle 0x8bba
movl %eax, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq 0x30(%rbx), %rdx
addq %rcx, 0x98(%rdx)
testl %eax, %eax
js 0x8c76
movl 0x30(%r14), %edx
subl %eax, %edx
je 0x8bdf
leaq 0x20(%rbx), %rdi
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addq 0x28(%r14), %rax
movq %rax, %rsi
callq 0xc0a8
leaq -0x30(%rbp), %rdi
callq 0xc13a
jmp 0x8bf1
movl $0x0, 0x28(%rbx)
cmpl $0x0, 0x28(%rbx)
jne 0x8c26
cmpb $0x1, 0x10(%rbx)
jne 0x8c20
movl (%rbx), %eax
testb $0x2, %al
je 0x8c26
andl $0xfd, %eax
movl %eax, (%rbx)
movq 0x30(%rbx), %rdi
addq $0x60, %rdi
leaq -0x30(%rbp), %rsi
movq %rbx, (%rsi)
callq 0xc7c6
jmp 0x8c26
movl $0xffffffff, (%rbx)     # imm = 0xFFFFFFFF
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl $0x30, %edi
callq 0x8170
movq %rax, %r14
leaq 0xe433(%rip), %rsi      # 0x17078
leaq 0xe405(%rip), %rdx      # 0x17051
leaq 0xe43f(%rip), %r8       # 0x17092
movq %rax, %rdi
movl $0x2e, %ecx
callq 0xcd04
leaq 0x150b1(%rip), %rsi     # 0x1dd18
leaq 0x46a2(%rip), %rdx      # 0xd310
movq %r14, %rdi
callq 0x8480
movl $0x30, %edi
callq 0x8170
movq %rax, %r14
leaq 0xe3ee(%rip), %rsi      # 0x17078
leaq 0xe3c0(%rip), %rdx      # 0x17051
leaq 0xe3fa(%rip), %r8       # 0x17092
movq %rax, %rdi
movl $0x37, %ecx
callq 0xcd04
leaq 0x1506c(%rip), %rsi     # 0x1dd18
leaq 0x465d(%rip), %rdx      # 0xd310
movq %r14, %rdi
callq 0x8480
movq %rax, %rbx
movq %r14, %rdi
callq 0x8220
jmp 0x8cd8
movq %rax, %rbx
movq %r14, %rdi
callq 0x8220
jmp 0x8ce1
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0xc13a
movq %rbx, %rdi
callq 0x84a0
nop