// File: mbourand[P]webserv/srcs/Utils/Utils.cpp
// Function: ft::toFloat(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
float	ft::toFloat(const std::string& str)
{
	if (str.empty())
		return 0;


	if (str.find_first_not_of("0123456789.-+") != std::string::npos)
		throw std::invalid_argument("String is not a float");

	if (std::count(str.begin(), str.end(), '-') == 1)
		if (str[0] != '-')
			throw std::invalid_argument("String is not a float");

	if (std::count(str.begin(), str.end(), '+') == 1)
		if (str[0] != '+')
			throw std::invalid_argument("String is not a float");

	if (std::count(str.begin(), str.end(), '.') > 1)
		throw std::invalid_argument("String is not a float");

	std::istringstream iss(str);
	float ret = 0;
	iss >> ret;
	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x220, %rsp            # imm = 0x220
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x9a50
testb $0x1, %al
jne 0x2f40e
jmp 0x2f41b
xorps %xmm0, %xmm0
movss %xmm0, -0x4(%rbp)
jmp 0x2f6df
movq -0x10(%rbp), %rdi
leaq 0x3c1a7(%rip), %rsi     # 0x6b5cd
xorl %eax, %eax
movl %eax, %edx
callq 0x93f0
cmpq $-0x1, %rax
je 0x2f491
movl $0x10, %edi
callq 0x9340
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x1f8(%rbp)
leaq 0x3c188(%rip), %rsi     # 0x6b5db
callq 0x9be0
jmp 0x2f45a
movq -0x1f8(%rbp), %rdi
movq 0x5fb60(%rip), %rsi     # 0x8efc8
movq 0x5fb49(%rip), %rdx     # 0x8efb8
callq 0x9aa0
movq -0x1f8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
callq 0x94c0
jmp 0x2f6ed
movq -0x10(%rbp), %rdi
callq 0x9640
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
callq 0x9bd0
movq %rax, -0x30(%rbp)
movb $0x2d, -0x31(%rbp)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
leaq -0x31(%rbp), %rdx
callq 0x32d60
cmpq $0x1, %rax
jne 0x2f539
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x9720
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x2f537
movl $0x10, %edi
callq 0x9340
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x200(%rbp)
leaq 0x3c0e2(%rip), %rsi     # 0x6b5db
callq 0x9be0
jmp 0x2f500
movq -0x200(%rbp), %rdi
movq 0x5faba(%rip), %rsi     # 0x8efc8
movq 0x5faa3(%rip), %rdx     # 0x8efb8
callq 0x9aa0
movq -0x200(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
callq 0x94c0
jmp 0x2f6ed
jmp 0x2f539
movq -0x10(%rbp), %rdi
callq 0x9640
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
callq 0x9bd0
movq %rax, -0x48(%rbp)
movb $0x2b, -0x49(%rbp)
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
leaq -0x49(%rbp), %rdx
callq 0x32d60
cmpq $0x1, %rax
jne 0x2f5e1
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x9720
movsbl (%rax), %eax
cmpl $0x2b, %eax
je 0x2f5df
movl $0x10, %edi
callq 0x9340
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x208(%rbp)
leaq 0x3c03a(%rip), %rsi     # 0x6b5db
callq 0x9be0
jmp 0x2f5a8
movq -0x208(%rbp), %rdi
movq 0x5fa12(%rip), %rsi     # 0x8efc8
movq 0x5f9fb(%rip), %rdx     # 0x8efb8
callq 0x9aa0
movq -0x208(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
callq 0x94c0
jmp 0x2f6ed
jmp 0x2f5e1
movq -0x10(%rbp), %rdi
callq 0x9640
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
callq 0x9bd0
movq %rax, -0x60(%rbp)
movb $0x2e, -0x61(%rbp)
movq -0x58(%rbp), %rdi
movq -0x60(%rbp), %rsi
leaq -0x61(%rbp), %rdx
callq 0x32d60
cmpq $0x1, %rax
jle 0x2f66f
movl $0x10, %edi
callq 0x9340
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x210(%rbp)
leaq 0x3bfa7(%rip), %rsi     # 0x6b5db
callq 0x9be0
jmp 0x2f63b
movq -0x210(%rbp), %rdi
movq 0x5f97f(%rip), %rsi     # 0x8efc8
movq 0x5f968(%rip), %rdx     # 0x8efb8
callq 0x9aa0
movq -0x210(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
callq 0x94c0
jmp 0x2f6ed
movq -0x10(%rbp), %rsi
leaq -0x1e8(%rbp), %rdi
movq %rdi, -0x218(%rbp)
movl $0x8, %edx
callq 0x9a60
movq -0x218(%rbp), %rdi
movl $0x0, -0x1ec(%rbp)
leaq -0x1ec(%rbp), %rsi
callq 0x9140
jmp 0x2f6aa
movss -0x1ec(%rbp), %xmm0
movss %xmm0, -0x4(%rbp)
leaq -0x1e8(%rbp), %rdi
callq 0x9310
jmp 0x2f6df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x1e8(%rbp), %rdi
callq 0x9310
jmp 0x2f6ed
movss -0x4(%rbp), %xmm0
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
movq -0x18(%rbp), %rdi
callq 0x9af0
nopw %cs:(%rax,%rax)