// File: mbourand[P]webserv/srcs/Config/ConfigContext.cpp
// Function: ConfigContext::parse_cgi_ext(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void ConfigContext::parse_cgi_ext(const std::string& directive_value)
{
	std::list<std::string> words = ft::split(directive_value, " \t\n");
	if (words.size() & 1)
		throw std::invalid_argument("No cgi path was provided for cgi_ext in config");
	bool extension_arg = true;
	std::string extension;
	for (std::list<std::string>::iterator it = words.begin(); it != words.end(); it++)
	{
		if (extension_arg)
		{
			if ((*it)[0] != '.')
				throw std::invalid_argument("Extension doesn't start with a dot for cgi_ext in config");
			extension = *it;
		}
		else
			_cgi_exts.insert(std::make_pair(extension, *it));
		extension_arg = !extension_arg;
	}
	for (std::map<std::string, std::string>::iterator it = _cgi_exts.begin(); it != _cgi_exts.end(); it++)
	{
		it->second = ft::simplify_path(it->second);
		if (!ft::is_executable(it->second.c_str()))
			throw std::invalid_argument("cgi_ext parameter is not an executable in config");
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x158(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x9b10
movq -0x150(%rbp), %rdx
leaq 0x226a0(%rip), %rsi     # 0x6bc67
leaq -0x48(%rbp), %rdi
callq 0xa780
jmp 0x495d2
movq -0x158(%rbp), %rsi
leaq -0x28(%rbp), %rdi
leaq -0x48(%rbp), %rdx
callq 0x2f910
jmp 0x495e8
leaq -0x48(%rbp), %rdi
callq 0x9c98
leaq -0x49(%rbp), %rdi
callq 0x9700
leaq -0x28(%rbp), %rdi
callq 0xcd10
andq $0x1, %rax
cmpq $0x0, %rax
je 0x496b4
movl $0x10, %edi
callq 0x9340
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x168(%rbp)
leaq 0x23b9f(%rip), %rsi     # 0x6d1ce
callq 0x9be0
jmp 0x49636
movq -0x168(%rbp), %rdi
movq 0x45984(%rip), %rsi     # 0x8efc8
movq 0x4596d(%rip), %rdx     # 0x8efb8
callq 0x9aa0
jmp 0x49ab1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x49678
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 0x49aa8
movq -0x168(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
callq 0x94c0
jmp 0x49a9f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x49a9f
movb $0x1, -0x5d(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x98c0
leaq -0x28(%rbp), %rdi
callq 0xcc30
movq %rax, -0x88(%rbp)
leaq -0x28(%rbp), %rdi
callq 0xccb0
movq %rax, -0x90(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x14110
testb $0x1, %al
jne 0x496fd
jmp 0x49888
testb $0x1, -0x5d(%rbp)
je 0x497c8
leaq -0x88(%rbp), %rdi
callq 0xd8f0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x9c70
movq %rax, -0x170(%rbp)
jmp 0x49728
movq -0x170(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2e, %eax
je 0x497a9
movl $0x10, %edi
callq 0x9340
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x178(%rbp)
leaq 0x23aa8(%rip), %rsi     # 0x6d1fd
callq 0x9be0
jmp 0x4975c
movq -0x178(%rbp), %rdi
movq 0x4585e(%rip), %rsi     # 0x8efc8
movq 0x45847(%rip), %rdx     # 0x8efb8
callq 0x9aa0
jmp 0x49ab1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x49a96
movq -0x178(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
callq 0x94c0
jmp 0x49a96
leaq -0x88(%rbp), %rdi
callq 0xd8f0
movq %rax, %rsi
leaq -0x80(%rbp), %rdi
callq 0x9070
jmp 0x497c3
jmp 0x49864
movq -0x160(%rbp), %rax
addq $0xc8, %rax
movq %rax, -0x180(%rbp)
leaq -0x88(%rbp), %rdi
callq 0xd8f0
movq %rax, %rdx
leaq -0xd0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x4dd60
jmp 0x497fd
movq -0x180(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x4dd20
movb %dl, -0x189(%rbp)
movq %rax, -0x188(%rbp)
jmp 0x4981f
movb -0x189(%rbp), %al
movq -0x188(%rbp), %rcx
movq %rcx, -0xe0(%rbp)
movb %al, -0xd8(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x4dda0
jmp 0x49864
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x4dda0
jmp 0x49a96
movb -0x5d(%rbp), %al
xorb $-0x1, %al
andb $0x1, %al
movb %al, -0x5d(%rbp)
leaq -0x88(%rbp), %rdi
xorl %esi, %esi
callq 0x142e0
movq %rax, -0xe8(%rbp)
jmp 0x496d1
movq -0x160(%rbp), %rdi
addq $0xc8, %rdi
callq 0x4ddd0
movq %rax, -0xf0(%rbp)
movq -0x160(%rbp), %rdi
addq $0xc8, %rdi
callq 0x4de30
movq %rax, -0xf8(%rbp)
leaq -0xf0(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x4de00
testb $0x1, %al
jne 0x498d8
jmp 0x49a7b
leaq -0xf0(%rbp), %rdi
callq 0x4de60
movq %rax, %rsi
addq $0x20, %rsi
leaq -0x118(%rbp), %rdi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0x32290
jmp 0x498fd
leaq -0xf0(%rbp), %rdi
movq %rdi, -0x1a8(%rbp)
callq 0x4de60
movq %rax, %rdi
addq $0x20, %rdi
leaq -0x118(%rbp), %rsi
movq %rsi, -0x1b0(%rbp)
callq 0x97e0
movq -0x1b0(%rbp), %rdi
callq 0x9c98
movq -0x1a8(%rbp), %rdi
callq 0x4de60
movq %rax, %rdi
addq $0x20, %rdi
callq 0x92b0
movq %rax, -0x1a0(%rbp)
leaq -0x139(%rbp), %rdi
movq %rdi, -0x198(%rbp)
callq 0x9b10
movq -0x1a0(%rbp), %rsi
movq -0x198(%rbp), %rdx
leaq -0x138(%rbp), %rdi
callq 0xa780
jmp 0x49984
leaq -0x138(%rbp), %rdi
callq 0x32140
movb %al, -0x1b1(%rbp)
jmp 0x49998
movb -0x1b1(%rbp), %al
xorb $-0x1, %al
movb %al, -0x1b2(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x9c98
leaq -0x139(%rbp), %rdi
callq 0x9700
movb -0x1b2(%rbp), %al
testb $0x1, %al
jne 0x499cd
jmp 0x49a5f
movl $0x10, %edi
callq 0x9340
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x1c0(%rbp)
leaq 0x2384b(%rip), %rsi     # 0x6d236
callq 0x9be0
jmp 0x499f2
movq -0x1c0(%rbp), %rdi
movq 0x455c8(%rip), %rsi     # 0x8efc8
movq 0x455b1(%rip), %rdx     # 0x8efb8
callq 0x9aa0
jmp 0x49ab1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x49a37
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x9c98
leaq -0x139(%rbp), %rdi
callq 0x9700
jmp 0x49a96
movq -0x1c0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
callq 0x94c0
jmp 0x49a96
jmp 0x49a61
leaq -0xf0(%rbp), %rdi
xorl %esi, %esi
callq 0x4de80
movq %rax, -0x148(%rbp)
jmp 0x498a2
leaq -0x80(%rbp), %rdi
callq 0x9c98
leaq -0x28(%rbp), %rdi
callq 0xceb0
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
leaq -0x80(%rbp), %rdi
callq 0x9c98
leaq -0x28(%rbp), %rdi
callq 0xceb0
movq -0x58(%rbp), %rdi
callq 0x9af0
nopw %cs:(%rax,%rax)