// File: /workspace/github_cpp_makefile_star2_O3/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 0x8b2b
movq 0x20(%rbx), %rsi
movl 0xc(%rbx), %edi
xorl %ecx, %ecx
callq 0x8180
testl %eax, %eax
jle 0x8baa
movl %eax, %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movq 0x30(%rbx), %rcx
addq %rsi, 0x98(%rcx)
movl 0x28(%rbx), %ecx
subl %eax, %ecx
jle 0x8bf1
movl %ecx, 0x28(%rbx)
movq 0x20(%rbx), %rdi
addq %rdi, %rsi
movslq %ecx, %rdx
callq 0x8440
jmp 0x8c1c
movq 0x1a0(%rbx), %rax
cmpq %rax, 0x1c0(%rbx)
je 0x8c1c
leaq 0x190(%rbx), %r15
movq 0x48(%rbx), %rcx
testb $0x20, 0x20(%rcx)
je 0x8b63
callq 0x163ac
movq %rax, 0x1e0(%rbx)
movq 0x1a0(%rbx), %rax
movq (%rax), %r14
movq %r15, %rdi
callq 0xc068
leaq -0x30(%rbp), %rdi
movq %r14, %rsi
movl $0x2, %edx
callq 0xc0c0
movq 0x28(%r14), %rsi
movl 0x30(%r14), %edx
movl 0xc(%rbx), %edi
xorl %ecx, %ecx
callq 0x8180
testl %eax, %eax
jle 0x8bfa
movl %eax, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq 0x30(%rbx), %rdx
addq %rcx, 0x98(%rdx)
jmp 0x8bfc
jns 0x8c1c
movl $0x30, %edi
callq 0x8170
movq %rax, %r14
leaq 0xe4b8(%rip), %rsi      # 0x17078
leaq 0xe48a(%rip), %rdx      # 0x17051
leaq 0xe4c4(%rip), %r8       # 0x17092
movq %rax, %rdi
movl $0x2e, %ecx
callq 0xcd04
leaq 0x15136(%rip), %rsi     # 0x1dd18
leaq 0x4727(%rip), %rdx      # 0xd310
movq %r14, %rdi
callq 0x8480
movl $0x0, 0x28(%rbx)
jmp 0x8c22
js 0x8c5c
movl 0x30(%r14), %edx
subl %eax, %edx
je 0x8c13
leaq 0x20(%rbx), %rdi
movl %eax, %esi
addq 0x28(%r14), %rsi
callq 0xc102
leaq -0x30(%rbp), %rdi
callq 0xc194
cmpl $0x0, 0x28(%rbx)
jne 0x8c51
cmpb $0x1, 0x10(%rbx)
jne 0x8c4b
movl (%rbx), %eax
testb $0x2, %al
je 0x8c51
andl $0xfd, %eax
movl %eax, (%rbx)
movq 0x30(%rbx), %rdi
addq $0x60, %rdi
leaq -0x30(%rbp), %rsi
movq %rbx, (%rsi)
callq 0xc7ba
jmp 0x8c51
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 0xe408(%rip), %rsi      # 0x17078
leaq 0xe3da(%rip), %rdx      # 0x17051
leaq 0xe414(%rip), %r8       # 0x17092
movq %rax, %rdi
movl $0x37, %ecx
callq 0xcd04
leaq 0x15086(%rip), %rsi     # 0x1dd18
leaq 0x4677(%rip), %rdx      # 0xd310
movq %r14, %rdi
callq 0x8480
movq %rax, %rbx
movq %r14, %rdi
callq 0x8220
jmp 0x8cbe
movq %rax, %rbx
movq %r14, %rdi
callq 0x8220
jmp 0x8cc7
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0xc194
movq %rbx, %rdi
callq 0x84a0
nop