// File: /workspace/github_cpp_makefile_star2_O1/mbourand[P]webserv/srcs/Config/ConfigContext.cpp
// Function: ConfigContext::rootPath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int&) const
std::string ConfigContext::rootPath(const std::string& path, int& base_depth) const
{
	std::string res;

	res = (getParam("root").front()[0] == '/' ? "/" : "");

	std::list<std::string> splitted = ft::split(getParam("root").front(), "/");
	base_depth = splitted.size();
	std::list<std::string> splitted_path = ft::split(path.substr(getNames().front().size()), "/");

	for (std::list<std::string>::iterator it = splitted.begin(); it != splitted.end(); it++)
		res += *it + "/";
	for (std::list<std::string>::iterator it2 = splitted_path.begin(); it2 != splitted_path.end(); it2++)
		res += *it2 + "/";
	if (res[res.size() - 1] == '/' && res != "/")
		res.erase(--res.end()); // Enlève le / à la fin
	return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rcx, %r12
movq %rdx, %rbp
movq %rsi, %r13
movq %rdi, %rbx
leaq 0x10(%rdi), %r14
movq %r14, (%rdi)
movq $0x0, 0x8(%rdi)
movb $0x0, 0x10(%rdi)
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xeb30(%rip), %rsi      # 0x3a874
leaq 0xeb2d(%rip), %rdx      # 0x3a878
leaq 0x8(%rsp), %rdi
callq 0x80f4
leaq 0x8(%rsp), %rsi
movq %r13, %rdi
callq 0x2b4c6
movq (%rax), %rax
movq 0x10(%rax), %rax
xorl %r8d, %r8d
cmpb $0x2f, (%rax)
sete %r8b
leaq 0xed1a(%rip), %rax      # 0x3aa94
leaq 0xf01a(%rip), %rcx      # 0x3ad9b
cmoveq %rax, %rcx
movq 0x8(%rbx), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x76f0
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2bdaa
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x74b0
leaq 0x8(%rsp), %rdi
movq %r15, (%rdi)
leaq 0xeabb(%rip), %rsi      # 0x3a874
leaq 0xeab8(%rip), %rdx      # 0x3a878
movq %r14, 0x60(%rsp)
callq 0x80f4
movq %rbp, 0x68(%rsp)
leaq 0x8(%rsp), %rsi
movq %r13, %rdi
callq 0x2b4c6
movq (%rax), %rbp
leaq 0x38(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xeca5(%rip), %rsi      # 0x3aa94
leaq 0xec9f(%rip), %rdx      # 0x3aa95
leaq 0x28(%rsp), %rdi
callq 0x80f4
addq $0x10, %rbp
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rdx
movq %rbp, %rsi
callq 0x1c232
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x2be2d
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x74b0
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2be44
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x74b0
movl 0x58(%rsp), %eax
movl %eax, (%r12)
movq 0x98(%r13), %rax
movq 0x18(%rax), %rdx
leaq 0x8(%rsp), %rdi
movq 0x68(%rsp), %rsi
movq $-0x1, %rcx
callq 0x74d0
leaq 0x28(%rsp), %rdi
movq %r14, (%rdi)
leaq 0xec18(%rip), %rsi      # 0x3aa94
leaq 0xec12(%rip), %rdx      # 0x3aa95
callq 0x80f4
leaq 0x70(%rsp), %rbp
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
movq %rbp, %rdi
callq 0x1c232
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x2beb6
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x74b0
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2becd
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x74b0
movq 0x48(%rsp), %r14
leaq 0x48(%rsp), %rax
cmpq %rax, %r14
je 0x2bf41
leaq 0x8(%rsp), %r12
leaq 0xebac(%rip), %r13      # 0x3aa94
movq %r15, 0x8(%rsp)
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x8a8a
movq %r12, %rdi
movq %r13, %rsi
callq 0x78d0
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x7190
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2bf34
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x74b0
movq (%r14), %r14
leaq 0x48(%rsp), %rax
cmpq %rax, %r14
jne 0x2bee8
movq 0x70(%rsp), %r13
cmpq %rbp, %r13
je 0x2bfac
leaq 0x8(%rsp), %r14
leaq 0xeb3d(%rip), %r12      # 0x3aa94
movq %r15, 0x8(%rsp)
movq 0x10(%r13), %rsi
movq 0x18(%r13), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x8a8a
movq %r14, %rdi
movq %r12, %rsi
callq 0x78d0
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x7190
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2bfa3
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x74b0
movq (%r13), %r13
cmpq %rbp, %r13
jne 0x2bf57
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpb $0x2f, -0x1(%rax,%rcx)
jne 0x2bfe1
leaq 0xead3(%rip), %rsi      # 0x3aa94
movq %rbx, %rdi
callq 0x7180
testl %eax, %eax
je 0x2bfe1
movq 0x8(%rbx), %rsi
decq %rsi
movl $0x1, %edx
movq %rbx, %rdi
callq 0x7540
leaq 0x70(%rsp), %rdi
callq 0x96d8
leaq 0x48(%rsp), %rdi
callq 0x96d8
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2c0c2
movq %rax, %r13
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x2c02e
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x2c02e
movq %rax, %r13
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2c0ed
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x2c0ed
movq %rax, %r13
jmp 0x2c0ed
movq %rax, %r13
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x2c077
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x2c077
jmp 0x2c074
movq %rax, %r13
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2c0f7
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x2c0f7
movq %rax, %r13
jmp 0x2c0f7
movq %r14, %r12
movq %rax, %r13
jmp 0x2c0fc
movq %r14, %r12
movq %rax, %r13
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2c0fc
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x2c0fc
jmp 0x2c0c2
jmp 0x2c0c9
jmp 0x2c0c9
movq %rax, %r13
jmp 0x2c0e3
jmp 0x2c0c9
movq %rax, %r13
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2c0e3
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x74b0
leaq 0x70(%rsp), %rdi
callq 0x96d8
leaq 0x48(%rsp), %rdi
callq 0x96d8
movq 0x60(%rsp), %r12
movq (%rbx), %rdi
cmpq %r12, %rdi
je 0x2c110
movq (%r12), %rsi
incq %rsi
callq 0x74b0
movq %r13, %rdi
callq 0x7810