// File: /workspace/github_cpp_makefile_star2_O3/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 0xfad8
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 0x1260c
leaq -0x348(%rbp), %rdi
callq 0x13154
leaq 0x10(%r14), %rsi
movq %r14, %rdi
callq 0xffe4
leaq 0x58(%r14), %r15
leaq 0x5ec4(%rip), %rsi      # 0x158f5
movq %r15, %rdi
callq 0x4760
movq %r14, %rdi
callq 0x10304
movq -0x70(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x136be
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x10a86
leaq -0x30(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xfa73
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 0xfa9a
movq (%rax), %rsi
incq %rsi
callq 0x43e0
movl $0x20, %esi
movq %rbx, %rdi
callq 0x43e0
leaq -0x348(%rbp), %rdi
callq 0x13034
movq -0x60(%rbp), %rdi
cmpq %r12, %rdi
je 0xfac8
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 0x5de7(%rip), %rsi      # 0x158d3
leaq -0x348(%rbp), %rdi
movq %r15, %rdx
callq 0x643f
movb $0x1, %r15b
leaq 0x5dc4(%rip), %rdx      # 0x158c9
leaq -0x348(%rbp), %rcx
movq %r14, %rdi
movl $0x194, %esi            # imm = 0x194
callq 0xe0d4
xorl %r15d, %r15d
leaq 0xd24d(%rip), %rsi      # 0x1cd70
leaq -0x19e8(%rip), %rdx     # 0xe142
movq %r14, %rdi
callq 0x46a0
movq %rax, %rbx
leaq -0x338(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xfb54
movq -0x338(%rbp), %rsi
incq %rsi
callq 0x43e0
testb %r15b, %r15b
jne 0xfb5e
jmp 0xfbb1
movq %rax, %rbx
movq %r14, %rdi
callq 0x42e0
jmp 0xfbb1
movq %rax, %rbx
leaq -0x30(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xfb90
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x43e0
jmp 0xfb90
jmp 0xfb8d
movq %rax, %rbx
jmp 0xfb9c
movq %rax, %rbx
leaq -0x348(%rbp), %rdi
callq 0x13034
movq -0x60(%rbp), %rdi
cmpq %r12, %rdi
je 0xfbb1
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x43e0
movq %rbx, %rdi
callq 0x46d0
nop