// File: llefranc[P]42_webserv/srcs/server/Response.cpp
// Function: Response::execCgi(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*)
void Response::execCgi(const std::string& realUri, std::string* cgiName)
{
    struct stat st;
    if (stat(realUri.c_str(), &st) == -1)
	{
        throw StatusLine(404, REASON_404, "fillCgi method: " + realUri);
	}

	Body cgiRep;
	CGI cgi(&cgiRep, _req, realUri, *cgiName);
	
	cgi.executeCGI();
	
	fillStatusLine(_staLine);
	fillServerHeader();
	fillDateHeader();
	fillContentlengthHeader(convertNbToString(cgiRep.getSize()));

	_buffer += cgiRep.getBody();
	
	delete cgiName;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x430, %rsp            # imm = 0x430
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x408(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5240
movq %rax, %rdi
leaq -0xa8(%rbp), %rsi
callq 0x54c0
cmpl $-0x1, %eax
jne 0x1c479
movb $0x1, -0xd5(%rbp)
movl $0x48, %edi
callq 0x5290
movq %rax, -0x410(%rbp)
movq -0x10(%rbp), %rdx
leaq 0x74b8(%rip), %rsi      # 0x2388e
leaq -0xc8(%rbp), %rdi
callq 0x9a60
jmp 0x1c3e4
movq -0x410(%rbp), %rdi
leaq 0x7492(%rip), %rdx      # 0x23884
movl $0x194, %esi            # imm = 0x194
leaq -0xc8(%rbp), %rcx
callq 0x199d0
jmp 0x1c405
movq -0x410(%rbp), %rdi
movb $0x0, -0xd5(%rbp)
leaq 0x14976(%rip), %rsi     # 0x30d90
leaq -0x29a1(%rip), %rdx     # 0x19a80
callq 0x58a0
jmp 0x1c625
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
jmp 0x1c45d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x5a08
testb $0x1, -0xd5(%rbp)
jne 0x1c468
jmp 0x1c474
movq -0x410(%rbp), %rdi
callq 0x53f0
jmp 0x1c619
leaq -0x110(%rbp), %rdi
movq %rdi, -0x418(%rbp)
callq 0x19730
movq -0x408(%rbp), %rax
movq -0x418(%rbp), %rsi
movq 0x8(%rax), %rdx
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %r8
leaq -0x3e0(%rbp), %rdi
callq 0x1f510
jmp 0x1c4b4
leaq -0x3e0(%rbp), %rdi
callq 0x20210
jmp 0x1c4c2
movq -0x408(%rbp), %rdi
movq %rdi, %rsi
addq $0x10, %rsi
callq 0x1cb90
jmp 0x1c4d7
movq -0x408(%rbp), %rdi
callq 0x1cdc0
jmp 0x1c4e5
movq -0x408(%rbp), %rdi
callq 0x1cdf0
jmp 0x1c4f3
leaq -0x110(%rbp), %rdi
callq 0x19cb0
movq %rax, -0x420(%rbp)
jmp 0x1c508
movq -0x420(%rbp), %rsi
leaq -0x400(%rbp), %rdi
callq 0x20c10
jmp 0x1c51d
movq -0x408(%rbp), %rdi
leaq -0x400(%rbp), %rsi
callq 0x1d230
jmp 0x1c532
leaq -0x400(%rbp), %rdi
callq 0x5a08
leaq -0x110(%rbp), %rdi
callq 0x19c90
movq %rax, -0x428(%rbp)
jmp 0x1c553
movq -0x428(%rbp), %rsi
movq -0x408(%rbp), %rdi
addq $0x58, %rdi
callq 0x56b0
jmp 0x1c56c
movq -0x18(%rbp), %rax
movq %rax, -0x430(%rbp)
cmpq $0x0, %rax
je 0x1c59a
movq -0x430(%rbp), %rdi
callq 0x5a08
movq -0x430(%rbp), %rdi
movl $0x20, %esi
callq 0x5560
leaq -0x3e0(%rbp), %rdi
callq 0x200d0
leaq -0x110(%rbp), %rdi
callq 0x197a0
addq $0x430, %rsp            # imm = 0x430
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
jmp 0x1c60d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
jmp 0x1c601
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
leaq -0x400(%rbp), %rdi
callq 0x5a08
leaq -0x3e0(%rbp), %rdi
callq 0x200d0
leaq -0x110(%rbp), %rdi
callq 0x197a0
movq -0xd0(%rbp), %rdi
callq 0x58e0
nopw %cs:(%rax,%rax)