// File: /workspace/github_cpp_makefile_star2_O1/dhruvbhargava[P]microTP/src/HttpMethods.cpp
// Function: HttpServer::GET(char const*, bool)
void HttpServer::GET(const char *filepath, bool close)
{
    std::string root_path = PROJECT_ROOT, file_p = filepath;
    std::string full_path = root_path + file_p + ".html";
    std::cout<<full_path<<std::endl;
    if (!exists(full_path))
    {
        char response[] = "HTTP/1.1 404 NOT FOUND\r\nContent-Type: text/plain\r\nContent-Length: 3\r\n\r\n404";
        std::cout << response << std::endl;
        write(new_socket_fd, response, strlen(response));
        return;
    }

    std::ifstream html(full_path);
    std::ostringstream html_stream;
    html_stream << html.rdbuf();
    std::string html_string = html_stream.str();
    std::string http_template = close ? (char *)HTTP_OK_CLOSE_START : HTTP_OK_KEEP_ALIVE_START;
    std::string http_string = format(http_template,html_string.length());
    std::string response = http_string + html_string;
    write(new_socket_fd, response.c_str(), strlen(response.c_str()));
    return;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x488, %rsp            # imm = 0x488
movq %rsi, %r14
movq %rdi, %rbx
movq 0x30(%rdi), %rsi
leaq 0xe0(%rsp), %rdi
leaq 0x100(%rsp), %rdx
callq 0x2c14
leaq 0xc0(%rsp), %rdi
leaq 0x100(%rsp), %rdx
movq %r14, %rsi
callq 0x2c14
leaq 0x100(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x2c51
leaq 0x18cd(%rip), %rsi      # 0x4022
leaq 0x100(%rsp), %rdi
callq 0x2340
leaq 0x10(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2789
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x2791
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x110(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x27ca
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x2210
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq 0x37fe(%rip), %rdi      # 0x5fd8
callq 0x2230
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2170
movq (%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x21d0
testl %eax, %eax
je 0x28b5
leaq 0x1857(%rip), %rsi      # 0x4080
leaq 0x100(%rsp), %r15
movl $0x9, %ecx
movq %r15, %rdi
rep  movsq (%rsi), %es:(%rdi)
movb $0x0, 0x4a(%r15)
movw $0x3430, 0x48(%r15)     # imm = 0x3430
movq %r15, %rdi
callq 0x2110
movq 0x3781(%rip), %r14      # 0x5fd8
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x2230
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq 0x3755(%rip), %rdi      # 0x5fd8
callq 0x2030
movq %rax, %rdi
callq 0x2170
movl 0x8(%rbx), %ebx
leaq 0x100(%rsp), %r14
movq %r14, %rdi
callq 0x2110
movl %ebx, %edi
movq %r14, %rsi
movq %rax, %rdx
callq 0x20e0
jmp 0x2a48
leaq 0x100(%rsp), %rdi
movq %rsp, %rsi
movl $0x8, %edx
callq 0x22e0
leaq 0x310(%rsp), %rdi
callq 0x2260
leaq 0x110(%rsp), %rsi
leaq 0x310(%rsp), %rdi
callq 0x2050
leaq 0x318(%rsp), %rsi
leaq 0x60(%rsp), %rdi
callq 0x22c0
leaq 0x30(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x171a(%rip), %rsi      # 0x4028
leaq 0x1733(%rip), %rdx      # 0x4048
leaq 0x20(%rsp), %rdi
callq 0x2da8
leaq 0x50(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
addq %rsi, %rdx
leaq 0x40(%rsp), %rdi
callq 0x2d18
movl 0x68(%rsp), %edx
leaq 0xa0(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x24fc
movq 0x40(%rsp), %rdi
cmpq %r14, %rdi
je 0x296c
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2210
leaq 0x80(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x2c51
movl 0x8(%rbx), %ebx
movq 0x80(%rsp), %r14
movq %r14, %rdi
callq 0x2110
movl %ebx, %edi
movq %r14, %rsi
movq %rax, %rdx
callq 0x20e0
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x29c7
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x2210
leaq 0xb0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x29e8
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x29ff
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2210
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2a1a
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0x35af(%rip), %rsi      # 0x5fd0
leaq 0x310(%rsp), %rdi
callq 0x2140
leaq 0x380(%rsp), %rdi
callq 0x20d0
leaq 0x100(%rsp), %rdi
callq 0x2070
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x2a5e
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2210
leaq 0xd0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2a7f
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x2210
leaq 0xf0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2aa0
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x2210
addq $0x488, %rsp            # imm = 0x488
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %rbx
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2ad8
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x2210
jmp 0x2ad8
movq %rax, %rbx
leaq 0xb0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2b12
movq 0xb0(%rsp), %rsi
jmp 0x2b05
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r14, %rdi
je 0x2b12
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2210
jmp 0x2b12
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x2b2e
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2210
jmp 0x2b2e
movq %rax, %rbx
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2b50
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x2210
jmp 0x2b50
jmp 0x2b4d
movq %rax, %rbx
movq 0x3479(%rip), %rsi      # 0x5fd0
leaq 0x310(%rsp), %rdi
callq 0x2140
leaq 0x380(%rsp), %rdi
callq 0x20d0
leaq 0x100(%rsp), %rdi
callq 0x2070
jmp 0x2bb4
movq %rax, %rbx
jmp 0x2b71
jmp 0x2bb1
movq %rax, %rbx
leaq 0x110(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2bca
movq 0x110(%rsp), %rsi
jmp 0x2bc2
movq %rax, %rbx
jmp 0x2bca
movq %rax, %rbx
jmp 0x2beb
jmp 0x2bb1
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x2bca
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2210
leaq 0xd0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2beb
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x2210
leaq 0xf0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2c0c
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x2210
movq %rbx, %rdi
callq 0x2310