// File: /workspace/github_cpp_makefile_star2_O3/mbourand[P]webserv/srcs/Utils/URL.cpp
// Function: URL::URL(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
URL::URL(const std::string& url)
	: _is_directory(false)
{
	if (url.size() == 0)
		throw std::invalid_argument("Empty url");

	if (url == "*")
	{
		_path = "*";
		return;
	}
	else if (url[0] == '/')
		parse_partial(url);
	else
		parse_full(url);

	if (_port.empty())
		_port = "80";
	if (_path.empty())
		_path = "/";

	if (_path.find_first_not_of('/') != std::string::npos && _path[_path.size() - 1] == '/')
	{
		while (_path[_path.size() - 1] == '/')
			_path = _path.substr(0, _path.size() - 1);
		_is_directory = true;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
leaq 0x32d1a(%rip), %rax     # 0x4dc10
movq %rax, (%rdi)
leaq 0x18(%rdi), %r13
movq %r13, 0x8(%rdi)
xorl %eax, %eax
movq %rax, 0x10(%rdi)
movb %al, 0x18(%rdi)
leaq 0x38(%rdi), %rcx
movq %rcx, 0x28(%rsp)
movq %rcx, 0x28(%rdi)
movq %rax, 0x30(%rdi)
movb %al, 0x38(%rdi)
leaq 0x58(%rdi), %rcx
movq %rcx, 0x20(%rsp)
movq %rcx, 0x48(%rdi)
movq %rax, 0x50(%rdi)
movb %al, 0x58(%rdi)
leaq 0x68(%rdi), %rcx
movq %rcx, 0x30(%rsp)
leaq 0x78(%rdi), %rcx
movq %rcx, 0x18(%rsp)
movq %rcx, 0x68(%rdi)
movq %rax, 0x70(%rdi)
movb %al, 0x78(%rdi)
leaq 0x88(%rdi), %r15
leaq 0x98(%rdi), %rcx
movq %rcx, 0x10(%rsp)
movq %rcx, 0x88(%rdi)
movq %rax, 0x90(%rdi)
movb %al, 0x98(%rdi)
leaq 0xb8(%rdi), %r14
movq %r14, 0xa8(%rdi)
movq %rax, 0xb0(%rdi)
movb %al, 0xb8(%rdi)
leaq 0xd8(%rdi), %rbp
movq %rbp, 0xc8(%rdi)
movq %rax, 0xd0(%rdi)
movb %al, 0xd8(%rdi)
movb %al, 0xe8(%rdi)
cmpq %rax, 0x8(%rsi)
je 0x1b0f5
movq %rsi, %r12
leaq 0x1f84d(%rip), %rsi     # 0x3a813
movq %r12, %rdi
callq 0x7180
testl %eax, %eax
je 0x1afe8
movq (%r12), %rax
cmpb $0x2f, (%rax)
jne 0x1b00b
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1b20a
jmp 0x1b016
movq 0x90(%rbx), %rdx
leaq 0x1f81d(%rip), %rcx     # 0x3a813
movl $0x1, %r8d
movq %r15, %rdi
xorl %esi, %esi
callq 0x76f0
jmp 0x1b0e6
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1b3b8
cmpq $0x0, 0x70(%rbx)
jne 0x1b038
leaq 0x1fe44(%rip), %rcx     # 0x3ae68
movl $0x2, %r8d
movq 0x30(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x76f0
cmpq $0x0, 0x90(%rbx)
jne 0x1b05b
leaq 0x1fa4b(%rip), %rcx     # 0x3aa94
movl $0x1, %r8d
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x76f0
movq %r15, %rdi
movl $0x2f, %esi
xorl %edx, %edx
callq 0x7440
cmpq $-0x1, %rax
je 0x1b0e6
movq 0x88(%rbx), %rax
movq 0x90(%rbx), %rcx
cmpb $0x2f, -0x1(%rax,%rcx)
jne 0x1b0e6
movq %r13, 0x8(%rsp)
decq %rcx
leaq 0x48(%rsp), %r13
leaq 0x38(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x74d0
movq %r15, %rdi
movq %r12, %rsi
callq 0x7590
movq 0x38(%rsp), %rdi
cmpq %r13, %rdi
je 0x1b0c6
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x74b0
movq 0x88(%rbx), %rax
movq 0x90(%rbx), %rdx
leaq -0x1(%rdx), %rcx
cmpb $0x2f, -0x1(%rax,%rdx)
je 0x1b097
movb $0x1, 0xe8(%rbx)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, 0x8(%rsp)
movl $0x10, %edi
callq 0x7260
movq %rax, %r13
leaq 0x1fd50(%rip), %rsi     # 0x3ae5e
movq %rax, %rdi
callq 0x78c0
movq 0x32eab(%rip), %rsi     # 0x4dfc8
movq 0x32e8c(%rip), %rdx     # 0x4dfb0
movq %r13, %rdi
movq 0x8(%rsp), %r13
callq 0x77d0
movq %rax, %r12
movq %r13, %rdi
callq 0x7390
jmp 0x1b148
movq %r13, 0x8(%rsp)
jmp 0x1b145
movq %rax, %r12
movq 0xc8(%rbx), %rdi
cmpq %rbp, %rdi
je 0x1b160
movq (%rbp), %rsi
incq %rsi
callq 0x74b0
movq 0xa8(%rbx), %rdi
cmpq %r14, %rdi
je 0x1b177
movq (%r14), %rsi
incq %rsi
callq 0x74b0
movq (%r15), %rdi
cmpq 0x10(%rsp), %rdi
je 0x1b191
movq 0x10(%rsp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x74b0
movq 0x30(%rsp), %rax
movq (%rax), %rdi
cmpq 0x18(%rsp), %rdi
je 0x1b1b0
movq 0x18(%rsp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x74b0
movq 0x48(%rbx), %rdi
cmpq 0x20(%rsp), %rdi
je 0x1b1cb
movq 0x20(%rsp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x74b0
movq 0x28(%rbx), %rdi
cmpq 0x28(%rsp), %rdi
je 0x1b1e6
movq 0x28(%rsp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x74b0
movq 0x8(%rbx), %rdi
cmpq 0x8(%rsp), %rdi
je 0x1b201
movq 0x8(%rsp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x74b0
movq %r12, %rdi
callq 0x7810
nop