// File: /workspace/github_cpp_makefile_star2_O2/jixinqi[P]lazurite/./src/lazurite_core/http_request.cpp
// Function: lazurite::http::request_parser::parser_header()
bool lazurite::http::request_parser::parser_header()
{
    const std::size_t index = _request.raw_msg().find("\r\n\r\n");
    if (index == _request.raw_msg().npos)
    {
        return (_request.raw_msg().length() + 4 - _request.first_line_end_index() <= http_msg_header_max_length);
    }
    else if (index + 4 - _request.first_line_end_index() > http_msg_header_max_length)
    {
        return false;
    }

    std::size_t last_line_break_index = 0;
    std::size_t line_break_index = 0;
    std::string line;
    std::string key;
    std::string value;

    std::string raw_request_header = _request.raw_msg().substr
    (
        _request.first_line_end_index(),
        index - _request.first_line_end_index() + 2
    );

    while (line_break_index != raw_request_header.npos && line_break_index < raw_request_header.length())
    {
        last_line_break_index = line_break_index;
        line_break_index = raw_request_header.find("\r\n", line_break_index);
        line = raw_request_header.substr(last_line_break_index, line_break_index - last_line_break_index);
        line_break_index += 2;

        std::size_t colon_index = line.find(":");
        if (colon_index == line.npos)
        {
            return false;
        }

        key = line.substr(0, colon_index);
        value = line.substr(colon_index + 1, line.length() - 1);
        for (std::size_t erase_space_index = 0; erase_space_index != value.length(); erase_space_index++)
        {
            if (value.at(erase_space_index) != ' ')
            {
                value.erase(0, erase_space_index);
                break;
            }
        }

        _request.add_header(key, value);
    }
    _request.header_end_index(index + 4);

    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdi, %r12
leaq 0x18(%rdi), %rbx
leaq 0x18(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x6460
leaq 0x27c6(%rip), %rsi      # 0x12239
movq %r15, %rdi
xorl %edx, %edx
callq 0x6650
movq %rax, %r14
movq %r15, %rdi
callq 0x6668
leaq 0x18(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x6460
movq %r15, %rdi
callq 0x6668
cmpq $-0x1, %r14
je 0xfac1
leaq 0x4(%r14), %r15
movq %r15, %rax
subq (%r12), %rax
cmpq $0x4000, %rax           # imm = 0x4000
jbe 0xfaef
xorl %r12d, %r12d
jmp 0xfcc7
leaq 0x18(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x6460
movq 0x8(%r14), %rax
subq (%r12), %rax
addq $0x4, %rax
cmpq $0x4001, %rax           # imm = 0x4001
setb %r12b
movq %r14, %rdi
jmp 0xfcc2
leaq 0x28(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
leaq 0xa8(%rsp), %rdx
movq %rdx, -0x10(%rdx)
andq $0x0, -0x8(%rdx)
movb %cl, (%rax)
movb %cl, (%rdx)
leaq 0x68(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0x78(%rsp), %rdi
movq %rbx, %rsi
callq 0x6460
movq %r15, 0x10(%rsp)
movq %r12, 0x8(%rsp)
movq (%r12), %rdx
subq %rdx, %r14
addq $0x2, %r14
leaq 0x38(%rsp), %rdi
leaq 0x78(%rsp), %rsi
movq %r14, %rcx
callq 0x6350
leaq 0x78(%rsp), %r14
movq %r14, %rdi
callq 0x6668
xorl %r15d, %r15d
leaq 0x18(%rsp), %r13
cmpq $-0x1, %r15
sete %al
cmpq 0x40(%rsp), %r15
setae %r12b
orb %al, %r12b
jne 0xfc8e
movq %r13, %rbp
leaq 0x38(%rsp), %r13
movq %r13, %rdi
leaq 0x26a3(%rip), %rsi      # 0x1223b
movq %r15, %rdx
callq 0x6650
movq %rax, %rbx
movq %rax, %rcx
subq %r15, %rcx
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x6350
movq %rbp, %r13
movq %rbp, %rdi
movq %r14, %rsi
callq 0x63e0
movq %r14, %rdi
callq 0x6668
movq %rbp, %rdi
leaq 0x2667(%rip), %rsi      # 0x1223e
xorl %edx, %edx
callq 0x6650
cmpq $-0x1, %rax
je 0xfc9c
movq %rax, %r15
movq %r14, %rdi
movq %r13, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x6350
leaq 0x98(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x63e0
movq %r14, %rdi
callq 0x6668
incq %r15
movq 0x20(%rsp), %rcx
decq %rcx
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x6350
leaq 0x58(%rsp), %rbp
movq %rbx, %r15
addq $0x2, %r15
movq %rbp, %rdi
movq %r14, %rsi
callq 0x63e0
movq %r14, %rdi
callq 0x6668
xorl %ebx, %ebx
cmpq 0x60(%rsp), %rbx
je 0xfc79
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x6610
cmpb $0x20, (%rax)
jne 0xfc6c
incq %rbx
jmp 0xfc50
movq %rbp, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x60c0
movq 0x8(%rsp), %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0xf61a
jmp 0xfb6d
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
movq %rcx, 0x8(%rax)
leaq 0x38(%rsp), %rdi
callq 0x6668
leaq 0x58(%rsp), %rdi
callq 0x6668
leaq 0x98(%rsp), %rdi
callq 0x6668
leaq 0x18(%rsp), %rdi
callq 0x6668
movl %r12d, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
jmp 0xfcfd
movq %rax, %rbx
jmp 0xfd02
jmp 0xfcf5
jmp 0xfcf5
jmp 0xfcf5
jmp 0xfcf5
jmp 0xfcf5
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x6668
leaq 0x58(%rsp), %rdi
callq 0x6668
leaq 0x98(%rsp), %rdi
callq 0x6668
leaq 0x18(%rsp), %rdi
callq 0x6668
movq %rbx, %rdi
callq 0x6550
nop