// File: /workspace/github_cpp_makefile_star2_O2/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, %r14
leaq 0x98(%rsp), %rbx
movq %rbx, %rdi
callq 0x2250
leaq 0x60(%rsp), %rdi
pushq $0xd
popq %rdx
movq %rbx, %rsi
callq 0x2ae8
leaq 0x98(%rsp), %rdi
callq 0x2110
movl $0xe0, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x2150
movq %r14, %rdi
callq 0x2f48
movq 0x60(%rsp), %rsi
leaq 0x78(%rsp), %rdi
callq 0x2250
leaq 0x48(%rsp), %rdi
leaq 0x78(%rsp), %rsi
pushq $0x20
popq %rdx
callq 0x2ae8
leaq 0x78(%rsp), %rdi
callq 0x2110
movq 0x48(%rsp), %rsi
movq %r14, %rdi
callq 0x2140
movq 0x48(%rsp), %rsi
addq $0x20, %rsi
leaq 0x20(%r14), %rdi
callq 0x2140
movq 0x48(%rsp), %rsi
addq $0x40, %rsi
leaq 0x40(%r14), %rdi
callq 0x2140
leaq 0x60(%r14), %rax
movq %rax, 0x40(%rsp)
leaq 0x80(%r14), %rax
movq %rax, 0x38(%rsp)
leaq 0xa0(%r14), %rax
movq %rax, 0x30(%rsp)
movq %r14, 0x8(%rsp)
leaq 0xc0(%r14), %rax
movq %rax, 0x28(%rsp)
pushq $0x1
popq %r13
pushq $0x20
popq %r12
leaq 0xd8(%rsp), %rbp
leaq 0xf8(%rsp), %rbx
leaq 0xb8(%rsp), %r14
leaq 0x10(%rsp), %r15
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rax
subq %rsi, %rax
sarq $0x5, %rax
cmpq %r13, %rax
jbe 0x2e37
addq %r12, %rsi
movq %rbp, %rdi
callq 0x2250
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x2b9d
movq %rbp, %rdi
callq 0x2110
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2250
movq %r15, %rdi
movq %r14, %rsi
pushq $0x3a
popq %rdx
callq 0x2ae8
movq %r14, %rdi
callq 0x2110
movq 0x10(%rsp), %rdi
leaq 0x1412(%rip), %rsi      # 0x4199
callq 0x20b0
testl %eax, %eax
jne 0x2da3
movq 0x10(%rsp), %rsi
addq $0x20, %rsi
movq 0x40(%rsp), %rdi
callq 0x2140
movq 0x10(%rsp), %rdi
leaq 0x13f7(%rip), %rsi      # 0x41a6
callq 0x20b0
testl %eax, %eax
jne 0x2dcb
movq 0x10(%rsp), %rsi
addq $0x20, %rsi
movq 0x38(%rsp), %rdi
callq 0x2140
movq 0x10(%rsp), %rdi
leaq 0x13e0(%rip), %rsi      # 0x41b7
callq 0x20b0
testl %eax, %eax
jne 0x2df3
movq 0x10(%rsp), %rsi
addq $0x20, %rsi
movq 0x30(%rsp), %rdi
callq 0x2140
movq 0x10(%rsp), %rdi
leaq 0x13c9(%rip), %rsi      # 0x41c8
callq 0x20b0
testl %eax, %eax
jne 0x2e1b
movq 0x10(%rsp), %rsi
addq $0x20, %rsi
movq 0x28(%rsp), %rdi
callq 0x2140
movq %r15, %rdi
callq 0x2f26
movq %rbx, %rdi
callq 0x2110
incq %r13
addq $0x20, %r12
jmp 0x2d22
leaq 0x48(%rsp), %rdi
callq 0x2f26
leaq 0x60(%rsp), %rdi
callq 0x2f26
movq 0x8(%rsp), %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x2110
jmp 0x2edf
movq %rax, %rbx
jmp 0x2edf
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x2110
jmp 0x2ef1
movq %rax, %rbx
jmp 0x2ed5
movq %rax, %rbx
jmp 0x2ed0
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
jmp 0x2ecb
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x2110
jmp 0x2ec3
movq %rax, %rbx
jmp 0x2ec3
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x2f26
leaq 0xf8(%rsp), %rdi
callq 0x2110
movq 0x8(%rsp), %r14
leaq 0x48(%rsp), %rdi
callq 0x2f26
movq %r14, %rdi
callq 0x2fde
leaq 0x60(%rsp), %rdi
callq 0x2f26
movq %rbx, %rdi
callq 0x2300
nop