// File: /workspace/github_cpp_makefile_star2_O2/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 %r14
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 0x28e4
leaq 0xc0(%rsp), %rdi
leaq 0x100(%rsp), %rdx
movq %r14, %rsi
callq 0x28e4
leaq 0x100(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x293e
leaq 0x1a21(%rip), %rdx      # 0x4022
movq %rsp, %rdi
leaq 0x100(%rsp), %rsi
callq 0x2976
leaq 0x100(%rsp), %rdi
callq 0x2110
movq 0x39b3(%rip), %rdi      # 0x5fd8
movq %rsp, %rsi
callq 0x21b0
movq %rax, %rdi
callq 0x2120
movq %rsp, %rdi
callq 0x2995
testb %al, %al
je 0x2755
leaq 0x100(%rsp), %rdi
movq %rsp, %rsi
pushq $0x8
popq %rdx
callq 0x22d0
leaq 0x310(%rsp), %rdi
callq 0x2240
leaq 0x110(%rsp), %rsi
leaq 0x310(%rsp), %rdi
callq 0x2040
leaq 0x318(%rsp), %rsi
leaq 0x40(%rsp), %rdi
callq 0x22b0
leaq 0x1995(%rip), %rsi      # 0x4028
leaq 0xa0(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x28e4
leaq 0x80(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x2250
movl 0x48(%rsp), %edx
leaq 0x20(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x24ec
leaq 0x80(%rsp), %rdi
callq 0x2110
leaq 0x60(%rsp), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x40(%rsp), %rdx
callq 0x293e
movl 0x8(%rbx), %ebx
movq 0x60(%rsp), %r14
movq %r14, %rdi
callq 0x2100
movl %ebx, %edi
movq %r14, %rsi
movq %rax, %rdx
callq 0x20d0
leaq 0x60(%rsp), %rdi
callq 0x2110
leaq 0x20(%rsp), %rdi
callq 0x2110
leaq 0xa0(%rsp), %rdi
callq 0x2110
leaq 0x40(%rsp), %rdi
callq 0x2110
leaq 0x310(%rsp), %rdi
callq 0x2060
leaq 0x100(%rsp), %rdi
callq 0x2080
jmp 0x27a3
leaq 0x1924(%rip), %rsi      # 0x4080
pushq $0x4b
popq %rcx
leaq 0x100(%rsp), %rax
movq %rax, %rdi
rep  movsb (%rsi), %es:(%rdi)
movq 0x3865(%rip), %rdi      # 0x5fd8
movq %rax, %rsi
callq 0x21d0
movq %rax, %rdi
callq 0x2120
movl 0x8(%rbx), %ebx
leaq 0x100(%rsp), %r14
movq %r14, %rdi
callq 0x2100
movl %ebx, %edi
movq %r14, %rsi
movq %rax, %rdx
callq 0x20d0
movq %rsp, %rdi
callq 0x2110
leaq 0xc0(%rsp), %rdi
callq 0x2110
leaq 0xe0(%rsp), %rdi
callq 0x2110
addq $0x488, %rsp            # imm = 0x488
popq %rbx
popq %r14
retq
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x2110
jmp 0x27e2
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
jmp 0x27f4
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x2110
jmp 0x27fe
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x2110
jmp 0x2810
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x2110
jmp 0x2821
jmp 0x281e
movq %rax, %rbx
leaq 0x310(%rsp), %rdi
callq 0x2060
leaq 0x100(%rsp), %rdi
callq 0x2080
jmp 0x2860
movq %rax, %rbx
jmp 0x282e
jmp 0x285d
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
jmp 0x2863
movq %rax, %rbx
jmp 0x2868
movq %rax, %rbx
jmp 0x2875
jmp 0x285d
movq %rax, %rbx
movq %rsp, %rdi
callq 0x2110
leaq 0xc0(%rsp), %rdi
callq 0x2110
leaq 0xe0(%rsp), %rdi
callq 0x2110
movq %rbx, %rdi
callq 0x2300