// File: /workspace/github_cpp_makefile_star2_O1/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, %rbx
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x18(%rdi), %rsi
movq 0x20(%rdi), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x9ce2
leaq 0x309b(%rip), %rsi      # 0x16250
movl $0x4, %ecx
movq %r15, %rdi
xorl %edx, %edx
callq 0x6570
movq %rax, %r14
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x131d4
callq 0x6350
leaq 0x8(%rsp), %r15
leaq 0x18(%rsp), %r12
movq %r12, (%r15)
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x9ce2
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x13201
callq 0x6350
cmpq $-0x1, %r14
je 0x1321e
leaq 0x4(%r14), %r15
movq %r15, %rax
subq (%rbx), %rax
cmpq $0x4000, %rax           # imm = 0x4000
jbe 0x13275
xorl %r15d, %r15d
jmp 0x13260
leaq 0x8(%rsp), %r14
leaq 0x18(%rsp), %r12
movq %r12, (%r14)
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x9ce2
movq (%r14), %rdi
movq 0x8(%r14), %rax
subq (%rbx), %rax
addq $0x4, %rax
cmpq $0x4001, %rax           # imm = 0x4001
setb %r15b
cmpq %r12, %rdi
je 0x13260
callq 0x6350
movl %r15d, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
xorl %eax, %eax
movq %rax, 0x10(%rsp)
movb %al, 0x18(%rsp)
leaq 0x88(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x68(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %rdi
callq 0x9ce2
movq (%rbx), %rdx
subq %rdx, %r14
addq $0x2, %r14
leaq 0x98(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movq %r14, %rcx
callq 0x6380
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x132fc
callq 0x6350
movq %r15, 0x48(%rsp)
xorl %ebp, %ebp
leaq 0x78(%rsp), %r12
cmpq $-0x1, %rbp
sete %al
cmpq 0xa0(%rsp), %rbp
setae %r15b
orb %al, %r15b
jne 0x13468
movq %rbx, %r13
movl $0x2, %ecx
leaq 0x98(%rsp), %rbx
movq %rbx, %rdi
leaq 0x2f14(%rip), %rsi      # 0x16252
movq %rbp, %rdx
callq 0x6570
movq %rax, 0x50(%rsp)
movq %rax, %rcx
subq %rbp, %rcx
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x6380
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6410
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x13388
callq 0x6350
movl $0x1, %ecx
movq %rbx, %rdi
leaq 0x2ebe(%rip), %rsi      # 0x16255
xorl %edx, %edx
callq 0x6570
cmpq $-0x1, %rax
je 0x13471
movq %rax, %rbp
movq %rbx, %rsi
movq %r13, %rbx
leaq 0x28(%rsp), %r15
movq %r15, %rdi
xorl %edx, %edx
movq %rax, %rcx
callq 0x6380
movq %r12, %rdi
movq %r15, %rsi
callq 0x6410
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x133e2
callq 0x6350
incq %rbp
movq 0x10(%rsp), %rcx
decq %rcx
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
movq %rbp, %rdx
callq 0x6380
leaq 0x58(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x6410
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x13421
callq 0x6350
movq 0x60(%rsp), %rax
testq %rax, %rax
je 0x1344c
movq 0x58(%rsp), %rcx
xorl %edx, %edx
cmpb $0x20, (%rcx,%rdx)
jne 0x13442
incq %rdx
cmpq %rdx, %rax
jne 0x13432
jmp 0x1344c
movq %r14, %rdi
xorl %esi, %esi
callq 0x60c0
movq 0x50(%rsp), %rbp
addq $0x2, %rbp
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x12bfc
jmp 0x13308
movq 0x48(%rsp), %rax
movq %rax, 0x8(%rbx)
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x13487
callq 0x6350
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x1349b
callq 0x6350
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x134b2
callq 0x6350
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
jne 0x1325b
jmp 0x13260
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
jmp 0x134f5
movq %rax, %rbx
jmp 0x134ff
jmp 0x134e6
jmp 0x134e6
jmp 0x134e6
jmp 0x134e6
movq %rax, %rbx
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x134ff
callq 0x6350
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x13513
callq 0x6350
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x1352a
callq 0x6350
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1353e
callq 0x6350
movq %rbx, %rdi
callq 0x6580