// File: /workspace/github_cpp_makefile_star2_O3/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 0xee8c(%rip), %rsi      # 0x3a874
leaq 0xee89(%rip), %rdx      # 0x3a878
leaq 0x8(%rsp), %rdi
callq 0x80f4
leaq 0x8(%rsp), %rsi
movq %r13, %rdi
callq 0x2b17e
movq (%rax), %rax
movq 0x10(%rax), %rax
xorl %r8d, %r8d
cmpb $0x2f, (%rax)
sete %r8b
leaq 0xf076(%rip), %rax      # 0x3aa94
leaq 0xf376(%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 0x2ba4e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x74b0
leaq 0x8(%rsp), %rdi
movq %r15, (%rdi)
leaq 0xee17(%rip), %rsi      # 0x3a874
leaq 0xee14(%rip), %rdx      # 0x3a878
movq %r14, 0x60(%rsp)
callq 0x80f4
movq %rbp, 0x68(%rsp)
leaq 0x8(%rsp), %rsi
movq %r13, %rdi
callq 0x2b17e
movq (%rax), %rbp
leaq 0x38(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xf001(%rip), %rsi      # 0x3aa94
leaq 0xeffb(%rip), %rdx      # 0x3aa95
leaq 0x28(%rsp), %rdi
callq 0x80f4
addq $0x10, %rbp
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rdx
movq %rbp, %rsi
callq 0x1bf30
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x2bad1
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x74b0
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2bae8
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 0xef74(%rip), %rsi      # 0x3aa94
leaq 0xef6e(%rip), %rdx      # 0x3aa95
callq 0x80f4
leaq 0x70(%rsp), %rbp
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
movq %rbp, %rdi
callq 0x1bf30
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x2bb5a
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x74b0
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2bb71
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x74b0
movq 0x48(%rsp), %r14
leaq 0x48(%rsp), %rax
cmpq %rax, %r14
je 0x2bbe5
leaq 0x8(%rsp), %r12
leaq 0xef08(%rip), %r13      # 0x3aa94
movq %r15, 0x8(%rsp)
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x8a92
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 0x2bbd8
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x74b0
movq (%r14), %r14
leaq 0x48(%rsp), %rax
cmpq %rax, %r14
jne 0x2bb8c
movq 0x70(%rsp), %r13
cmpq %rbp, %r13
je 0x2bc50
leaq 0x8(%rsp), %r14
leaq 0xee99(%rip), %r12      # 0x3aa94
movq %r15, 0x8(%rsp)
movq 0x10(%r13), %rsi
movq 0x18(%r13), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x8a92
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 0x2bc47
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x74b0
movq (%r13), %r13
cmpq %rbp, %r13
jne 0x2bbfb
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpb $0x2f, -0x1(%rax,%rcx)
jne 0x2bc85
leaq 0xee2f(%rip), %rsi      # 0x3aa94
movq %rbx, %rdi
callq 0x7180
testl %eax, %eax
je 0x2bc85
movq 0x8(%rbx), %rsi
decq %rsi
movl $0x1, %edx
movq %rbx, %rdi
callq 0x7540
leaq 0x70(%rsp), %rdi
callq 0x96b6
leaq 0x48(%rsp), %rdi
callq 0x96b6
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2bd66
movq %rax, %r13
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x2bcd2
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x2bcd2
movq %rax, %r13
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2bd91
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x2bd91
movq %rax, %r13
jmp 0x2bd91
movq %rax, %r13
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x2bd1b
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x2bd1b
jmp 0x2bd18
movq %rax, %r13
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2bd9b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x2bd9b
movq %rax, %r13
jmp 0x2bd9b
movq %r14, %r12
movq %rax, %r13
jmp 0x2bda0
movq %r14, %r12
movq %rax, %r13
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2bda0
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x2bda0
jmp 0x2bd66
jmp 0x2bd6d
jmp 0x2bd6d
movq %rax, %r13
jmp 0x2bd87
jmp 0x2bd6d
movq %rax, %r13
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2bd87
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x74b0
leaq 0x70(%rsp), %rdi
callq 0x96b6
leaq 0x48(%rsp), %rdi
callq 0x96b6
movq 0x60(%rsp), %r12
movq (%rbx), %rdi
cmpq %r12, %rdi
je 0x2bdb4
movq (%r12), %rsi
incq %rsi
callq 0x74b0
movq %r13, %rdi
callq 0x7810