// File: /workspace/github_c_makefile_star2_O2/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 0x483b
testl %eax, %eax
jne 0x3c43
cmpb $0x2f, (%r14)
jne 0x3a94
pushq $0x1
popq %rdi
pushq $0x6e
popq %rsi
callq 0x21c0
testq %rax, %rax
je 0x3c43
movq %rax, %rbx
movw $0x1, (%rax)
movq %r14, %rdi
callq 0x2120
cmpq $0x6c, %rax
jb 0x3b55
leaq 0x3b0a(%rip), %rdi      # 0x7587
movq %r14, %rsi
xorl %eax, %eax
callq 0x4aa8
callq 0x2090
andl $0x0, (%rax)
jmp 0x3c3b
movq %r14, %rdi
callq 0x2300
testq %rax, %rax
je 0x3c43
movq %rax, %rbx
pushq $0x3a
popq %rsi
movq %rax, %rdi
callq 0x2150
testq %rax, %rax
je 0x3bb2
movq %rax, %r12
incq %r12
movb $0x0, (%rax)
cmpb $0x5b, (%rbx)
jne 0x3bbb
movq %rbx, %rdi
callq 0x2120
cmpb $0x5d, -0x1(%rbx,%rax)
jne 0x3c1e
movq %rbx, %r15
incq %r15
movq %r15, %rdi
callq 0x2120
movb $0x0, (%rbx,%rax)
callq 0x2090
movq %rax, %r14
andl $0x0, (%rax)
leaq 0x10(%rsp), %rbp
pushq $0xa
popq %rdx
movq %r12, %rdi
movq %rbp, %rsi
callq 0x2050
movq %rax, %r13
movq (%rbp), %rcx
pushq $0x16
popq %rax
cmpq %r12, %rcx
je 0x3b3c
cmpb $0x0, (%rcx)
jne 0x3b3c
movq $-0x10000, %rax         # imm = 0xFFFF0000
leaq (%rax,%r13), %rcx
cmpq %rax, %rcx
ja 0x3d25
pushq $0x22
popq %rax
movl %eax, (%r14)
leaq 0x38c3(%rip), %rdi      # 0x7409
movq %r12, %rsi
xorl %eax, %eax
callq 0x4aa8
jmp 0x3c37
movq %rbx, %rdi
addq $0x2, %rdi
movq %r14, %rsi
callq 0x20b0
pushq $0x18
popq %rdi
callq 0x2220
testq %rax, %rax
je 0x3c3b
movq %rax, %r15
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, (%r15)
movq %rbx, 0x8(%r15)
movl $0x6e, 0x10(%r15)
pushq $0x10
popq %rdi
callq 0x2220
testq %rax, %rax
je 0x3c58
movq %rax, %r14
movq %r15, (%rax)
andq $0x0, 0x8(%rax)
jmp 0x3c46
leaq 0x37f7(%rip), %rdi      # 0x73b0
jmp 0x3c25
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)
leaq 0x8(%rsp), %r14
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rcx
callq 0x22f0
testl %eax, %eax
je 0x3c62
movl %eax, %edi
callq 0x2140
leaq 0x399f(%rip), %rdi      # 0x75a0
xorl %r14d, %r14d
movq %rbx, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x4aa8
callq 0x2090
andl $0x0, (%rax)
jmp 0x3df9
leaq 0x37b0(%rip), %rdi      # 0x73d5
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4aa8
callq 0x2090
movq %rax, %r14
andl $0x0, (%r14)
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 0x3c3b
pushq $0x8
popq %rdi
xorl %eax, %eax
movq (%r14), %r14
testq %r14, %r14
je 0x3c7c
addq $0x28, %r14
addq $0x8, %rdi
decq %rax
jmp 0x3c67
cmpq $0x1, %rax
je 0x3eae
negq %rax
movabsq $0x1fffffffffffffff, %rcx # imm = 0x1FFFFFFFFFFFFFFF
cmpq %rcx, %rax
jb 0x3ca8
callq 0x2090
movl $0xc, (%rax)
jmp 0x3dec
callq 0x2220
testq %rax, %rax
je 0x3dec
movq %rax, %r14
leaq 0x8(%rsp), %r15
pushq $-0x1
popq %rbp
movq (%r15), %r15
testq %r15, %r15
je 0x3db6
pushq $0x18
popq %rdi
callq 0x2220
movq %rax, 0x8(%r14,%rbp,8)
testq %rax, %rax
je 0x3dde
movq %rax, %r12
movq 0x4(%r15), %rax
movq %rax, (%r12)
movl 0x10(%r15), %r13d
movl %r13d, 0x10(%r12)
movq %r13, %rdi
callq 0x2220
movq %rax, 0x8(%r12)
testq %rax, %rax
je 0x3dc8
movq 0x18(%r15), %rsi
movq %rax, %rdi
movq %r13, %rdx
callq 0x21e0
addq $0x28, %r15
incq %rbp
jmp 0x3cc1
cmpl $0x0, (%r14)
jne 0x3b3f
pushq $0x3a
popq %rsi
movq %r15, %rdi
callq 0x2130
pushq $0x1
popq %rdi
testq %rax, %rax
je 0x3e06
pushq $0x1c
popq %rsi
callq 0x21c0
testq %rax, %rax
je 0x3df6
movq %rax, %r12
rolw $0x8, %r13w
movw $0xa, (%rax)
movw %r13w, 0x2(%rax)
movq %rax, %rdx
addq $0x8, %rdx
pushq $0xa
popq %rdi
movq %r15, %rsi
callq 0x2200
cmpl $0x1, %eax
jne 0x3e82
pushq $0x18
popq %rdi
callq 0x2220
testq %rax, %rax
je 0x3e97
movq %rax, %r15
movabsq $0x10000000a, %rax      # imm = 0x10000000A
movq %rax, (%r15)
movq %r12, 0x8(%r15)
movl $0x1c, 0x10(%r15)
jmp 0x3e65
andq $0x0, 0x8(%r14,%rbp,8)
movq 0x8(%rsp), %rdi
callq 0x2350
jmp 0x3df9
movq %r12, %rdi
callq 0x2040
jmp 0x3dde
movq (%r14,%rbp,8), %rdi
callq 0x4007
decq %rbp
cmpq $-0x1, %rbp
jne 0x3dd2
movq %r14, %rdi
callq 0x2040
movq 0x8(%rsp), %rdi
callq 0x2350
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x2040
jmp 0x3c46
pushq $0x10
popq %rsi
callq 0x21c0
testq %rax, %rax
je 0x3df6
movq %rax, %r12
rolw $0x8, %r13w
movw $0x2, (%rax)
movw %r13w, 0x2(%rax)
movq %rax, %rdx
addq $0x4, %rdx
pushq $0x2
popq %rdi
movq %r15, %rsi
callq 0x2200
cmpl $0x1, %eax
jne 0x3e82
pushq $0x18
popq %rdi
callq 0x2220
testq %rax, %rax
je 0x3e97
movq %rax, %r15
movabsq $0x100000002, %rax      # imm = 0x100000002
movq %rax, (%r15)
movq %r12, 0x8(%r15)
movl $0x10, 0x10(%r15)
pushq $0x10
popq %rdi
callq 0x2220
testq %rax, %rax
je 0x3ea4
movq %rax, %r14
movq %r15, (%rax)
andq $0x0, 0x8(%rax)
jmp 0x3df9
leaq 0x377d(%rip), %rdi      # 0x7606
movq %r15, %rsi
xorl %eax, %eax
callq 0x4aa8
andl $0x0, (%r14)
movq %r12, %rdi
callq 0x2040
jmp 0x3df6
movq %r15, %rdi
callq 0x2040
jmp 0x3e97
leaq 0x3703(%rip), %rdi      # 0x75b8
leaq 0x3532(%rip), %rsi      # 0x73ee
leaq 0x3702(%rip), %rcx      # 0x75c5
pushq $0x63
popq %rdx
callq 0x2160