// File: /workspace/github_cpp_makefile_star2_O3/mbourand[P]webserv/srcs/Config/ConfigContext.cpp
// Function: ConfigContext::ConfigContext(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, ConfigContext const*)
ConfigContext::ConfigContext(const std::string& raw, const std::string& name, const ConfigContext* parent)
	: _autoIndex(false)
{
	handle_parent_and_directives(parent, name);

	for (size_t i = 0; i < raw.size();)
	{
		// On skip les whitepsaces en début de ligne
		i = raw.find_first_not_of(" \t", i);
		if (i == std::string::npos)
			break;

		// Si la ligne est vide ou que c'est un commentaire, on skip la ligne
		if (raw[i] == '\n' || raw[i] == '#')
		{
			i = raw.find('\n', i) + 1;
			continue;
		}

		// On récupère le nom de la directive, par exemple : "server_name" ou "root", etc.
		std::string directive_name = raw.substr(i, raw.find_first_of(" \t", i) - i);
		if (!ft::contains(_directive_names, directive_name))
			throw std::invalid_argument("Unknown directive name in config");

		// Pour empêcher une directive d'apparaître deux fois dans le même context
		if (_params.find(directive_name) != _params.end())
			_params.erase(_params.find(directive_name));

		i += directive_name.size();
		i = raw.find_first_not_of(" \t", i);

		std::string directive_value = raw.substr(i, raw.find('\n', i) - i);
		if (directive_value.empty())
			throw std::invalid_argument("Empty directive value in config");

		if (directive_name == "location")
		{
			// On récupère le chemin de la location (juste après le nom de la directive)
			std::string location_name = raw.substr(i, raw.find_first_of(" \t\n", i) - i);
			i += location_name.size();
			i = raw.find_first_not_of(" \t", i);

			// Si il n'y a pas d'accolate ouvrante, la config est invalide
			if (raw[i] != '{')
				throw std::invalid_argument("Bad curly braces in config");
			i = raw.find_first_not_of(" \t", i + 1);

			// Si il n'y a pas de retour à la ligne après les espaces, la config est invalide
			if (raw[i] != '\n')
				throw std::invalid_argument("Bad new line in config");

			// On récupère le contenu du fichier qui concerne la location
			std::string location_raw = raw.substr(i, find_closing_bracket(raw, i) - i - 2);
			_childs.push_back(ConfigContext(location_raw, location_name, this));
			i += location_raw.size() + 2;
			if (raw.find('\n', i) == std::string::npos)
				break;
			i = raw.find('\n', i) + 1;
			continue;
		}
		else if (directive_name == "server_name")
			parse_server_name(directive_value);
		else if (directive_name == "error_page")
			parse_error_page(directive_value);
		else if (directive_name == "autoindex")
			parse_autoindex(directive_value);
		else if (directive_name == "disable_methods")
			parse_methods(directive_value);
		else if (directive_name == "cgi_ext")
			parse_cgi_ext(directive_value);
		else if (directive_name == "uploads_exts")
			parse_uploads_exts(directive_value);
		else if (directive_name == "auth_basic")
			parse_auth_basic(directive_value);
		else
		{
			std::string directive_value = raw.substr(i, raw.find('\n', i) - i);
			if (directive_value.size() == 0)
				throw std::invalid_argument("Empty directive value in config");
			_params.insert(std::make_pair(directive_name, ft::split(directive_value, " \t")));
		}
		if (raw.find('\n', i) == std::string::npos)
			break;
		i = raw.find('\n', i) + 1;
	}
	if (ft::contains(_directive_names, "listen") && _params.find("listen") == _params.end())
		throw std::invalid_argument("No listen in config");
	set_uploads_default();
	set_root_default(parent);
	set_max_body_size_default();
	set_cgi_dir_default();
	set_auth_basic_default();
	if (_params["auth_basic"].front() != "")
		set_auth_basic_user_file_default();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1e8, %rsp            # imm = 0x1E8
movq %rcx, %r8
movq %rsi, %rbp
movq %rdi, %r13
leaq 0x25fab(%rip), %rax     # 0x4dca0
movq %rax, (%rdi)
leaq 0x8(%rdi), %rbx
movq %rbx, 0x10(%rdi)
movq %rbx, 0x8(%rdi)
xorl %eax, %eax
movq %rax, 0x18(%rdi)
leaq 0x20(%rdi), %rcx
movq %rcx, 0x8(%rsp)
leaq 0x28(%rdi), %rcx
movl %eax, 0x28(%rdi)
movq %rax, 0x30(%rdi)
movq %rcx, 0x38(%rdi)
movq %rcx, 0x78(%rsp)
movq %rcx, 0x40(%rdi)
movq %rax, 0x48(%rdi)
leaq 0x50(%rdi), %rcx
movq %rcx, 0x58(%rdi)
movq %rcx, 0x70(%rsp)
movq %rcx, 0x50(%rdi)
movq %rax, 0x60(%rdi)
leaq 0x70(%rdi), %rcx
movl %eax, 0x70(%rdi)
movq %rax, 0x78(%rdi)
movq %rcx, 0x80(%rdi)
movq %rcx, 0x88(%rdi)
movq %rax, 0x90(%rdi)
leaq 0x98(%rdi), %rcx
movq %rcx, 0xa0(%rdi)
movq %rcx, 0xa8(%rsp)
movq %rcx, 0x98(%rdi)
movq %rax, 0xa8(%rdi)
leaq 0xb0(%rdi), %r14
movq %r14, 0xb8(%rdi)
movq %r14, 0xb0(%rdi)
movq %rax, 0xc0(%rdi)
leaq 0xd0(%rdi), %rcx
movl %eax, 0xd0(%rdi)
movq %rax, 0xd8(%rdi)
movq %rcx, 0xe0(%rdi)
movq %rcx, 0xe8(%rdi)
movq %rax, 0xf0(%rdi)
leaq 0xf8(%rdi), %rcx
movq %rcx, 0x100(%rdi)
movq %rcx, 0xa0(%rsp)
movq %rcx, 0xf8(%rdi)
movq %rax, 0x108(%rdi)
movb $0x0, 0x110(%rdi)
movq %r8, 0xb0(%rsp)
movq %r8, %rsi
callq 0x2881a
movq %r13, (%rsp)
cmpq $0x0, 0x8(%rbp)
je 0x283ca
xorl %r13d, %r13d
leaq 0x80(%rsp), %r12
leaq 0xd0(%rsp), %r15
movl $0x2, %ecx
movq %rbp, %rdi
leaq 0x13a27(%rip), %rsi     # 0x3b860
movq %r13, %rdx
callq 0x77a0
cmpq $-0x1, %rax
je 0x283ca
movq %rax, %r13
movq (%rbp), %rax
movzbl (%rax,%r13), %eax
cmpl $0x23, %eax
je 0x27e61
cmpl $0xa, %eax
jne 0x27e82
movq %rbp, %rdi
movl $0xa, %esi
movq %r13, %rdx
callq 0x75c0
movq %rax, %r13
incq %r13
cmpq 0x8(%rbp), %r13
jb 0x27e2a
jmp 0x283ca
movl $0x2, %ecx
movq %rbp, %rdi
leaq 0x139cf(%rip), %rsi     # 0x3b860
movq %r13, %rdx
callq 0x76c0
subq %r13, %rax
movq %r12, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rax, %rcx
callq 0x74d0
movq %r12, %rax
movq (%rbx), %r12
movq %rax, 0xd0(%rsp)
cmpq %rbx, %r12
je 0x28524
movq %r15, %rdi
movq %r12, %rsi
callq 0x2d37a
testb %al, %al
jne 0x27ed9
movq (%r12), %r12
jmp 0x27ebb
cmpq %rbx, %r12
je 0x28524
movq 0x8(%rsp), %rdi
leaq 0x80(%rsp), %r12
movq %r12, %rsi
callq 0x2d3ac
cmpq 0x78(%rsp), %rax
je 0x27f21
movq %r12, %rsi
movq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x2d3ac
movq %r12, %rdi
movq %rax, %rsi
callq 0x2d436
leaq 0x80(%rsp), %r12
movq 0x88(%rsp), %rdx
addq %r13, %rdx
movl $0x2, %ecx
movq %rbp, %rdi
leaq 0x13925(%rip), %rsi     # 0x3b860
callq 0x77a0
movq %rax, %r13
movq %rbp, %rdi
movl $0xa, %esi
movq %rax, %rdx
callq 0x75c0
subq %r13, %rax
leaq 0x50(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rax, %rcx
callq 0x74d0
cmpq $0x0, 0x58(%rsp)
je 0x2855b
movq %r12, %rdi
leaq 0x14f6b(%rip), %rsi     # 0x3ceea
callq 0x7180
testl %eax, %eax
je 0x2810f
movq %r12, %rdi
leaq 0x14dad(%rip), %rsi     # 0x3cd43
callq 0x7180
testl %eax, %eax
je 0x281d5
movq %r12, %rdi
leaq 0x14da2(%rip), %rsi     # 0x3cd4f
callq 0x7180
testl %eax, %eax
je 0x281e8
movq %r12, %rdi
leaq 0x14d96(%rip), %rsi     # 0x3cd5a
callq 0x7180
testl %eax, %eax
je 0x282de
movq %r12, %rdi
leaq 0x14d89(%rip), %rsi     # 0x3cd64
callq 0x7180
testl %eax, %eax
je 0x282ee
movq %r12, %rdi
leaq 0x14d82(%rip), %rsi     # 0x3cd74
callq 0x7180
testl %eax, %eax
je 0x282fe
movq %r12, %rdi
leaq 0x14d73(%rip), %rsi     # 0x3cd7c
callq 0x7180
testl %eax, %eax
je 0x2830e
movq %r12, %rdi
leaq 0x14d69(%rip), %rsi     # 0x3cd89
callq 0x7180
testl %eax, %eax
je 0x2831e
movq %rbp, %rdi
movl $0xa, %esi
movq %r13, %rdx
callq 0x75c0
subq %r13, %rax
leaq 0x30(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rax, %rcx
callq 0x74d0
cmpq $0x0, 0x38(%rsp)
leaq 0x10(%rsp), %rcx
je 0x2861a
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq %rcx, %rdi
leaq 0x137e8(%rip), %rsi     # 0x3b860
leaq 0x137e3(%rip), %rdx     # 0x3b862
callq 0x80f4
leaq 0xb8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x1bf30
movq %r15, %rdi
movq %r12, %rsi
leaq 0xb8(%rsp), %r12
movq %r12, %rdx
callq 0x2cd92
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x2d4b8
movq %r15, %rdi
callq 0x2bf04
movq %r12, %rdi
callq 0x96b6
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x280ea
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x74b0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x2832c
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x2832c
movl $0x3, %ecx
movq %rbp, %rdi
leaq 0x1376d(%rip), %rsi     # 0x3b88b
movq %r13, %rdx
callq 0x76c0
subq %r13, %rax
leaq 0x30(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rax, %rcx
callq 0x74d0
movq 0x38(%rsp), %rdx
addq %r13, %rdx
movl $0x2, %ecx
movq %rbp, %rdi
leaq 0x1370d(%rip), %r12     # 0x3b860
movq %r12, %rsi
callq 0x77a0
movq (%rbp), %rcx
cmpb $0x7b, (%rcx,%rax)
jne 0x28592
incq %rax
movl $0x2, %ecx
movq %rbp, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x77a0
movq %rax, %r13
movq (%rbp), %rax
cmpb $0xa, (%rax,%r13)
jne 0x285b0
movq 0x8(%rbp), %rdx
movq $-0x1, %rcx
cmpq %r13, %rdx
jbe 0x281fe
movl $0x1, %edi
movq %r13, %rsi
movb (%rax,%rsi), %r8b
xorl %r9d, %r9d
cmpb $0x7b, %r8b
sete %r9b
addq %r9, %rdi
xorl %r9d, %r9d
cmpb $0x7d, %r8b
sete %r9b
subq %r9, %rdi
je 0x281fb
incq %rsi
cmpq %rsi, %rdx
jne 0x281a9
jmp 0x281fe
movq (%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x28988
jmp 0x2832c
movq (%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x28aa2
jmp 0x2832c
movq %rsi, %rcx
leaq 0x10(%rsp), %r12
subq %r13, %rcx
addq $-0x2, %rcx
movq %r12, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x74d0
movq %r15, %rdi
movq %r12, %rsi
leaq 0x30(%rsp), %rdx
movq (%rsp), %rcx
callq 0x27cd4
movq 0x70(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x2d474
movq %rax, %rdi
movq %r12, %rsi
callq 0x7090
movq (%rsp), %rax
incq 0x60(%rax)
movq %r15, %rdi
callq 0x279dc
movq 0x18(%rsp), %rax
addq %rax, %r13
addq $0x2, %r13
movq %rbp, %rdi
movl $0xa, %esi
movq %r13, %rdx
callq 0x75c0
cmpq $-0x1, %rax
je 0x28297
movq %rbp, %rdi
movl $0xa, %esi
movq %r13, %rdx
callq 0x75c0
movq %rax, %r13
incq %r13
movl $0x3, %r12d
jmp 0x2829d
movl $0x2, %r12d
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x282b9
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x74b0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x28363
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x28363
movq (%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x28d26
jmp 0x2832c
movq (%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x28e9e
jmp 0x2832c
movq (%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x29014
jmp 0x2832c
movq (%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x29374
jmp 0x2832c
movq (%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x295cc
movq %rbp, %rdi
movl $0xa, %esi
movq %r13, %rdx
callq 0x75c0
cmpq $-0x1, %rax
je 0x2835d
movq %rbp, %rdi
movl $0xa, %esi
movq %r13, %rdx
callq 0x75c0
movq %rax, %r13
incq %r13
xorl %r12d, %r12d
jmp 0x28363
movl $0x2, %r12d
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x2837f
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x74b0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x283a4
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x74b0
testl %r12d, %r12d
je 0x283bd
cmpl $0x3, %r12d
leaq 0x80(%rsp), %r12
je 0x27e77
jmp 0x283ca
leaq 0x80(%rsp), %r12
jmp 0x27e77
movq (%rbx), %r12
cmpq %rbx, %r12
movq (%rsp), %r13
movq 0x8(%rsp), %rbp
je 0x2846a
leaq 0x149ae(%rip), %r15     # 0x3cd94
leaq 0x10(%r12), %rdi
movq %r15, %rsi
callq 0x7180
testl %eax, %eax
je 0x28402
movq (%r12), %r12
cmpq %rbx, %r12
jne 0x283e6
jmp 0x2846a
cmpq %rbx, %r12
je 0x2846a
leaq 0xe0(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x14979(%rip), %rsi     # 0x3cd94
leaq 0x14978(%rip), %rdx     # 0x3cd9a
leaq 0xd0(%rsp), %rdi
callq 0x80f4
leaq 0xd0(%rsp), %rsi
movq %rbp, %rdi
callq 0x2d3ac
movq %rax, %r15
movq 0xd0(%rsp), %rdi
cmpq %r12, %rdi
je 0x2845f
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x74b0
cmpq 0x78(%rsp), %r15
je 0x285e2
movq %r13, %rdi
callq 0x297a0
movq %r13, %rdi
movq 0xb0(%rsp), %rsi
callq 0x29b36
movq %r13, %rdi
callq 0x29dee
movq %r13, %rdi
callq 0x2a080
movq %r13, %rdi
callq 0x2a416
leaq 0xe0(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x148db(%rip), %rsi     # 0x3cd89
leaq 0x148de(%rip), %rdx     # 0x3cd93
leaq 0xd0(%rsp), %rdi
callq 0x80f4
leaq 0xd0(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0x2bf2c
movq (%rax), %rdi
addq $0x10, %rdi
leaq 0x128b9(%rip), %rsi     # 0x3ad9b
callq 0x7180
movl %eax, %ebp
movq 0xd0(%rsp), %rdi
cmpq %r12, %rdi
je 0x28506
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x74b0
testl %ebp, %ebp
je 0x28512
movq %r13, %rdi
callq 0x2a5aa
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x7260
movq %rax, %r12
leaq 0x147b8(%rip), %rsi     # 0x3ccf0
movq %rax, %rdi
callq 0x78c0
movq 0x25a81(%rip), %rsi     # 0x4dfc8
movq 0x25a62(%rip), %rdx     # 0x4dfb0
movq %r12, %rdi
callq 0x77d0
jmp 0x2864c
movl $0x10, %edi
callq 0x7260
movq %rax, %r12
leaq 0x132fc(%rip), %rsi     # 0x3b86b
movq %rax, %rdi
callq 0x78c0
movq 0x25a4a(%rip), %rsi     # 0x4dfc8
movq 0x25a2b(%rip), %rdx     # 0x4dfb0
movq %r12, %rdi
callq 0x77d0
jmp 0x2864c
movl $0x10, %edi
callq 0x7260
movq %rax, %r12
leaq 0x1476b(%rip), %rsi     # 0x3cd11
movq %rax, %rdi
callq 0x78c0
jmp 0x285cc
movl $0x10, %edi
callq 0x7260
movq %rax, %r12
leaq 0x14768(%rip), %rsi     # 0x3cd2c
movq %rax, %rdi
callq 0x78c0
movq 0x259f5(%rip), %rsi     # 0x4dfc8
movq 0x259d6(%rip), %rdx     # 0x4dfb0
movq %r12, %rdi
callq 0x77d0
movl $0x10, %edi
callq 0x7260
movq %rax, %r12
leaq 0x147a5(%rip), %rsi     # 0x3cd9b
movq %rax, %rdi
callq 0x78c0
movq 0x259c3(%rip), %rsi     # 0x4dfc8
movq 0x259a4(%rip), %rdx     # 0x4dfb0
movq %r12, %rdi
movq (%rsp), %r13
callq 0x77d0
jmp 0x2864c
movl $0x10, %edi
callq 0x7260
movq %rax, %r12
leaq 0x1323d(%rip), %rsi     # 0x3b86b
movq %rax, %rdi
callq 0x78c0
movq 0x2598b(%rip), %rsi     # 0x4dfc8
movq 0x2596c(%rip), %rdx     # 0x4dfb0
movq %r12, %rdi
callq 0x77d0
jmp 0x28704
jmp 0x2869c
movq %rax, %r15
leaq 0xd0(%rsp), %rdi
callq 0x2bf04
jmp 0x28668
movq %rax, %r15
leaq 0xb8(%rsp), %rdi
callq 0x96b6
jmp 0x286e4
jmp 0x286e1
jmp 0x28704
jmp 0x28736
movq %rax, %r15
movq %r12, %rdi
callq 0x7390
jmp 0x2879c
jmp 0x286a9
jmp 0x2875d
jmp 0x2869c
movq %rax, %r15
movq %r12, %rdi
callq 0x7390
jmp 0x28707
movq %rax, %r15
movq 0xd0(%rsp), %rdi
cmpq %r12, %rdi
je 0x2879c
movq 0xe0(%rsp), %rsi
jmp 0x28794
jmp 0x2875d
movq %rax, %r15
leaq 0xd0(%rsp), %rdi
callq 0x279dc
jmp 0x286e4
movq %rax, %r15
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x28707
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x28707
jmp 0x28704
movq %rax, %r15
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x28739
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x28739
jmp 0x28736
jmp 0x28736
movq %rax, %r15
movq %r12, %rdi
callq 0x7390
jmp 0x28739
movq %rax, %r15
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x28777
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x28777
jmp 0x28767
jmp 0x28767
jmp 0x28767
movq %rax, %r15
jmp 0x2879c
movq %rax, %r15
jmp 0x287a0
movq %rax, %r15
jmp 0x28777
movq %rax, %r15
movq %r12, %rdi
callq 0x7390
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x2879c
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x74b0
movq (%rsp), %r13
leaq 0xc8(%r13), %r12
movq 0xa0(%rsp), %rdi
callq 0x96b6
movq %r12, %rdi
callq 0x2c110
movq (%r14), %rdi
cmpq %r14, %rdi
movq 0x8(%rsp), %rbp
je 0x287de
movq (%rdi), %r12
movl $0x18, %esi
callq 0x74b0
movq %r12, %rdi
cmpq %r14, %r12
jne 0x287c9
addq $0x68, %r13
movq 0xa8(%rsp), %rdi
callq 0x96b6
movq %r13, %rdi
callq 0x2c1a2
movq 0x70(%rsp), %rdi
callq 0x2c21a
movq %rbp, %rdi
callq 0x2c252
movq %rbx, %rdi
callq 0x96b6
movq %r15, %rdi
callq 0x7810
nop