// File: shaovie[P]reactor/src/io_handle.cpp
// Function: io_handle::sync_ordered_send(async_send_buf&)
void io_handle::sync_ordered_send(async_send_buf &asb) {
    if (this->fd == -1) {
        delete[] asb.buf;
        return;
    }
    this->async_send_buf_size += (asb.len - asb.sendn);
    if (this->async_send_buf_q != nullptr && !this->async_send_buf_q->empty()) {
        this->async_send_buf_q->push_back(asb);
        return ;
    }

    int ret = 0;
    do {
        ret = ::send(this->fd, asb.buf + asb.sendn, asb.len - asb.sendn, 0);
    } while (ret == -1 && errno == EINTR);

    if (ret > 0) { // partial
        this->async_send_buf_size -= ret;
        if (ret == (asb.len - asb.sendn)) {
            delete[] asb.buf;
            return ;
        }
        asb.sendn += ret;
    }
    if (this->async_send_buf_q == nullptr)
        this->async_send_buf_q = new ringq<async_send_buf>(2);
    this->async_send_buf_q->push_back(asb);
    if (this->async_send_polling == false) {
        this->poll->append(this->fd, ev_handler::ev_write);
        this->async_send_polling = true;
    }
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x28(%rsp)
cmpl $-0x1, 0x8(%rax)
jne 0x1f7b1
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, %rax
je 0x1f7ac
movq 0x20(%rsp), %rdi
callq 0x155c0
jmp 0x1f95b
movq 0x28(%rsp), %rax
movq 0x48(%rsp), %rcx
movl 0x4(%rcx), %ecx
movq 0x48(%rsp), %rdx
subl (%rdx), %ecx
addl 0x34(%rax), %ecx
movl %ecx, 0x34(%rax)
cmpq $0x0, 0x38(%rax)
je 0x1f7fc
movq 0x28(%rsp), %rax
movq 0x38(%rax), %rdi
callq 0x141f0
testb $0x1, %al
jne 0x1f7fc
movq 0x28(%rsp), %rax
movq 0x38(%rax), %rdi
movq 0x48(%rsp), %rsi
callq 0x15400
jmp 0x1f95b
movl $0x0, 0x44(%rsp)
movq 0x28(%rsp), %rax
movl 0x8(%rax), %edi
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rsi
movq 0x48(%rsp), %rax
movslq (%rax), %rax
addq %rax, %rsi
movq 0x48(%rsp), %rax
movl 0x4(%rax), %eax
movq 0x48(%rsp), %rcx
subl (%rcx), %eax
movslq %eax, %rdx
xorl %ecx, %ecx
callq 0x14820
movl %eax, 0x44(%rsp)
xorl %eax, %eax
cmpl $-0x1, 0x44(%rsp)
movb %al, 0x1f(%rsp)
jne 0x1f859
callq 0x140c0
cmpl $0x4, (%rax)
sete %al
movb %al, 0x1f(%rsp)
movb 0x1f(%rsp), %al
testb $0x1, %al
jne 0x1f804
cmpl $0x0, 0x44(%rsp)
jle 0x1f8c0
movq 0x28(%rsp), %rax
movl 0x44(%rsp), %edx
movl 0x34(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x34(%rax)
movl 0x44(%rsp), %eax
movq 0x48(%rsp), %rcx
movl 0x4(%rcx), %ecx
movq 0x48(%rsp), %rdx
subl (%rdx), %ecx
cmpl %ecx, %eax
jne 0x1f8b3
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, %rax
je 0x1f8ae
movq 0x10(%rsp), %rdi
callq 0x155c0
jmp 0x1f95b
movl 0x44(%rsp), %ecx
movq 0x48(%rsp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
movq 0x28(%rsp), %rax
cmpq $0x0, 0x38(%rax)
jne 0x1f917
movl $0x18, %edi
callq 0x15120
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x8(%rsp)
movl $0x2, %esi
callq 0x150c0
jmp 0x1f8ed
movq 0x28(%rsp), %rax
movq 0x8(%rsp), %rcx
movq %rcx, 0x38(%rax)
jmp 0x1f917
movq 0x8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x38(%rsp)
movl %eax, 0x34(%rsp)
callq 0x15060
jmp 0x1f960
movq 0x28(%rsp), %rax
movq 0x38(%rax), %rdi
movq 0x48(%rsp), %rsi
callq 0x15400
movq 0x28(%rsp), %rax
movb 0x30(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x1f95b
movq 0x28(%rsp), %rax
movq 0x18(%rax), %rdi
movl 0x8(%rax), %esi
movl $0x4, %edx
callq 0x14750
movq 0x28(%rsp), %rax
movb $0x1, 0x30(%rax)
addq $0x58, %rsp
retq
movq 0x38(%rsp), %rdi
callq 0x15ce0
nopw (%rax,%rax)