// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x3c0, %rsp            # imm = 0x3C0
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq (%rsi), %rdi
leaq -0x3d8(%rbp), %rsi
callq 0x4360
cmpl $-0x1, %eax
je 0xfb3c
xorl %eax, %eax
leaq -0x50(%rbp), %r12
movb %al, -0x28(%r12)
movq %rax, -0x20(%r12)
movq $-0x1, -0x18(%r12)
movq %r12, -0x10(%r12)
movq %rax, -0x8(%r12)
movb %al, (%r12)
movq 0x8(%r14), %rdx
leaq -0x348(%rbp), %rdi
leaq -0x78(%rbp), %rsi
movq %r15, %rcx
movq %rbx, %r8
callq 0x126c4
leaq -0x348(%rbp), %rdi
callq 0x13218
leaq 0x10(%r14), %rsi
movq %r14, %rdi
callq 0x1004e
leaq 0x58(%r14), %r15
leaq 0x5e60(%rip), %rsi      # 0x158f5
movq %r15, %rdi
callq 0x4760
movq %r14, %rdi
callq 0x10374
movq -0x70(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x1378a
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x10af6
leaq -0x30(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xfad7
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x43e0
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq %r15, %rdi
callq 0x4150
movq (%rbx), %rdi
leaq 0x10(%rbx), %rax
cmpq %rax, %rdi
je 0xfafe
movq (%rax), %rsi
incq %rsi
callq 0x43e0
movl $0x20, %esi
movq %rbx, %rdi
callq 0x43e0
leaq -0x348(%rbp), %rdi
callq 0x130ee
movq -0x60(%rbp), %rdi
cmpq %r12, %rdi
je 0xfb2c
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x43e0
addq $0x3c0, %rsp            # imm = 0x3C0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x48, %edi
callq 0x41f0
movq %rax, %r14
leaq 0x5d83(%rip), %rsi      # 0x158d3
leaq -0x348(%rbp), %rdi
movq %r15, %rdx
callq 0x6400
movb $0x1, %r15b
leaq 0x5d60(%rip), %rdx      # 0x158c9
leaq -0x348(%rbp), %rcx
movq %r14, %rdi
movl $0x194, %esi            # imm = 0x194
callq 0xe106
xorl %r15d, %r15d
leaq 0xd1e9(%rip), %rsi      # 0x1cd70
leaq -0x1a1a(%rip), %rdx     # 0xe174
movq %r14, %rdi
callq 0x46a0
movq %rax, %rbx
leaq -0x338(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xfbc0
movq -0x338(%rbp), %rsi
incq %rsi
callq 0x43e0
jmp 0xfbc0
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0xfc18
movq %r14, %rdi
callq 0x42e0
jmp 0xfc18
movq %rax, %rbx
leaq -0x30(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xfbf7
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x43e0
jmp 0xfbf7
jmp 0xfbf4
movq %rax, %rbx
jmp 0xfc03
movq %rax, %rbx
leaq -0x348(%rbp), %rdi
callq 0x130ee
movq -0x60(%rbp), %rdi
cmpq %r12, %rdi
je 0xfc18
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x43e0
movq %rbx, %rdi
callq 0x46d0