// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]spiped/liball/../lib/dnsthread/dnsthread.c
// Function: dnsthread_resolveone
int
dnsthread_resolveone(DNSTHREAD T, const char * addr,
    int (* callback)(void *, struct sock_addr **), void * cookie)
{
	int err = 0;
	int rc;

	/* Grab the mutex. */
	if ((rc = pthread_mutex_lock(&T->mtx)) != 0) {
		warn0("pthread_mutex_lock: %s", strerror(rc));
		goto err0;
	}

	/* If the resolver is already busy, fail. */
	if (T->state == THREAD_HASWORK) {
		err = EALREADY;
		goto ealready;
	}

	/* Duplicate the address to be resolved. */
	if ((T->addr = strdup(addr)) == NULL)
		goto err1;

	/* Remember what callback we'll need to do eventually. */
	T->callback = callback;
	T->cookie = cookie;

	/* There is now work for the thread to do. */
	T->state = THREAD_HASWORK;

	/* Wake up the worker thread. */
	if ((rc = pthread_cond_signal(&T->cv)) != 0) {
		warn0("pthread_cond_signal: %s", strerror(rc));
		goto err1;
	}

	/* We want a callback when the worker thread pokes us. */
	if (events_network_register(callback_resolveone, T, T->wakeupsock[1],
	    EVENTS_NETWORK_OP_READ)) {
		warnp("Error registering wakeup listener");
		goto err1;
	}

ealready:
	/* Release the mutex. */
	if ((rc = pthread_mutex_unlock(&T->mtx)) != 0) {
		warn0("pthread_mutex_unlock: %s", strerror(rc));
		goto err0;
	}

	/* If err was set earlier, store the value in errno. */
	if (err)
		errno = err;

	/* Success! */
	return (0);

err1:
	pthread_mutex_unlock(&T->mtx);
err0:
	/* Failure! */
	return (-1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x23a0
movl %eax, -0x30(%rbp)
cmpl $0x0, %eax
je 0x6fbf
jmp 0x6f96
movl -0x30(%rbp), %edi
callq 0x2380
movq %rax, %rsi
leaq 0x287c(%rip), %rdi      # 0x9824
movb $0x0, %al
callq 0x66d0
callq 0x2090
movl $0x0, (%rax)
jmp 0x711c
movq -0x10(%rbp), %rax
cmpl $0x1, 0x60(%rax)
jne 0x6fd5
movl $0x72, -0x2c(%rbp)
jmp 0x70b3
movq -0x18(%rbp), %rdi
callq 0x2370
movq -0x10(%rbp), %rcx
movq %rax, 0x70(%rcx)
cmpq $0x0, %rax
jne 0x6ff1
jmp 0x710f
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x88(%rax)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x90(%rax)
movq -0x10(%rbp), %rax
movl $0x1, 0x60(%rax)
movq -0x10(%rbp), %rdi
addq $0x30, %rdi
callq 0x21e0
movl %eax, -0x30(%rbp)
cmpl $0x0, %eax
je 0x705a
jmp 0x7031
movl -0x30(%rbp), %edi
callq 0x2380
movq %rax, %rsi
leaq 0x2845(%rip), %rdi      # 0x9888
movb $0x0, %al
callq 0x66d0
callq 0x2090
movl $0x0, (%rax)
jmp 0x710f
movq -0x10(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x68(%rax), %edx
leaq 0xc4(%rip), %rdi        # 0x7130
xorl %ecx, %ecx
callq 0x3220
cmpl $0x0, %eax
je 0x70b1
jmp 0x707a
callq 0x2090
cmpl $0x0, (%rax)
je 0x709f
leaq 0x2815(%rip), %rdi      # 0x98a0
movb $0x0, %al
callq 0x6480
callq 0x2090
movl $0x0, (%rax)
jmp 0x70ad
leaq 0x27fa(%rip), %rdi      # 0x98a0
movb $0x0, %al
callq 0x66d0
jmp 0x70af
jmp 0x710f
jmp 0x70b3
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x2250
movl %eax, -0x30(%rbp)
cmpl $0x0, %eax
je 0x70f0
jmp 0x70ca
movl -0x30(%rbp), %edi
callq 0x2380
movq %rax, %rsi
leaq 0x2793(%rip), %rdi      # 0x986f
movb $0x0, %al
callq 0x66d0
callq 0x2090
movl $0x0, (%rax)
jmp 0x711c
cmpl $0x0, -0x2c(%rbp)
je 0x7106
movl -0x2c(%rbp), %eax
movl %eax, -0x34(%rbp)
callq 0x2090
movl -0x34(%rbp), %ecx
movl %ecx, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x7123
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x2250
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)