// File: /workspace/github_c_makefile_star2_O0/wahern[P]cqueues/src/dns.c
// Function: res_new
static int res_new(lua_State *L) {
	struct resolver *R = res_prep(L);
	struct dns_resolv_conf *resconf = resconf_test(L, 1);
	struct dns_hosts *hosts = hosts_test(L, 2);
	struct dns_hints *hints = hints_test(L, 3);
	int error;

	if (resconf)
		dns_resconf_acquire(resconf);
	if (hosts)
		dns_hosts_acquire(hosts);
	if (hints)
		dns_hints_acquire(hints);

	if (!resconf && !(resconf = dns_resconf_local(&error)))
		goto error;

	if (!hosts) {
		if (resconf->options.recurse)
			hosts = dns_hosts_open(&error);
		else
			hosts = dns_hosts_local(&error);

		if (!hosts)
			goto error;
	}

	if (!hints) {
		if (resconf->options.recurse)
			hints = dns_hints_root(resconf, &error);
		else
			hints = dns_hints_local(resconf, &error);

		if (!hints)
			goto error;
	}

	if (!(R->res = dns_res_open(resconf, hosts, hints, NULL, dns_opts(.closefd = { R, &res_closefd }), &error)))
		goto error;

	dns_resconf_close(resconf);
	dns_hosts_close(hosts);
	dns_hints_close(hints);

	return 1;
error:
	dns_resconf_close(resconf);
	dns_hosts_close(hosts);
	dns_hints_close(hints);

	lua_pushnil(L);
	lua_pushinteger(L, error);

	return 2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2b7b0
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x2a0b0
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movl $0x2, %esi
callq 0x2a690
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
movl $0x3, %esi
callq 0x2ae50
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x2b59f
movq -0x20(%rbp), %rdi
callq 0xfb90
cmpq $0x0, -0x28(%rbp)
je 0x2b5af
movq -0x28(%rbp), %rdi
callq 0xfb70
cmpq $0x0, -0x30(%rbp)
je 0x2b5bf
movq -0x30(%rbp), %rdi
callq 0xf7b0
cmpq $0x0, -0x20(%rbp)
jne 0x2b5de
leaq -0x34(%rbp), %rdi
callq 0xf310
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0x2b5de
jmp 0x2b6c9
cmpq $0x0, -0x28(%rbp)
jne 0x2b61c
movq -0x20(%rbp), %rax
testb $0x1, 0x5c1(%rax)
je 0x2b601
leaq -0x34(%rbp), %rdi
callq 0xf810
movq %rax, -0x28(%rbp)
jmp 0x2b60e
leaq -0x34(%rbp), %rdi
callq 0x10360
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x2b61a
jmp 0x2b6c9
jmp 0x2b61c
cmpq $0x0, -0x30(%rbp)
jne 0x2b65f
movq -0x20(%rbp), %rax
testb $0x1, 0x5c1(%rax)
je 0x2b643
movq -0x20(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0xf240
movq %rax, -0x30(%rbp)
jmp 0x2b654
movq -0x20(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0xf260
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x2b65d
jmp 0x2b6c9
jmp 0x2b65f
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x18(%rbp), %rax
movq %rax, -0x50(%rbp)
leaq 0x1b6(%rip), %rax       # 0x2b830
movq %rax, -0x48(%rbp)
movl $0x0, -0x40(%rbp)
xorl %eax, %eax
movl %eax, %ecx
leaq -0x50(%rbp), %r8
leaq -0x34(%rbp), %r9
callq 0xf9f0
movq -0x18(%rbp), %rcx
movq %rax, (%rcx)
cmpq $0x0, %rax
jne 0x2b6a5
jmp 0x2b6c9
movq -0x20(%rbp), %rdi
callq 0xfff0
movq -0x28(%rbp), %rdi
callq 0x108f0
movq -0x30(%rbp), %rdi
callq 0xfc90
movl $0x1, -0x4(%rbp)
jmp 0x2b701
movq -0x20(%rbp), %rdi
callq 0xfff0
movq -0x28(%rbp), %rdi
callq 0x108f0
movq -0x30(%rbp), %rdi
callq 0xfc90
movq -0x10(%rbp), %rdi
callq 0xfa10
movq -0x10(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0xf9a0
movl $0x2, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)