// File: /workspace/github_cpp_makefile_star2_O3/dhruvbhargava[P]microTP/src/Parser.cpp
// Function: parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
Request parse(std::string raw_header)
{
    //split the header line by line
    std::vector<std::string> lines = split(raw_header, '\r');
    Request httpRequest =  Request();
    //set the method parameter (@required part)
    std::vector<std::string> method_meta = split(lines[0], ' ');
    httpRequest.request_method = method_meta[0];
    httpRequest.url = method_meta[1];
    httpRequest.http_version = method_meta[2];
    //set the optional fields
    for (int index = 1; index < lines.size(); index++)
    {
        std::string curr = stripLower(lines[index]);
        std::vector<std::string> field_dp = split(curr, ':');
        if (field_dp[0].compare("content-type") == 0)
        {
            httpRequest.content_type = field_dp[1];
        }
        if (field_dp[0].compare("content-encoding") == 0)
        {
            httpRequest.content_encoding = field_dp[1];
        }
        if (field_dp[0].compare("content-language") == 0)
        {
            httpRequest.content_language = field_dp[1];
        }
        if (field_dp[0].compare("content-location") == 0)
        {
            httpRequest.content_location = field_dp[1];
        }
    }
    return httpRequest;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, %r15
leaq 0x108(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq (%rsi), %rax
movq 0x8(%rsi), %rdx
addq %rax, %rdx
leaq 0xf8(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x2d18
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
movl $0xd, %edx
callq 0x2e44
movq 0xf8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x3060
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x2210
leaq 0x10(%r15), %r14
xorl %ebx, %ebx
movl $0xd0, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x2160
movq %r14, (%r15)
movq $0x0, 0x8(%r15)
leaq 0x30(%r15), %rax
movq %rax, 0x20(%r15)
movb %bl, 0x30(%r15)
leaq 0x50(%r15), %rax
movq %rax, 0x40(%r15)
movb %bl, 0x50(%r15)
leaq 0x70(%r15), %rax
movq %rax, 0x60(%r15)
movb %bl, 0x70(%r15)
leaq 0x90(%r15), %rax
movq %rax, 0x80(%r15)
movb %bl, 0x90(%r15)
leaq 0xb0(%r15), %rax
movq %rax, 0xa0(%r15)
movb %bl, 0xb0(%r15)
leaq 0xd0(%r15), %rax
movq %rax, 0xc0(%r15)
movb %bl, 0xd0(%r15)
movq 0x28(%rsp), %rax
leaq 0xe8(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0xd8(%rsp), %rdi
movq %r15, 0x8(%rsp)
callq 0x2d18
leaq 0xa0(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
movl $0x20, %edx
callq 0x2e44
movq 0xd8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x3147
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0xa0(%rsp), %rsi
movq %r15, %rdi
callq 0x2150
leaq 0x20(%r15), %rdi
movq 0xa0(%rsp), %rsi
addq $0x20, %rsi
callq 0x2150
leaq 0x40(%r15), %rdi
movq 0xa0(%rsp), %rsi
addq $0x40, %rsi
callq 0x2150
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
subq %rax, %rcx
cmpq $0x21, %rcx
jb 0x337d
movq 0x8(%rsp), %rcx
leaq 0x60(%rcx), %rdx
movq %rdx, 0x98(%rsp)
leaq 0x80(%rcx), %rdx
movq %rdx, 0x90(%rsp)
leaq 0xa0(%rcx), %rdx
movq %rdx, 0x88(%rsp)
addq $0xc0, %rcx
movq %rcx, 0x80(%rsp)
leaq 0xc8(%rsp), %r14
movl $0x1, %ebx
movl $0x28, %r13d
leaq 0x40(%rsp), %rbp
leaq 0xb8(%rsp), %r15
leaq 0x10(%rsp), %r12
leaq 0x50(%rsp), %rcx
movq %rcx, 0x40(%rsp)
movq -0x8(%rax,%r13), %rsi
movq (%rax,%r13), %rdx
addq %rsi, %rdx
movq %rbp, %rdi
callq 0x2d18
leaq 0x60(%rsp), %rdi
movq %rbp, %rsi
callq 0x2f4b
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x3242
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2210
movq %r14, 0xb8(%rsp)
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x2d18
movq %r12, %rdi
movq %r15, %rsi
movl $0x3a, %edx
callq 0x2e44
movq 0xb8(%rsp), %rdi
cmpq %r14, %rdi
je 0x328c
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0x10(%rsp), %rdi
leaq 0xf01(%rip), %rsi       # 0x4199
callq 0x20a0
testl %eax, %eax
jne 0x32b7
movq 0x10(%rsp), %rsi
addq $0x20, %rsi
movq 0x98(%rsp), %rdi
callq 0x2150
movq 0x10(%rsp), %rdi
leaq 0xee3(%rip), %rsi       # 0x41a6
callq 0x20a0
testl %eax, %eax
jne 0x32e2
movq 0x10(%rsp), %rsi
addq $0x20, %rsi
movq 0x90(%rsp), %rdi
callq 0x2150
movq 0x10(%rsp), %rdi
leaq 0xec9(%rip), %rsi       # 0x41b7
callq 0x20a0
testl %eax, %eax
jne 0x330d
movq 0x10(%rsp), %rsi
addq $0x20, %rsi
movq 0x88(%rsp), %rdi
callq 0x2150
movq 0x10(%rsp), %rdi
leaq 0xeaf(%rip), %rsi       # 0x41c8
callq 0x20a0
testl %eax, %eax
jne 0x3338
movq 0x10(%rsp), %rsi
addq $0x20, %rsi
movq 0x80(%rsp), %rdi
callq 0x2150
movq %r12, %rdi
callq 0x34dc
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x335c
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x2210
incq %rbx
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
addq $0x20, %r13
cmpq %rbx, %rcx
ja 0x31fb
leaq 0xa0(%rsp), %rdi
callq 0x34dc
leaq 0x28(%rsp), %rdi
callq 0x34dc
movq 0x8(%rsp), %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
movq 0xd8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x3482
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x2210
jmp 0x3482
movq %rax, %r15
jmp 0x3482
movq %rax, %r15
movq 0xf8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x3496
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x2210
jmp 0x3496
jmp 0x3407
movq %rax, %r15
jmp 0x3475
movq %rax, %r15
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x3475
movq 0x50(%rsp), %rsi
jmp 0x346d
movq %rax, %r15
jmp 0x3459
movq %rax, %r15
movq 0xb8(%rsp), %rdi
cmpq %r14, %rdi
je 0x3459
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x2210
jmp 0x3459
movq %rax, %r15
leaq 0x10(%rsp), %rdi
callq 0x34dc
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x3475
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x2210
leaq 0xa0(%rsp), %rdi
callq 0x34dc
movq 0x8(%rsp), %rdi
callq 0x353a
leaq 0x28(%rsp), %rdi
callq 0x34dc
movq %r15, %rdi
callq 0x2310