// File: 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
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0x128(%rbp)
movq %rdi, %rax
movq %rax, -0x120(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x48(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x3140
movq -0x118(%rbp), %rsi
leaq -0x28(%rbp), %rdi
movl $0xd, %edx
callq 0x44c0
jmp 0x476b
leaq -0x48(%rbp), %rdi
callq 0x31a0
movq -0x128(%rbp), %rdi
movb $0x0, -0x55(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x140(%rbp)
movups %xmm0, 0xd0(%rdi)
movups %xmm0, 0xc0(%rdi)
movups %xmm0, 0xb0(%rdi)
movups %xmm0, 0xa0(%rdi)
movups %xmm0, 0x90(%rdi)
movups %xmm0, 0x80(%rdi)
movups %xmm0, 0x70(%rdi)
movups %xmm0, 0x60(%rdi)
movups %xmm0, 0x50(%rdi)
movups %xmm0, 0x40(%rdi)
movups %xmm0, 0x30(%rdi)
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x10(%rdi)
movups %xmm0, (%rdi)
callq 0x4df0
xorl %eax, %eax
movl %eax, %esi
leaq -0x28(%rbp), %rdi
callq 0x4e70
movq %rax, %rsi
leaq -0x90(%rbp), %rdi
callq 0x3140
jmp 0x47f5
leaq -0x70(%rbp), %rdi
leaq -0x90(%rbp), %rsi
movl $0x20, %edx
callq 0x44c0
jmp 0x480c
leaq -0x90(%rbp), %rdi
callq 0x31a0
xorl %eax, %eax
movl %eax, %esi
leaq -0x70(%rbp), %rdi
callq 0x4e70
movq -0x128(%rbp), %rdi
movq %rax, %rsi
callq 0x3030
jmp 0x4836
leaq -0x70(%rbp), %rdi
movl $0x1, %esi
callq 0x4e70
movq -0x128(%rbp), %rdi
movq %rax, %rsi
addq $0x20, %rdi
callq 0x3030
jmp 0x4859
leaq -0x70(%rbp), %rdi
movl $0x2, %esi
callq 0x4e70
movq -0x128(%rbp), %rdi
movq %rax, %rsi
addq $0x40, %rdi
callq 0x3030
jmp 0x487c
movl $0x1, -0x94(%rbp)
movslq -0x94(%rbp), %rax
movq %rax, -0x148(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x4e90
movq %rax, %rcx
movq -0x148(%rbp), %rax
cmpq %rcx, %rax
jae 0x4b65
movslq -0x94(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x4e70
movq %rax, %rsi
leaq -0xd8(%rbp), %rdi
callq 0x3140
jmp 0x48d1
leaq -0xb8(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x4620
jmp 0x48e6
leaq -0xd8(%rbp), %rdi
callq 0x31a0
leaq -0x110(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x3140
jmp 0x4907
leaq -0xf0(%rbp), %rdi
leaq -0x110(%rbp), %rsi
movl $0x3a, %edx
callq 0x44c0
jmp 0x4921
leaq -0x110(%rbp), %rdi
callq 0x31a0
leaq -0xf0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4e70
movq %rax, %rdi
leaq 0x2865(%rip), %rsi      # 0x71ac
callq 0x30e0
cmpl $0x0, %eax
jne 0x4a41
leaq -0xf0(%rbp), %rdi
movl $0x1, %esi
callq 0x4e70
movq -0x128(%rbp), %rdi
movq %rax, %rsi
addq $0x60, %rdi
callq 0x3030
jmp 0x497b
jmp 0x4a41
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x31a0
jmp 0x4bbf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x4baa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x31a0
jmp 0x4baa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x4b7a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x31a0
jmp 0x4b7a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x4b57
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x31a0
jmp 0x4b57
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x4c80
jmp 0x4b57
leaq -0xf0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4e70
movq %rax, %rdi
leaq 0x275e(%rip), %rsi      # 0x71b9
callq 0x30e0
cmpl $0x0, %eax
jne 0x4a8d
leaq -0xf0(%rbp), %rdi
movl $0x1, %esi
callq 0x4e70
movq -0x128(%rbp), %rdi
movq %rax, %rsi
subq $-0x80, %rdi
callq 0x3030
jmp 0x4a8b
jmp 0x4a8d
leaq -0xf0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4e70
movq %rax, %rdi
leaq 0x2723(%rip), %rsi      # 0x71ca
callq 0x30e0
cmpl $0x0, %eax
jne 0x4adc
leaq -0xf0(%rbp), %rdi
movl $0x1, %esi
callq 0x4e70
movq -0x128(%rbp), %rdi
movq %rax, %rsi
addq $0xa0, %rdi
callq 0x3030
jmp 0x4ada
jmp 0x4adc
leaq -0xf0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4e70
movq %rax, %rdi
leaq 0x26e5(%rip), %rsi      # 0x71db
callq 0x30e0
cmpl $0x0, %eax
jne 0x4b2b
leaq -0xf0(%rbp), %rdi
movl $0x1, %esi
callq 0x4e70
movq -0x128(%rbp), %rdi
movq %rax, %rsi
addq $0xc0, %rdi
callq 0x3030
jmp 0x4b29
jmp 0x4b2b
leaq -0xf0(%rbp), %rdi
callq 0x4c80
leaq -0xb8(%rbp), %rdi
callq 0x31a0
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x4886
leaq -0xb8(%rbp), %rdi
callq 0x31a0
jmp 0x4b7a
movb $0x1, -0x55(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x4c80
testb $0x1, -0x55(%rbp)
jne 0x4b91
jmp 0x4b85
leaq -0x70(%rbp), %rdi
callq 0x4c80
jmp 0x4baa
movq -0x128(%rbp), %rdi
callq 0x4eb0
leaq -0x28(%rbp), %rdi
callq 0x4c80
movq -0x120(%rbp), %rax
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq -0x128(%rbp), %rdi
callq 0x4eb0
leaq -0x28(%rbp), %rdi
callq 0x4c80
movq -0x50(%rbp), %rdi
callq 0x33f0
nopl (%rax,%rax)