// File: /workspace/github_c_makefile_star2_O0/wahern[P]cqueues/src/lib/socket.c
// Function: so_open
struct socket *(so_open)(const char *host, const char *port, int qtype, int domain, int type, const struct so_options *opts, int *error_) {
	_Bool isnumeric = sa_isnumeric(host);
	struct dns_resolver *res = NULL;
	struct addrinfo hints;
	struct socket *so;
	int error;

	if (!(so = so_make(opts, &error)))
		goto error;

	/*
	 * Copy host name as TLS server host name.
	 *
	 * NOTE: All the TLS RFCs (from RFC 3546 to RFC 6066)
	 * declare
	 *
	 *      Literal IPv4 and IPv6 addresses are not permitted in
	 *      "HostName".
	 *
	 * If the caller wants to send the IP address as the TLS
	 * server host name, they can set .tls_hostname explicitly.
	 */
	if (so->opts.tls_sendname == SO_OPTS_TLS_HOSTNAME && !isnumeric) {
		if (!(so->opts.tls_sendname = strdup(host)))
			goto syerr;
	}

	memset(&hints, 0, sizeof hints);

	hints.ai_flags    = AI_CANONNAME;
	hints.ai_family   = domain;
	hints.ai_socktype = type;

	if (isnumeric) {
		hints.ai_flags |= AI_NUMERICHOST;
	} else {
		struct dns_options *opts = dns_opts();

		opts->closefd.arg = so->opts.fd_close.arg;
		opts->closefd.cb = so->opts.fd_close.cb;

		if (!(res = dns_res_stub(opts, &error)))
			goto error;
	}

	if (!(so->res = dns_ai_open(host, port, qtype, &hints, res, &error)))
		goto error;

	so->todo = SO_S_GETADDR | SO_S_SOCKET | SO_S_BIND;

	dns_res_close(res);

	return so;
syerr:
	error = so_syerr();
error:
	dns_res_close(res);

	so_close(so);

	*error_ = error;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2d2e0
andb $0x1, %al
movb %al, -0x31(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x30(%rbp), %rdi
leaq -0x7c(%rbp), %rsi
callq 0x2d330
movq %rax, -0x78(%rbp)
cmpq $0x0, %rax
jne 0x2d187
jmp 0x2d2a9
movq -0x78(%rbp), %rax
movl $0x1, %ecx
cmpq %rcx, 0x40(%rax)
jne 0x2d1ba
testb $0x1, -0x31(%rbp)
jne 0x2d1ba
movq -0x10(%rbp), %rdi
callq 0x10a90
movq -0x78(%rbp), %rcx
movq %rax, 0x40(%rcx)
cmpq $0x0, %rax
jne 0x2d1b8
jmp 0x2d29f
jmp 0x2d1ba
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0xf7d0
movl $0x2, -0x70(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x68(%rbp)
testb $0x1, -0x31(%rbp)
je 0x2d1ee
movl -0x70(%rbp), %eax
orl $0x4, %eax
movl %eax, -0x70(%rbp)
jmp 0x2d252
leaq -0xa0(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0xf7d0
leaq -0xa0(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x78(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x88(%rbp), %rax
movq %rcx, (%rax)
movq -0x78(%rbp), %rax
movq 0x30(%rax), %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x88(%rbp), %rdi
leaq -0x7c(%rbp), %rsi
callq 0xf8c0
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
jne 0x2d250
jmp 0x2d2a9
jmp 0x2d252
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movq -0x40(%rbp), %r8
leaq -0x70(%rbp), %rcx
leaq -0x7c(%rbp), %r9
callq 0xfe10
movq -0x78(%rbp), %rcx
movq %rax, 0x50(%rcx)
cmpq $0x0, %rax
jne 0x2d27e
jmp 0x2d2a9
movq -0x78(%rbp), %rax
movl $0xe, 0xb8(%rax)
movq -0x40(%rbp), %rdi
callq 0xfef0
movq -0x78(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2d2cc
callq 0xf0a0
movl (%rax), %eax
movl %eax, -0x7c(%rbp)
movq -0x40(%rbp), %rdi
callq 0xfef0
movq -0x78(%rbp), %rdi
callq 0xf470
movl -0x7c(%rbp), %ecx
movq 0x10(%rbp), %rax
movl %ecx, (%rax)
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)