// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/liball/../libcperciva/util/sock.c
// Function: sock_resolve
struct sock_addr **
sock_resolve(const char * addr)
{
	struct sock_addr ** res;
	char * s;
	char * ports;
	char * ips;
	long p;

	/* Check syntax. */
	if (sock_addr_validate(addr))
		goto err0;

	/* If the address starts with '/', it's a Unix domain socket. */
	if (addr[0] == '/') {
		res = sock_resolve_unix(addr);
		goto done0;
	}

	/* Copy the address so that we can mangle it. */
	if ((s = strdup(addr)) == NULL)
		goto err0;

	/* The address should end with :port.  Look for the last ':'. */
	if ((ports = strrchr(s, ':')) == NULL) {
		warn0("Address must contain port number: %s", s);
		goto err1;
	}
	*ports++ = '\0';

	/* If the address doesn't start with '[', it's a host name. */
	if (s[0] != '[') {
		res = sock_resolve_host(s, ports);
		goto done1;
	}

	/* The address (sans :port) should end with ']'. */
	if (s[strlen(s) - 1] != ']') {
		warn0("Invalid [IP address]: %s", s);
		goto err1;
	}

	/* Extract the IP address string. */
	ips = &s[1];
	ips[strlen(ips) - 1] = '\0';

	/* Parse the port number in base 10, no trailing characters. */
	if (PARSENUM_EX(&p, ports, 1, 65535, 10, 0)) {
		warn0("Invalid port number: %s", ports);
		goto err1;
	}

	/* If the IP address contains ':', it's IPv6; otherwise, IPv4. */
	if (strchr(ips, ':') != NULL)
		res = sock_resolve_ipv6(ips, (in_port_t)p);
	else
		res = sock_resolve_ipv4(ips, (in_port_t)p);

done1:
	/* Free string allocated by strdup. */
	free(s);
done0:
	/* Return result from sock_resolve_foo. */
	return (res);

err1:
	free(s);
err0:
	/* Failure! */
	return (NULL);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %r14
callq 0x4e0a
testl %eax, %eax
jne 0x404e
cmpb $0x2f, (%r14)
jne 0x3ebf
movl $0x1, %edi
movl $0x6e, %esi
callq 0x21c0
testq %rax, %rax
je 0x404e
movq %rax, %rbx
movw $0x1, (%rax)
movq %r14, %rdi
callq 0x2120
cmpq $0x6c, %rax
jb 0x3f57
leaq 0x36ca(%rip), %rdi      # 0x756f
movq %r14, %rsi
xorl %eax, %eax
callq 0x500f
callq 0x2090
movl $0x0, (%rax)
jmp 0x4046
movq %r14, %rdi
callq 0x2300
testq %rax, %rax
je 0x404e
movq %rax, %rbx
movq %rax, %rdi
movl $0x3a, %esi
callq 0x2150
testq %rax, %rax
je 0x3fbb
movq %rax, %r14
incq %r14
movb $0x0, (%rax)
cmpb $0x5b, (%rbx)
jne 0x3fc4
movq %rbx, %rdi
callq 0x2120
cmpb $0x5d, -0x1(%rbx,%rax)
jne 0x4025
movq %rbx, %r15
incq %r15
movq %r15, %rdi
callq 0x2120
movb $0x0, (%rbx,%rax)
callq 0x2090
movq %rax, %r12
movl $0x0, (%rax)
movq %r14, %rdi
callq 0x41da
cmpl $0x0, (%r12)
je 0x40b0
leaq 0x34a9(%rip), %rdi      # 0x73f1
movq %r14, %rsi
xorl %eax, %eax
callq 0x500f
jmp 0x403e
movq %rbx, %rdi
addq $0x2, %rdi
movq %r14, %rsi
callq 0x20b0
movl $0x18, %edi
callq 0x2220
testq %rax, %rax
je 0x4046
movq %rax, %r15
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, (%r15)
movq %rbx, 0x8(%r15)
movl $0x6e, 0x10(%r15)
movl $0x10, %edi
callq 0x2220
testq %rax, %rax
je 0x4063
movq %rax, %r14
movq %r15, (%rax)
movq $0x0, 0x8(%rax)
jmp 0x4051
leaq 0x33d6(%rip), %rdi      # 0x7398
jmp 0x402c
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x10(%rdx)
movaps %xmm0, 0x20(%rdx)
movabsq $0x600000001, %rax      # imm = 0x600000001
movq %rax, 0x8(%rdx)
movq %rsp, %rcx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x22f0
testl %eax, %eax
je 0x406d
movl %eax, %edi
callq 0x2140
leaq 0x3583(%rip), %rdi      # 0x7588
xorl %r14d, %r14d
movq %rbx, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x500f
callq 0x2090
movl $0x0, (%rax)
jmp 0x41ae
leaq 0x3391(%rip), %rdi      # 0x73bd
movq %rbx, %rsi
xorl %eax, %eax
callq 0x500f
callq 0x2090
movq %rax, %r12
movl $0x0, (%r12)
movq %rbx, %rdi
callq 0x2040
xorl %r14d, %r14d
movq %r14, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
callq 0x2040
jmp 0x4046
movq (%rsp), %r15
xorl %eax, %eax
testq %r15, %r15
je 0x4087
movq %r15, %rcx
incq %rax
movq 0x28(%rcx), %rcx
testq %rcx, %rcx
jne 0x407b
cmpq $-0x1, %rax
je 0x41bb
movabsq $0x1fffffffffffffff, %rcx # imm = 0x1FFFFFFFFFFFFFFF
cmpq %rcx, %rax
jb 0x40da
callq 0x2090
movl $0xc, (%rax)
xorl %r14d, %r14d
jmp 0x40ea
movq %rax, %r13
movq %r15, %rdi
movl $0x3a, %esi
callq 0x2130
movzwl %r13w, %esi
movq %r15, %rdi
testq %rax, %rax
je 0x4174
callq 0x425b
jmp 0x4179
leaq 0x8(,%rax,8), %rdi
callq 0x2220
movq %rax, %r14
testq %r14, %r14
je 0x41a2
testq %r15, %r15
movq %r15, 0x8(%rsp)
je 0x415e
xorl %ebp, %ebp
movl $0x18, %edi
callq 0x2220
movq %rax, (%r14,%rbp,8)
testq %rax, %rax
je 0x4186
movq %rax, %r12
movl 0x4(%r15), %eax
movl %eax, (%r12)
movl 0x8(%r15), %eax
movl %eax, 0x4(%r12)
movl 0x10(%r15), %r13d
movl %r13d, 0x10(%r12)
movq %r13, %rdi
callq 0x2220
movq %rax, 0x8(%r12)
testq %rax, %rax
je 0x417e
movq 0x18(%r15), %rsi
movq %rax, %rdi
movq %r13, %rdx
callq 0x21e0
incq %rbp
movq 0x28(%r15), %r15
testq %r15, %r15
jne 0x40ff
jmp 0x4160
xorl %ebp, %ebp
movq $0x0, (%r14,%rbp,8)
movq 0x8(%rsp), %rdi
callq 0x2350
jmp 0x41ae
callq 0x4321
movq %rax, %r14
jmp 0x41ae
movq %r12, %rdi
callq 0x2040
testq %rbp, %rbp
je 0x419a
movq -0x8(%r14,%rbp,8), %rdi
callq 0x4543
decq %rbp
jne 0x418b
movq %r14, %rdi
callq 0x2040
movq (%rsp), %rdi
callq 0x2350
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x2040
jmp 0x4051
leaq 0x33de(%rip), %rdi      # 0x75a0
leaq 0x320d(%rip), %rsi      # 0x73d6
leaq 0x33dd(%rip), %rcx      # 0x75ad
movl $0x63, %edx
callq 0x2160