// File: JianjiaoSQ[P]MyPoorWebServer/http/http_conn.cpp
// Function: http_conn::process_write(http_conn::HTTP_CODE)
bool http_conn::process_write(HTTP_CODE ret)
{
    switch (ret)
    {
    case INTERNAL_ERROR:
    {
        add_status_line(500, error_500_title);
        add_headers(strlen(error_500_form));
        if (!add_content(error_500_form))
            return false;
        break;
    }
    case BAD_REQUEST:
    {
        add_status_line(404, error_404_title);
        add_headers(strlen(error_404_form));
        if (!add_content(error_404_form))
            return false;
        break;
    }
    case FORBIDDEN_REQUEST:
    {
        add_status_line(403, error_403_title);
        add_headers(strlen(error_403_form));
        if (!add_content(error_403_form))
            return false;
        break;
    }
    case FILE_REQUEST:
    {
        add_status_line(200, ok_200_title);
        if (m_file_stat.st_size != 0)
        {
            add_headers(m_file_stat.st_size);
            m_iv[0].iov_base = m_write_buf;
            m_iv[0].iov_len = m_write_idx;
            m_iv[1].iov_base = m_file_address;
            m_iv[1].iov_len = m_file_stat.st_size;
            m_iv_count = 2;
            bytes_to_send = m_write_idx + m_file_stat.st_size;
            return true;
        }
        else
        {
            const char *ok_string = "<html><body></body></html>";
            add_headers(strlen(ok_string));
            if (!add_content(ok_string))
                return false;
        }
    }
    default:
        return false;
    }
    m_iv[0].iov_base = m_write_buf;
    m_iv[0].iov_len = m_write_idx;
    m_iv_count = 1;
    bytes_to_send = m_write_idx;
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movl -0x14(%rbp), %eax
addl $-0x2, %eax
movl %eax, %ecx
movq %rcx, -0x28(%rbp)
subl $0x4, %eax
ja 0x6c4c
movq -0x28(%rbp), %rax
leaq 0x7645(%rip), %rcx      # 0xe0cc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x30(%rbp), %rdi
movq 0xd9b5(%rip), %rdx      # 0x14450
movl $0x1f4, %esi            # imm = 0x1F4
callq 0x68a0
movq 0xd9ac(%rip), %rdi      # 0x14458
callq 0x31b0
movq -0x30(%rbp), %rdi
movl %eax, %esi
callq 0x68e0
movq -0x30(%rbp), %rdi
movq 0xd991(%rip), %rsi      # 0x14458
callq 0x6a20
testb $0x1, %al
jne 0x6ad9
movb $0x0, -0x1(%rbp)
jmp 0x6c8f
jmp 0x6c52
movq -0x30(%rbp), %rdi
movq 0xd957(%rip), %rdx      # 0x14440
movl $0x194, %esi            # imm = 0x194
callq 0x68a0
movq 0xd94e(%rip), %rdi      # 0x14448
callq 0x31b0
movq -0x30(%rbp), %rdi
movl %eax, %esi
callq 0x68e0
movq -0x30(%rbp), %rdi
movq 0xd933(%rip), %rsi      # 0x14448
callq 0x6a20
testb $0x1, %al
jne 0x6b27
movb $0x0, -0x1(%rbp)
jmp 0x6c8f
jmp 0x6c52
movq -0x30(%rbp), %rdi
movq 0xd8f9(%rip), %rdx      # 0x14430
movl $0x193, %esi            # imm = 0x193
callq 0x68a0
movq 0xd8f0(%rip), %rdi      # 0x14438
callq 0x31b0
movq -0x30(%rbp), %rdi
movl %eax, %esi
callq 0x68e0
movq -0x30(%rbp), %rdi
movq 0xd8d5(%rip), %rsi      # 0x14438
callq 0x6a20
testb $0x1, %al
jne 0x6b75
movb $0x0, -0x1(%rbp)
jmp 0x6c8f
jmp 0x6c52
movq -0x30(%rbp), %rdi
movq 0xd893(%rip), %rdx      # 0x14418
movl $0xc8, %esi
callq 0x68a0
movq -0x30(%rbp), %rax
cmpq $0x0, 0xd60(%rax)
je 0x6c12
movq -0x30(%rbp), %rdi
movq 0xd60(%rdi), %rax
movl %eax, %esi
callq 0x68e0
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x834, %rcx            # imm = 0x834
movq %rcx, 0xdc0(%rax)
movslq 0xc34(%rax), %rcx
movq %rcx, 0xdc8(%rax)
movq 0xd28(%rax), %rcx
movq %rcx, 0xdd0(%rax)
movq 0xd60(%rax), %rcx
movq %rcx, 0xdd8(%rax)
movl $0x2, 0xde0(%rax)
movslq 0xc34(%rax), %rcx
addq 0xd60(%rax), %rcx
movl %ecx, 0xdf0(%rax)
movb $0x1, -0x1(%rbp)
jmp 0x6c8f
leaq 0x7791(%rip), %rax      # 0xe3aa
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x31b0
movq -0x30(%rbp), %rdi
movl %eax, %esi
callq 0x68e0
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x6a20
testb $0x1, %al
jne 0x6c48
movb $0x0, -0x1(%rbp)
jmp 0x6c8f
jmp 0x6c4a
jmp 0x6c4c
movb $0x0, -0x1(%rbp)
jmp 0x6c8f
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x834, %rcx            # imm = 0x834
movq %rcx, 0xdc0(%rax)
movslq 0xc34(%rax), %rcx
movq %rcx, 0xdc8(%rax)
movl $0x1, 0xde0(%rax)
movl 0xc34(%rax), %ecx
movl %ecx, 0xdf0(%rax)
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)