// File: /workspace/github_cpp_makefile_star2_O2/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 $0x78, %rsp
movq %rcx, %r15
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x10(%rdi), %rax
movq %rax, (%rdi)
andq $0x0, 0x8(%rdi)
movb $0x0, 0x10(%rdi)
leaq 0xadd5(%rip), %rsi      # 0x2c828
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x8032
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x2167a
movq (%rax), %rax
movq 0x10(%rax), %rax
cmpb $0x2f, (%rax)
leaq 0xafc8(%rip), %rax      # 0x2ca48
leaq 0xb2c8(%rip), %rsi      # 0x2cd4f
cmoveq %rax, %rsi
movq %rbx, %rdi
callq 0x7930
leaq 0x8(%rsp), %rdi
callq 0x79b8
leaq 0xad84(%rip), %rsi      # 0x2c828
leaq 0x8(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x8032
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x2167a
movq (%rax), %rbp
leaq 0xaf7e(%rip), %rsi      # 0x2ca48
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x8032
addq $0x10, %rbp
leaq 0x60(%rsp), %r13
leaq 0x28(%rsp), %rdx
movq %r13, %rdi
movq %rbp, %rsi
callq 0x16f10
leaq 0x28(%rsp), %rdi
callq 0x79b8
leaq 0x8(%rsp), %rdi
callq 0x79b8
movl 0x70(%rsp), %eax
movl %eax, (%r15)
movq 0x98(%r12), %rax
movq 0x18(%rax), %rdx
leaq 0x8(%rsp), %rdi
pushq $-0x1
popq %rcx
movq %r14, %rsi
callq 0x7540
leaq 0xaf18(%rip), %rsi      # 0x2ca48
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x8032
leaq 0x48(%rsp), %r14
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
movq %r14, %rdi
callq 0x16f10
leaq 0x28(%rsp), %rdi
callq 0x79b8
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x79b8
leaq 0xaed4(%rip), %r12      # 0x2ca48
movq %r13, %rbp
movq (%rbp), %rbp
cmpq %r13, %rbp
je 0x21ba4
leaq 0x10(%rbp), %rsi
movq %r15, %rdi
movq %r12, %rdx
callq 0xc1e9
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7950
movq %r15, %rdi
callq 0x79b8
jmp 0x21b77
leaq 0xae9d(%rip), %r15      # 0x2ca48
leaq 0x8(%rsp), %r12
movq %r14, %r13
movq (%r13), %r13
cmpq %r14, %r13
je 0x21be0
leaq 0x10(%r13), %rsi
movq %r12, %rdi
movq %r15, %rdx
callq 0xc1e9
movq %rbx, %rdi
movq %r12, %rsi
callq 0x7950
movq %r12, %rdi
callq 0x79b8
jmp 0x21bb3
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpb $0x2f, -0x1(%rax,%rcx)
jne 0x21c17
leaq 0xae53(%rip), %rsi      # 0x2ca48
movq %rbx, %rdi
callq 0x8f4f
testb %al, %al
je 0x21c17
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
leaq (%rax,%rcx), %rsi
decq %rsi
movq %rbx, %rdi
callq 0x7600
leaq 0x48(%rsp), %rdi
callq 0x8f64
leaq 0x60(%rsp), %rdi
callq 0x8f64
movq %rbx, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x21c8f
movq %rax, %r14
leaq 0x28(%rsp), %rdi
callq 0x79b8
jmp 0x21c51
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x79b8
jmp 0x21cab
movq %rax, %r14
jmp 0x21cab
movq %rax, %r14
leaq 0x28(%rsp), %rdi
callq 0x79b8
jmp 0x21c7f
jmp 0x21c7c
jmp 0x21c7c
jmp 0x21c77
movq %rax, %r14
jmp 0x21cb5
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x79b8
jmp 0x21cb5
jmp 0x21c8f
jmp 0x21c94
movq %rax, %r14
jmp 0x21ca1
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x79b8
leaq 0x48(%rsp), %rdi
callq 0x8f64
leaq 0x60(%rsp), %rdi
callq 0x8f64
movq %rbx, %rdi
callq 0x79b8
movq %r14, %rdi
callq 0x7860
nop