// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]spiped/liball/../lib/dnsthread/dnsthread.c
// Function: workthread
static void *
workthread(void * cookie)
{
	struct dnsthread_internal * T = cookie;
	char * addr;
	struct sock_addr ** sas;
	int res_errno = 0;
	int rc;
	uint8_t zero = 0;

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

	/* Infinite loop doing work until told to suicide. */
	do {
		/*
		 * Sleep on the condition variable as long as we're in the
		 * SLEEPING state.
		 */
		while (T->state == THREAD_SLEEPING) {
			/* Sleep until we're woken up. */
			if ((rc = pthread_cond_wait(&T->cv, &T->mtx)) != 0) {
				warn0("pthread_cond_wait: %s", strerror(rc));
				exit(1);
			}
		}

		/* If we need to kill ourself, stop looping. */
		if (T->state == THREAD_SUICIDE)
			break;

		/* Grab the work. */
		addr = T->addr;

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

		/* Perform the address resolution. */
		if ((sas = sock_resolve(addr)) == NULL)
			res_errno = errno;

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

		/* Write the answer back. */
		T->sas = sas;
		T->res_errno = res_errno;

		/* Send a completion message. */
		if (noeintr_write(T->wakeupsock[0], &zero, 1) != 1) {
			warnp("Error writing to wakeup socket");
			exit(1);
		}

		/* Return to sleeping, unless we were instructed to die. */
		if (T->state != THREAD_SUICIDE)
			T->state = THREAD_SLEEPING;
	} while (1);

	/* Close the socket pair. */
	if (close(T->wakeupsock[1]))
		warnp("close");
	if (close(T->wakeupsock[0]))
		warnp("close");

	/* Destroy the condition variable. */
	if ((rc = pthread_cond_destroy(&T->cv)) != 0) {
		warn0("pthread_cond_destroy: %s", strerror(rc));
		exit(1);
	}

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

	/* Destroy the mutex. */
	if ((rc = pthread_mutex_destroy(&T->mtx)) != 0) {
		warn0("pthread_mutex_destroy: %s", strerror(rc));
		exit(1);
	}

	/* Free the control structure. */
	free(T);

	/* Successful thread termination. */
	return (NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
movl $0x0, -0x24(%rbp)
movb $0x0, -0x29(%rbp)
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x23a0
movl %eax, -0x28(%rbp)
cmpl $0x0, %eax
je 0x6c34
jmp 0x6c06
movl -0x28(%rbp), %edi
callq 0x2380
movq %rax, %rsi
leaq 0x2c0c(%rip), %rdi      # 0x9824
movb $0x0, %al
callq 0x66d0
callq 0x2090
movl $0x0, (%rax)
movl $0x1, %edi
callq 0x2330
jmp 0x6c36
jmp 0x6c38
movq -0x10(%rbp), %rax
cmpl $0x0, 0x60(%rax)
jne 0x6c91
movq -0x10(%rbp), %rdi
addq $0x30, %rdi
movq -0x10(%rbp), %rsi
addq $0x8, %rsi
callq 0x2100
movl %eax, -0x28(%rbp)
cmpl $0x0, %eax
je 0x6c8f
jmp 0x6c61
movl -0x28(%rbp), %edi
callq 0x2380
movq %rax, %rsi
leaq 0x2c60(%rip), %rdi      # 0x98d3
movb $0x0, %al
callq 0x66d0
callq 0x2090
movl $0x0, (%rax)
movl $0x1, %edi
callq 0x2330
jmp 0x6c38
movq -0x10(%rbp), %rax
cmpl $0x2, 0x60(%rax)
jne 0x6ca0
jmp 0x6deb
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x2250
movl %eax, -0x28(%rbp)
cmpl $0x0, %eax
je 0x6cf1
jmp 0x6cc3
movl -0x28(%rbp), %edi
callq 0x2380
movq %rax, %rsi
leaq 0x2b9a(%rip), %rdi      # 0x986f
movb $0x0, %al
callq 0x66d0
callq 0x2090
movl $0x0, (%rax)
movl $0x1, %edi
callq 0x2330
movq -0x18(%rbp), %rdi
callq 0x4820
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0x6d0e
callq 0x2090
movl (%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x23a0
movl %eax, -0x28(%rbp)
cmpl $0x0, %eax
je 0x6d53
jmp 0x6d25
movl -0x28(%rbp), %edi
callq 0x2380
movq %rax, %rsi
leaq 0x2aed(%rip), %rdi      # 0x9824
movb $0x0, %al
callq 0x66d0
callq 0x2090
movl $0x0, (%rax)
movl $0x1, %edi
callq 0x2330
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x78(%rax)
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x80(%rax)
movq -0x10(%rbp), %rax
movl 0x64(%rax), %edi
leaq -0x29(%rbp), %rsi
movl $0x1, %edx
callq 0x8010
cmpq $0x1, %rax
je 0x6dc8
jmp 0x6d89
callq 0x2090
cmpl $0x0, (%rax)
je 0x6dae
leaq 0x2b4f(%rip), %rdi      # 0x98e9
movb $0x0, %al
callq 0x6480
callq 0x2090
movl $0x0, (%rax)
jmp 0x6dbc
leaq 0x2b34(%rip), %rdi      # 0x98e9
movb $0x0, %al
callq 0x66d0
jmp 0x6dbe
movl $0x1, %edi
callq 0x2330
movq -0x10(%rbp), %rax
cmpl $0x2, 0x60(%rax)
je 0x6ddd
movq -0x10(%rbp), %rax
movl $0x0, 0x60(%rax)
jmp 0x6ddf
movb $0x1, %al
testb $0x1, %al
jne 0x6c36
jmp 0x6deb
movq -0x10(%rbp), %rax
movl 0x68(%rax), %edi
callq 0x21a0
cmpl $0x0, %eax
je 0x6e35
jmp 0x6dfe
callq 0x2090
cmpl $0x0, (%rax)
je 0x6e23
leaq 0x2727(%rip), %rdi      # 0x9536
movb $0x0, %al
callq 0x6480
callq 0x2090
movl $0x0, (%rax)
jmp 0x6e31
leaq 0x270c(%rip), %rdi      # 0x9536
movb $0x0, %al
callq 0x66d0
jmp 0x6e33
jmp 0x6e35
movq -0x10(%rbp), %rax
movl 0x64(%rax), %edi
callq 0x21a0
cmpl $0x0, %eax
je 0x6e7f
jmp 0x6e48
callq 0x2090
cmpl $0x0, (%rax)
je 0x6e6d
leaq 0x26dd(%rip), %rdi      # 0x9536
movb $0x0, %al
callq 0x6480
callq 0x2090
movl $0x0, (%rax)
jmp 0x6e7b
leaq 0x26c2(%rip), %rdi      # 0x9536
movb $0x0, %al
callq 0x66d0
jmp 0x6e7d
jmp 0x6e7f
movq -0x10(%rbp), %rdi
addq $0x30, %rdi
callq 0x22f0
movl %eax, -0x28(%rbp)
cmpl $0x0, %eax
je 0x6ec4
jmp 0x6e96
movl -0x28(%rbp), %edi
callq 0x2380
movq %rax, %rsi
leaq 0x2a60(%rip), %rdi      # 0x9908
movb $0x0, %al
callq 0x66d0
callq 0x2090
movl $0x0, (%rax)
movl $0x1, %edi
callq 0x2330
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x2250
movl %eax, -0x28(%rbp)
cmpl $0x0, %eax
je 0x6f09
jmp 0x6edb
movl -0x28(%rbp), %edi
callq 0x2380
movq %rax, %rsi
leaq 0x2982(%rip), %rdi      # 0x986f
movb $0x0, %al
callq 0x66d0
callq 0x2090
movl $0x0, (%rax)
movl $0x1, %edi
callq 0x2330
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x2150
movl %eax, -0x28(%rbp)
cmpl $0x0, %eax
je 0x6f4e
jmp 0x6f20
movl -0x28(%rbp), %edi
callq 0x2380
movq %rax, %rsi
leaq 0x29ef(%rip), %rdi      # 0x9921
movb $0x0, %al
callq 0x66d0
callq 0x2090
movl $0x0, (%rax)
movl $0x1, %edi
callq 0x2330
movq -0x10(%rbp), %rdi
callq 0x2040
xorl %eax, %eax
addq $0x30, %rsp
popq %rbp
retq
nop