// File: 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
movq %rsp, %rbp
subq $0x220, %rsp            # imm = 0x220
movq %rdi, -0x1d0(%rbp)
movq %rdi, %rax
movq %rax, -0x1c8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x1c0(%rbp)
movb $0x0, -0x21(%rbp)
callq 0x98c0
leaq -0x49(%rbp), %rdi
movq %rdi, -0x1b8(%rbp)
callq 0x9b10
movq -0x1b8(%rbp), %rdx
leaq 0x1dada(%rip), %rsi     # 0x6a838
leaq -0x48(%rbp), %rdi
callq 0xa780
jmp 0x4cd69
movq -0x1c0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x4c710
movq %rax, -0x1d8(%rbp)
jmp 0x4cd82
movq -0x1d8(%rbp), %rdi
callq 0x14310
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x9720
movq -0x1d0(%rbp), %rdi
movb (%rax), %al
subb $0x2f, %al
leaq 0x1dcac(%rip), %rax     # 0x6aa58
leaq 0x1dfbd(%rip), %rsi     # 0x6ad70
cmoveq %rax, %rsi
callq 0x98a0
jmp 0x4cdbe
leaq -0x48(%rbp), %rdi
callq 0x9c98
leaq -0x49(%rbp), %rdi
callq 0x9700
leaq -0x99(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x9b10
movq -0x1e0(%rbp), %rdx
leaq 0x1da47(%rip), %rsi     # 0x6a838
leaq -0x98(%rbp), %rdi
callq 0xa780
jmp 0x4cdff
movq -0x1c0(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x4c710
movq %rax, -0x1e8(%rbp)
jmp 0x4ce1b
movq -0x1e8(%rbp), %rdi
callq 0x14310
movq %rax, -0x1f8(%rbp)
leaq -0xc1(%rbp), %rdi
movq %rdi, -0x1f0(%rbp)
callq 0x9b10
movq -0x1f0(%rbp), %rdx
leaq 0x1dc09(%rip), %rsi     # 0x6aa58
leaq -0xc0(%rbp), %rdi
callq 0xa780
jmp 0x4ce5d
movq -0x1f8(%rbp), %rsi
leaq -0x78(%rbp), %rdi
leaq -0xc0(%rbp), %rdx
callq 0x2f910
jmp 0x4ce76
leaq -0xc0(%rbp), %rdi
callq 0x9c98
leaq -0xc1(%rbp), %rdi
callq 0x9700
leaq -0x98(%rbp), %rdi
callq 0x9c98
leaq -0x99(%rbp), %rdi
callq 0x9700
leaq -0x78(%rbp), %rdi
callq 0xcd10
movq -0x1c0(%rbp), %rdi
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
movq %rax, -0x200(%rbp)
callq 0x4c690
movq %rax, %rdi
callq 0x14310
movq %rax, %rdi
callq 0x9480
movq -0x200(%rbp), %rsi
movq %rax, %rdx
leaq -0x100(%rbp), %rdi
movq $-0x1, %rcx
callq 0x96b0
jmp 0x4cefd
leaq -0x121(%rbp), %rdi
movq %rdi, -0x208(%rbp)
callq 0x9b10
movq -0x208(%rbp), %rdx
leaq 0x1db3a(%rip), %rsi     # 0x6aa58
leaq -0x120(%rbp), %rdi
callq 0xa780
jmp 0x4cf2c
leaq -0xe0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
leaq -0x120(%rbp), %rdx
callq 0x2f910
jmp 0x4cf48
leaq -0x120(%rbp), %rdi
callq 0x9c98
leaq -0x121(%rbp), %rdi
callq 0x9700
leaq -0x100(%rbp), %rdi
callq 0x9c98
leaq -0x78(%rbp), %rdi
callq 0xcc30
movq %rax, -0x130(%rbp)
leaq -0x78(%rbp), %rdi
callq 0xccb0
movq %rax, -0x138(%rbp)
leaq -0x130(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x14110
testb $0x1, %al
jne 0x4cfa8
jmp 0x4d125
leaq -0x130(%rbp), %rdi
callq 0xd8f0
movq %rax, %rsi
leaq 0x1da9a(%rip), %rdx     # 0x6aa58
leaq -0x158(%rbp), %rdi
callq 0x14190
jmp 0x4cfcc
movq -0x1d0(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x9830
jmp 0x4cfe1
leaq -0x158(%rbp), %rdi
callq 0x9c98
leaq -0x130(%rbp), %rdi
xorl %esi, %esi
callq 0x142e0
movq %rax, -0x160(%rbp)
jmp 0x4cf7c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x4d02a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x9c98
leaq -0x49(%rbp), %rdi
callq 0x9700
jmp 0x4d2e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x4d092
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x4d086
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x4d07a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x9c98
leaq -0xc1(%rbp), %rdi
callq 0x9700
leaq -0x98(%rbp), %rdi
callq 0x9c98
leaq -0x99(%rbp), %rdi
callq 0x9700
jmp 0x4d2e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x4d2c2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x4d0da
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x9c98
leaq -0x121(%rbp), %rdi
callq 0x9700
leaq -0x100(%rbp), %rdi
callq 0x9c98
jmp 0x4d2c2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x4d2b6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x9c98
jmp 0x4d2b6
leaq -0xe0(%rbp), %rdi
callq 0xcc30
movq %rax, -0x168(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0xccb0
movq %rax, -0x170(%rbp)
leaq -0x168(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x14110
testb $0x1, %al
jne 0x4d164
jmp 0x4d1e0
leaq -0x168(%rbp), %rdi
callq 0xd8f0
movq %rax, %rsi
leaq 0x1d8de(%rip), %rdx     # 0x6aa58
leaq -0x190(%rbp), %rdi
callq 0x14190
jmp 0x4d188
movq -0x1d0(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x9830
jmp 0x4d19d
leaq -0x190(%rbp), %rdi
callq 0x9c98
leaq -0x168(%rbp), %rdi
xorl %esi, %esi
callq 0x142e0
movq %rax, -0x198(%rbp)
jmp 0x4d138
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x9c98
jmp 0x4d2b6
movq -0x1d0(%rbp), %rdi
callq 0x9480
movq -0x1d0(%rbp), %rdi
movq %rax, %rsi
decq %rsi
callq 0x9c70
movq %rax, -0x210(%rbp)
jmp 0x4d207
movq -0x210(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
jne 0x4d295
movq -0x1d0(%rbp), %rdi
leaq 0x1d834(%rip), %rsi     # 0x6aa58
callq 0xce40
movb %al, -0x211(%rbp)
jmp 0x4d231
movb -0x211(%rbp), %al
testb $0x1, %al
jne 0x4d23d
jmp 0x4d295
movq -0x1d0(%rbp), %rdi
callq 0x9400
movq %rax, -0x1a8(%rbp)
leaq -0x1a8(%rbp), %rdi
callq 0x32ef0
movq %rax, %rsi
leaq -0x1a0(%rbp), %rdi
callq 0x32f10
movq -0x1d0(%rbp), %rdi
movq -0x1a0(%rbp), %rsi
callq 0x97f0
movq %rax, -0x220(%rbp)
jmp 0x4d287
movq -0x220(%rbp), %rax
movq %rax, -0x1b0(%rbp)
movb $0x1, -0x21(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0xceb0
leaq -0x78(%rbp), %rdi
callq 0xceb0
testb $0x1, -0x21(%rbp)
jne 0x4d2d9
jmp 0x4d2cd
leaq -0xe0(%rbp), %rdi
callq 0xceb0
leaq -0x78(%rbp), %rdi
callq 0xceb0
jmp 0x4d2e9
movq -0x1d0(%rbp), %rdi
callq 0x9c98
movq -0x1c8(%rbp), %rax
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
movq -0x1d0(%rbp), %rdi
callq 0x9c98
movq -0x58(%rbp), %rdi
callq 0x9af0
nop