// File: mbourand[P]webserv/srcs/Socket/Socket.cpp
// Function: my_inet_aton(char const*, in_addr*)
static int				my_inet_aton (const char *cp, struct in_addr *inp)
{
	std::string			host(cp);
	std::string			fragment;
	in_addr_t			result;
	u_int				parts[4];
	int					i = 0;

	if (host == "localhost")
		host = "127.0.0.1";
	std::stringstream	ss(host);
	while (getline(ss, fragment, '.') && (i < 4))
		parts[i++] = ft::toInt(fragment);
	if (i != 4)
		return (0);
	if ((parts[0] > 0xff) || (parts[1] > 0xff) || (parts[2] > 0xff) || (parts[3] > 0xff))
		return (0);
	result = (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8) | parts[3];
	if (inp)
		inp->s_addr = htonl(result);
	return (1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x250, %rsp            # imm = 0x250
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x238(%rbp)
leaq -0x39(%rbp), %rdi
movq %rdi, -0x230(%rbp)
callq 0x9b10
movq -0x238(%rbp), %rsi
movq -0x230(%rbp), %rdx
leaq -0x38(%rbp), %rdi
callq 0xa780
jmp 0x1c887
leaq -0x39(%rbp), %rdi
callq 0x9700
leaq -0x70(%rbp), %rdi
callq 0x98c0
movl $0x0, -0x94(%rbp)
leaq 0x4e153(%rip), %rsi     # 0x6a9fd
leaq -0x38(%rbp), %rdi
callq 0xdf50
movb %al, -0x239(%rbp)
jmp 0x1c8bb
movb -0x239(%rbp), %al
testb $0x1, %al
jne 0x1c8c7
jmp 0x1c906
leaq 0x4e139(%rip), %rsi     # 0x6aa07
leaq -0x38(%rbp), %rdi
callq 0x98a0
jmp 0x1c8d9
jmp 0x1c906
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x39(%rbp), %rdi
callq 0x9700
jmp 0x1cae5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1cad3
movl $0x10, %edi
movl $0x8, %esi
callq 0x14730
movl %eax, -0x240(%rbp)
jmp 0x1c91d
movl -0x240(%rbp), %edx
leaq -0x220(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x99d0
jmp 0x1c935
jmp 0x1c937
leaq -0x220(%rbp), %rdi
leaq -0x70(%rbp), %rsi
movl $0x2e, %edx
callq 0x9bb0
movq %rax, -0x248(%rbp)
jmp 0x1c955
movq -0x248(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x9810
movb %al, -0x249(%rbp)
jmp 0x1c973
movb -0x249(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x24a(%rbp)
jne 0x1c988
jmp 0x1c998
cmpl $0x4, -0x94(%rbp)
setl %al
movb %al, -0x24a(%rbp)
movb -0x24a(%rbp), %al
testb $0x1, %al
jne 0x1c9a4
jmp 0x1c9f7
leaq -0x70(%rbp), %rdi
callq 0x2f2a0
movl %eax, -0x250(%rbp)
jmp 0x1c9b5
movl -0x250(%rbp), %ecx
movl -0x94(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x94(%rbp)
cltq
movl %ecx, -0x90(%rbp,%rax,4)
jmp 0x1c937
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x94e0
jmp 0x1cad3
cmpl $0x4, -0x94(%rbp)
je 0x1ca16
movl $0x0, -0x4(%rbp)
movl $0x1, -0x224(%rbp)
jmp 0x1caa9
cmpl $0xff, -0x90(%rbp)
ja 0x1ca46
cmpl $0xff, -0x8c(%rbp)
ja 0x1ca46
cmpl $0xff, -0x88(%rbp)
ja 0x1ca46
cmpl $0xff, -0x84(%rbp)
jbe 0x1ca59
movl $0x0, -0x4(%rbp)
movl $0x1, -0x224(%rbp)
jmp 0x1caa9
movl -0x90(%rbp), %eax
shll $0x18, %eax
movl -0x8c(%rbp), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movl -0x88(%rbp), %ecx
shll $0x8, %ecx
orl %ecx, %eax
orl -0x84(%rbp), %eax
movl %eax, -0x74(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x1ca98
movl -0x74(%rbp), %edi
callq 0x9510
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl $0x1, -0x4(%rbp)
movl $0x1, -0x224(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x94e0
leaq -0x70(%rbp), %rdi
callq 0x9c98
leaq -0x38(%rbp), %rdi
callq 0x9c98
movl -0x4(%rbp), %eax
addq $0x250, %rsp            # imm = 0x250
popq %rbp
retq
leaq -0x70(%rbp), %rdi
callq 0x9c98
leaq -0x38(%rbp), %rdi
callq 0x9c98
movq -0x48(%rbp), %rdi
callq 0x9af0
nop