// File: /workspace/github_cpp_makefile_star2_O1/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 $0x108, %rsp            # imm = 0x108
movq %rdi, %rbx
leaq 0xf8(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rsi), %rax
movq 0x8(%rsi), %rdx
addq %rax, %rdx
leaq 0xe8(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x2d18
leaq 0x18(%rsp), %rdi
movq %r14, %rsi
movl $0xd, %edx
callq 0x2e38
movq 0xe8(%rsp), %rdi
cmpq %r12, %rdi
je 0x3055
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x2210
xorl %r14d, %r14d
movl $0xe0, %edx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2160
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq %r14, 0x8(%rbx)
movb %r14b, 0x10(%rbx)
leaq 0x30(%rbx), %rax
movq %rax, 0x20(%rbx)
movq %r14, 0x28(%rbx)
movb %r14b, 0x30(%rbx)
leaq 0x50(%rbx), %rax
movq %rax, 0x40(%rbx)
movq %r14, 0x48(%rbx)
movb %r14b, 0x50(%rbx)
leaq 0x70(%rbx), %rax
movq %rax, 0x60(%rbx)
movq %r14, 0x68(%rbx)
movb %r14b, 0x70(%rbx)
leaq 0x90(%rbx), %rax
movq %rax, 0x80(%rbx)
movq %r14, 0x88(%rbx)
movb %r14b, 0x90(%rbx)
leaq 0xb0(%rbx), %rax
movq %rax, 0xa0(%rbx)
movq %r14, 0xa8(%rbx)
movb %r14b, 0xb0(%rbx)
leaq 0xd0(%rbx), %rax
movq %rax, 0xc0(%rbx)
movq %r14, 0xc8(%rbx)
movb %r14b, 0xd0(%rbx)
movq 0x18(%rsp), %rax
leaq 0xd8(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0xc8(%rsp), %rdi
callq 0x2d18
leaq 0xb0(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
movl $0x20, %edx
callq 0x2e38
movq 0xc8(%rsp), %rdi
cmpq %r14, %rdi
je 0x3159
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0xb0(%rsp), %rsi
movq %rbx, %rdi
callq 0x2150
leaq 0x20(%rbx), %rdi
movq 0xb0(%rsp), %rsi
addq $0x20, %rsi
callq 0x2150
leaq 0x40(%rbx), %rdi
movq 0xb0(%rsp), %rsi
addq $0x40, %rsi
callq 0x2150
movq 0x18(%rsp), %rax
movq 0x20(%rsp), %rcx
subq %rax, %rcx
cmpq $0x21, %rcx
jb 0x337d
leaq 0x60(%rbx), %rcx
movq %rcx, 0xa8(%rsp)
leaq 0x80(%rbx), %rcx
movq %rcx, 0xa0(%rsp)
leaq 0xa0(%rbx), %rcx
movq %rcx, 0x98(%rsp)
leaq 0xc0(%rbx), %rcx
movq %rcx, 0x90(%rsp)
movl $0x1, %r13d
movl $0x28, %r14d
leaq 0x50(%rsp), %rbp
leaq 0x30(%rsp), %r15
movq %rsp, %r12
leaq 0x60(%rsp), %rcx
movq %rcx, 0x50(%rsp)
movq -0x8(%rax,%r14), %rsi
movq (%rax,%r14), %rdx
addq %rsi, %rdx
movq %rbp, %rdi
callq 0x2d18
leaq 0x70(%rsp), %rdi
movq %rbp, %rsi
callq 0x2f3f
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x3243
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2210
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x2d18
movq %r12, %rdi
movq %r15, %rsi
movl $0x3a, %edx
callq 0x2e38
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x328e
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2210
movq (%rsp), %rdi
leaq 0xf00(%rip), %rsi       # 0x4199
callq 0x20a0
testl %eax, %eax
jne 0x32b7
movq (%rsp), %rsi
addq $0x20, %rsi
movq 0xa8(%rsp), %rdi
callq 0x2150
movq (%rsp), %rdi
leaq 0xee4(%rip), %rsi       # 0x41a6
callq 0x20a0
testl %eax, %eax
jne 0x32e0
movq (%rsp), %rsi
addq $0x20, %rsi
movq 0xa0(%rsp), %rdi
callq 0x2150
movq (%rsp), %rdi
leaq 0xecc(%rip), %rsi       # 0x41b7
callq 0x20a0
testl %eax, %eax
jne 0x3309
movq (%rsp), %rsi
addq $0x20, %rsi
movq 0x98(%rsp), %rdi
callq 0x2150
movq (%rsp), %rdi
leaq 0xeb4(%rip), %rsi       # 0x41c8
callq 0x20a0
testl %eax, %eax
jne 0x3332
movq (%rsp), %rsi
addq $0x20, %rsi
movq 0x90(%rsp), %rdi
callq 0x2150
movq %r12, %rdi
callq 0x34dc
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x335c
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x2210
incq %r13
movq 0x18(%rsp), %rax
movq 0x20(%rsp), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
addq $0x20, %r14
cmpq %r13, %rcx
ja 0x31fc
leaq 0xb0(%rsp), %rdi
callq 0x34dc
leaq 0x18(%rsp), %rdi
callq 0x34dc
movq %rbx, %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
movq 0xc8(%rsp), %rdi
cmpq %r14, %rdi
je 0x3483
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x2210
jmp 0x3483
movq %rax, %r15
jmp 0x3483
movq %rax, %r15
movq 0xe8(%rsp), %rdi
cmpq %r12, %rdi
je 0x3495
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x2210
jmp 0x3495
jmp 0x3405
movq %rax, %r15
jmp 0x3476
movq %rax, %r15
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x3476
movq 0x60(%rsp), %rsi
jmp 0x346e
movq %rax, %r15
jmp 0x3454
movq %rax, %r15
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x3454
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2210
jmp 0x3454
movq %rax, %r15
movq %rsp, %rdi
callq 0x34dc
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x3476
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x2210
leaq 0xb0(%rsp), %rdi
callq 0x34dc
movq %rbx, %rdi
callq 0x3538
leaq 0x18(%rsp), %rdi
callq 0x34dc
movq %r15, %rdi
callq 0x2310
nop