// File: mbourand[P]webserv/srcs/Utils/CGI.cpp
// Function: CGI::ParseURI(Request const&, ConfigContext const&)
int	CGI::ParseURI(const Request& req, const ConfigContext& config)
{
	std::string	cgi_path = config.getParam("cgi_dir").front();

	m_env_Script_Name = find_first_file(req._url._path, config);
	if (m_env_Script_Name.empty())
		m_env_Script_Name = req._url._path; //return (404); (tester pass...)
	m_env_Path_Info = m_realPath.substr(m_realPath.find(m_env_Script_Name) + m_env_Script_Name.size());
	if (m_env_Path_Info.empty())
		m_env_Path_Info = "";
	else if (m_env_Path_Info[m_env_Path_Info.size() - 1] == '/')
		m_env_Path_Info.erase(m_env_Path_Info.size() - 1);
	return (0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq -0x59(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0x9b10
movq -0xb8(%rbp), %rdx
leaq 0x4b366(%rip), %rsi     # 0x6a6d1
leaq -0x58(%rbp), %rdi
callq 0xa780
jmp 0x1f376
movq -0xc0(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x4c710
movq %rax, -0xd0(%rbp)
jmp 0x1f38f
movq -0xd0(%rbp), %rdi
callq 0x14310
movq %rax, %rsi
leaq -0x38(%rbp), %rdi
callq 0x92c0
jmp 0x1f3a9
leaq -0x58(%rbp), %rdi
callq 0x9c98
leaq -0x59(%rbp), %rdi
callq 0x9700
movq -0xc8(%rbp), %rsi
movq -0x10(%rbp), %rdx
addq $0xb8, %rdx
movq -0x18(%rbp), %rcx
leaq -0x90(%rbp), %rdi
callq 0x20570
jmp 0x1f3df
movq -0xc8(%rbp), %rdi
addq $0x40, %rdi
leaq -0x90(%rbp), %rsi
callq 0x97e0
leaq -0x90(%rbp), %rdi
callq 0x9c98
movq -0xc8(%rbp), %rdi
addq $0x40, %rdi
callq 0x9a50
testb $0x1, %al
jne 0x1f418
jmp 0x1f482
movq -0xc8(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0xb8, %rsi
addq $0x40, %rdi
callq 0x9070
jmp 0x1f435
jmp 0x1f482
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x1f45a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x9c98
leaq -0x59(%rbp), %rdi
callq 0x9700
jmp 0x1f5c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x9c98
jmp 0x1f5c6
movq -0xc8(%rbp), %rsi
movq %rsi, %rdi
addq $0xc0, %rdi
movq %rdi, -0xd8(%rbp)
addq $0x40, %rsi
movq %rsi, -0xe8(%rbp)
xorl %eax, %eax
movl %eax, %edx
callq 0x9c80
movq -0xe8(%rbp), %rdi
movq %rax, -0xe0(%rbp)
callq 0x9480
movq -0xe0(%rbp), %rdx
movq -0xd8(%rbp), %rsi
addq %rax, %rdx
leaq -0xb0(%rbp), %rdi
movq $-0x1, %rcx
callq 0x96b0
jmp 0x1f4e7
movq -0xc8(%rbp), %rdi
addq $0x60, %rdi
leaq -0xb0(%rbp), %rsi
callq 0x97e0
leaq -0xb0(%rbp), %rdi
callq 0x9c98
movq -0xc8(%rbp), %rdi
addq $0x60, %rdi
callq 0x9a50
testb $0x1, %al
jne 0x1f520
jmp 0x1f53b
movq -0xc8(%rbp), %rdi
addq $0x60, %rdi
leaq 0x4b83e(%rip), %rsi     # 0x6ad70
callq 0x98a0
jmp 0x1f539
jmp 0x1f5b2
movq -0xc8(%rbp), %rdi
addq $0x60, %rdi
movq %rdi, -0xf8(%rbp)
callq 0x9480
movq -0xf8(%rbp), %rdi
movq %rax, %rsi
decq %rsi
callq 0x9c70
movq %rax, -0xf0(%rbp)
jmp 0x1f56d
movq -0xf0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
jne 0x1f5b0
movq -0xc8(%rbp), %rdi
addq $0x60, %rdi
movq %rdi, -0x100(%rbp)
callq 0x9480
movq -0x100(%rbp), %rdi
movq %rax, %rsi
decq %rsi
movq $-0x1, %rdx
callq 0x9180
jmp 0x1f5ae
jmp 0x1f5b0
jmp 0x1f5b2
leaq -0x38(%rbp), %rdi
callq 0x9c98
xorl %eax, %eax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x9af0
nop