// File: /workspace/github_cpp_makefile_star2_O1/lszp[P]SmallWebServer/http/http_conn.cpp
// Function: http_conn::write()
bool http_conn::write()
{
    int temp = 0;

    if (bytes_to_send == 0)
    {
        modfd(m_epollfd, m_sockfd, EPOLLIN, m_TRIGMode);
        init();
        return true;
    }

    while (1)
    {
        temp = writev(m_sockfd, m_iv, m_iv_count);

        if (temp < 0)
        {
            if (errno == EAGAIN)
            {
                modfd(m_epollfd, m_sockfd, EPOLLOUT, m_TRIGMode);
                return true;
            }
            unmap();
            return false;
        }

        bytes_have_send += temp;
        bytes_to_send -= temp;
        if (bytes_have_send >= m_iv[0].iov_len)
        {
            m_iv[0].iov_len = 0;
            m_iv[1].iov_base = m_file_address + (bytes_have_send - m_write_idx);
            m_iv[1].iov_len = bytes_to_send;
        }
        else
        {
            m_iv[0].iov_base = m_write_buf + bytes_have_send;
            m_iv[0].iov_len = m_iv[0].iov_len - bytes_have_send;
        }

        if (bytes_to_send <= 0)
        {
            unmap();
            modfd(m_epollfd, m_sockfd, EPOLLIN, m_TRIGMode);

            if (m_linger)
            {
                init();
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
cmpl $0x0, 0xdf0(%rdi)
je 0x5ced
leaq 0xdc0(%rbx), %r14
leaq 0x834(%rbx), %r15
movl 0x14(%rbx), %edi
movl 0xde0(%rbx), %edx
movq %r14, %rsi
callq 0x3240
testl %eax, %eax
js 0x5d50
movslq 0xdf4(%rbx), %rcx
movslq %eax, %rdx
addq %rdx, %rcx
movl %ecx, 0xdf4(%rbx)
movslq 0xdf0(%rbx), %rax
subq %rdx, %rax
movl %eax, 0xdf0(%rbx)
movq 0xdc8(%rbx), %rdx
subq %rcx, %rdx
jbe 0x5c44
addq %r15, %rcx
movq %rcx, 0xdc0(%rbx)
movq %rdx, 0xdc8(%rbx)
jmp 0x5c71
movq $0x0, 0xdc8(%rbx)
movslq 0xc34(%rbx), %rdx
movslq %ecx, %rcx
subq %rdx, %rcx
addq 0xd28(%rbx), %rcx
movq %rcx, 0xdd0(%rbx)
movq %rax, 0xdd8(%rbx)
testl %eax, %eax
jg 0x5be9
movq 0xd28(%rbx), %rdi
testq %rdi, %rdi
je 0x5c9c
movq 0xd60(%rbx), %rsi
callq 0x3270
movq $0x0, 0xd28(%rbx)
movl 0x879e(%rip), %edi      # 0xe440
movl 0x14(%rbx), %edx
movl 0xe34(%rbx), %eax
leaq 0x4(%rsp), %rcx
movl %edx, 0x4(%rcx)
xorl %esi, %esi
cmpl $0x1, %eax
setne %sil
shll $0x1f, %esi
addl $0xc0002001, %esi       # imm = 0xC0002001
movl %esi, (%rcx)
movl $0x3, %esi
callq 0x35b0
xorl %eax, %eax
cmpb $0x1, 0xd24(%rbx)
jne 0x5d91
movq $0x0, 0xdf0(%rbx)
jmp 0x5d2f
movl 0x874d(%rip), %edi      # 0xe440
movl 0x14(%rbx), %edx
movl 0xe34(%rbx), %eax
leaq 0x4(%rsp), %rcx
movl %edx, 0x4(%rcx)
xorl %esi, %esi
cmpl $0x1, %eax
setne %sil
shll $0x1f, %esi
addl $0xc0002001, %esi       # imm = 0xC0002001
movl %esi, (%rcx)
movl $0x3, %esi
callq 0x35b0
movq $0x0, 0xdf0(%rbx)
xorl %eax, %eax
movl %eax, 0xde4(%rbx)
leaq 0x28(%rbx), %rdi
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movl %eax, 0x10(%rbx)
movl $0xcfd, %edx            # imm = 0xCFD
xorl %esi, %esi
callq 0x3260
jmp 0x5d8f
callq 0x3060
cmpl $0xb, (%rax)
jne 0x5d9b
movl 0x86e0(%rip), %edi      # 0xe440
movl 0x14(%rbx), %edx
movl 0xe34(%rbx), %eax
leaq 0x4(%rsp), %rcx
movl %edx, 0x4(%rcx)
xorl %esi, %esi
cmpl $0x1, %eax
setne %sil
shll $0x1f, %esi
addl $0xc0002004, %esi       # imm = 0xC0002004
movl %esi, (%rcx)
movl $0x3, %esi
callq 0x35b0
movb $0x1, %al
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq 0xd28(%rbx), %rdi
testq %rdi, %rdi
je 0x5dbe
movq 0xd60(%rbx), %rsi
callq 0x3270
movq $0x0, 0xd28(%rbx)
xorl %eax, %eax
jmp 0x5d91