// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/liball/../libcperciva/util/sock.c
// Function: sock_resolve_host
static struct sock_addr **
sock_resolve_host(const char * addr, const char * ports)
{
	struct addrinfo hints;
	struct addrinfo * res;
	struct addrinfo * r;
	struct sock_addr ** sas;
	size_t n;
	int error;

	/* Create hints structure. */
	memset(&hints, 0, sizeof(hints));
	hints.ai_family = AF_UNSPEC;
	hints.ai_socktype = SOCK_STREAM;
	hints.ai_protocol = IPPROTO_TCP;

	/* Perform DNS lookup. */
	if ((error = getaddrinfo(addr, ports, &hints, &res)) != 0) {
		warn0("Error looking up %s: %s", addr, gai_strerror(error));
		goto err0;
	}

	/* Count addresses returned. */
	for (n = 0, r = res; r != NULL; r = r->ai_next)
		n++;

	/* Sanity check. */
	assert(n < SIZE_MAX);

	/* Allocate our response array. */
	if (IMALLOC(sas, n + 1, struct sock_addr *))
		goto err1;

	/* Create address structures. */
	for (n = 0, r = res; r != NULL; n++, r = r->ai_next) {
		/* Allocate a structure. */
		if ((sas[n] = malloc(sizeof(struct sock_addr))) == NULL)
			goto err2;

		/* Copy in the address metadata. */
		sas[n]->ai_family = r->ai_family;
		sas[n]->ai_socktype = r->ai_socktype;
		sas[n]->namelen = r->ai_addrlen;

		/* Duplicate the address. */
		if ((sas[n]->name = malloc(sas[n]->namelen)) == NULL)
			goto err3;
		memcpy(sas[n]->name, r->ai_addr, sas[n]->namelen);
	}

	/* Terminate array with a NULL. */
	sas[n] = NULL;

	/* Free the linked list of addresses returned by getaddrinfo. */
	freeaddrinfo(res);

	/* Success! */
	return (sas);

err3:
	free(sas[n]);
err2:
	for (; n > 0; n--)
		sock_addr_free(sas[n - 1]);
	free(sas);
err1:
	freeaddrinfo(res);
err0:
	/* Failure! */
	return (NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
leaq -0x48(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x2190
movl $0x0, -0x44(%rbp)
movl $0x1, -0x40(%rbp)
movl $0x6, -0x3c(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x48(%rbp), %rdx
leaq -0x50(%rbp), %rcx
callq 0x2310
movl %eax, -0x6c(%rbp)
cmpl $0x0, %eax
je 0x4dac
jmp 0x4d77
movq -0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
movl -0x6c(%rbp), %edi
callq 0x2160
movq -0x78(%rbp), %rsi
movq %rax, %rdx
leaq 0x5856(%rip), %rdi      # 0xa5eb
movb $0x0, %al
callq 0x6810
callq 0x20a0
movl $0x0, (%rax)
jmp 0x4f9c
movq $0x0, -0x68(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x4ddd
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
movq -0x58(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0x4dbc
cmpq $-0x1, -0x68(%rbp)
jae 0x4de6
jmp 0x4e05
leaq 0x5816(%rip), %rdi      # 0xa603
leaq 0x5645(%rip), %rsi      # 0xa439
movl $0x63, %edx
leaq 0x5810(%rip), %rcx      # 0xa610
callq 0x2180
movq -0x68(%rbp), %rdi
addq $0x1, %rdi
movl $0x8, %esi
callq 0x5c60
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
jne 0x4e34
movq -0x68(%rbp), %rax
addq $0x1, %rax
cmpq $0x0, %rax
jbe 0x4e34
jmp 0x4f93
movq $0x0, -0x68(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x4f2a
movl $0x18, %edi
callq 0x2240
movq -0x60(%rbp), %rcx
movq -0x68(%rbp), %rdx
movq %rax, (%rcx,%rdx,8)
cmpq $0x0, %rax
jne 0x4e70
jmp 0x4f5e
movq -0x58(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x60(%rbp), %rax
movq -0x68(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movl %ecx, (%rax)
movq -0x58(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x60(%rbp), %rax
movq -0x68(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movl %ecx, 0x4(%rax)
movq -0x58(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x60(%rbp), %rax
movq -0x68(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movl %ecx, 0x10(%rax)
movq -0x60(%rbp), %rax
movq -0x68(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x10(%rax), %eax
movl %eax, %edi
callq 0x2240
movq -0x60(%rbp), %rcx
movq -0x68(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movq %rax, 0x8(%rcx)
cmpq $0x0, %rax
jne 0x4edf
jmp 0x4f4d
movq -0x60(%rbp), %rax
movq -0x68(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rdi
movq -0x58(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x60(%rbp), %rax
movq -0x68(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x10(%rax), %eax
movl %eax, %edx
callq 0x2200
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
movq -0x58(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0x4e44
movq -0x60(%rbp), %rax
movq -0x68(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movq -0x50(%rbp), %rdi
callq 0x2370
movq -0x60(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x4fa4
movq -0x60(%rbp), %rax
movq -0x68(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2040
jmp 0x4f60
cmpq $0x0, -0x68(%rbp)
jbe 0x4f8a
movq -0x60(%rbp), %rax
movq -0x68(%rbp), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rdi
callq 0x5540
movq -0x68(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x4f60
movq -0x60(%rbp), %rdi
callq 0x2040
movq -0x50(%rbp), %rdi
callq 0x2370
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)