// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x6440
cmpl $0x0, %eax
je 0x496f
jmp 0x4be2
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
jne 0x498d
movq -0x10(%rbp), %rdi
callq 0x4c00
movq %rax, -0x18(%rbp)
jmp 0x4bcf
movq -0x10(%rbp), %rdi
callq 0x2320
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0x49a5
jmp 0x4be2
movq -0x20(%rbp), %rdi
movl $0x3a, %esi
callq 0x2170
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x49e1
jmp 0x49bf
movq -0x20(%rbp), %rsi
leaq 0x59c6(%rip), %rdi      # 0xa390
movb $0x0, %al
callq 0x6810
callq 0x20a0
movl $0x0, (%rax)
jmp 0x4bd9
movq -0x28(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x28(%rbp)
movb $0x0, (%rax)
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5b, %eax
je 0x4a15
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x4d20
movq %rax, -0x18(%rbp)
jmp 0x4bc6
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rdi
callq 0x2120
movq %rax, %rcx
movq -0x40(%rbp), %rax
subq $0x1, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x5d, %eax
je 0x4a5e
jmp 0x4a3c
movq -0x20(%rbp), %rsi
leaq 0x596e(%rip), %rdi      # 0xa3b5
movb $0x0, %al
callq 0x6810
callq 0x20a0
movl $0x0, (%rax)
jmp 0x4bd9
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rdi
callq 0x2120
movq %rax, %rcx
movq -0x48(%rbp), %rax
subq $0x1, %rcx
movb $0x0, (%rax,%rcx)
callq 0x20a0
movl $0x0, (%rax)
movq $0x1, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jle 0x4ae6
movq 0x953c(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x5908(%rip), %rsi      # 0xa3ce
leaq 0x595f(%rip), %rdx      # 0xa42c
leaq 0x5965(%rip), %rcx      # 0xa439
movl $0x11b, %r8d            # imm = 0x11B
movb $0x0, %al
callq 0x21f0
callq 0x2090
movq $-0x1, -0x38(%rbp)
movb $0x1, %al
testb $0x1, %al
jne 0x4af6
jmp 0x4b37
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rdx
xorl %eax, %eax
movl $0x1, %ecx
cmpq $0x0, %rdx
cmovlel %ecx, %eax
movslq %eax, %rsi
movq -0x38(%rbp), %rdx
xorl %eax, %eax
movl $0xffff, %ecx           # imm = 0xFFFF
cmpq $0x0, %rdx
cmovlel %ecx, %eax
movslq %eax, %rdx
movl $0xa, %ecx
xorl %r8d, %r8d
callq 0x4fc0
movq %rax, -0x38(%rbp)
jmp 0x4b5b
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rcx
movl $0x1, %esi
movl $0xffff, %edx           # imm = 0xFFFF
movl $0xa, %r8d
xorl %r9d, %r9d
callq 0x5080
movq %rax, -0x38(%rbp)
callq 0x20a0
cmpl $0x0, (%rax)
je 0x4b86
jmp 0x4b67
movq -0x28(%rbp), %rsi
leaq 0x58e2(%rip), %rdi      # 0xa454
movb $0x0, %al
callq 0x6810
callq 0x20a0
movl $0x0, (%rax)
jmp 0x4bd9
movq -0x30(%rbp), %rdi
movl $0x3a, %esi
callq 0x2140
cmpq $0x0, %rax
je 0x4bb0
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rax
movzwl %ax, %esi
callq 0x5140
movq %rax, -0x18(%rbp)
jmp 0x4bc4
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rax
movzwl %ax, %esi
callq 0x5270
movq %rax, -0x18(%rbp)
jmp 0x4bc6
movq -0x20(%rbp), %rdi
callq 0x2040
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x4bea
movq -0x20(%rbp), %rdi
callq 0x2040
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)