// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/perf/dispatch.c
// Function: callback_accept
static int
callback_accept(void * cookie, int s)
{
	struct dispatch_state * D = cookie;

	/* We are no longer waiting for a connection to arrive. */
	D->accept_cookie = NULL;

	/* We have a socket. */
	if ((D->s = s) == -1) {
		warnp("Error accepting connection");
		goto err0;
	}

	/* Make the accepted connection non-blocking. */
	if (fcntl(D->s, F_SETFL, O_NONBLOCK) == -1) {
		warnp("Cannot make connection non-blocking");
		goto err1;
	}

	/* Create a buffered writer for the connection. */
	if ((D->writeq = netbuf_write_init(D->s, NULL, NULL)) == NULL) {
		warnp("Cannot create packet write queue");
		goto err1;
	}

	/* Create a buffered reader for the connection. */
	if ((D->readq = netbuf_read_init(D->s)) == NULL) {
		warn0("Cannot create packet read queue");
		goto err2;
	}

	/* Wait for a request to arrive. */
	if ((D->read_cookie = wire_readpacket_wait(D->readq,
	    callback_gotrequests, D)) == NULL) {
		warnp("Error reading request from connection");
		goto err3;
	}

	/* Success! */
	return (0);

err3:
	netbuf_read_free(D->readq);
err2:
	netbuf_write_free(D->writeq);
err1:
	if (close(D->s))
		warnp("close");
err0:
	/* Failure! */
	return (-1);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
andq $0x0, 0x18(%rdi)
movl %esi, (%rdi)
cmpl $-0x1, %esi
je 0x2fae
movq %rdi, %rbx
pushq $0x4
popq %rax
movl %esi, %edi
movl %eax, %esi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x2100
cmpl $-0x1, %eax
je 0x2fce
movl (%rbx), %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x54d4
movq %rax, 0x10(%rbx)
testq %rax, %rax
je 0x2fe4
movl (%rbx), %edi
callq 0x5158
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x301b
leaq 0x23c(%rip), %rsi       # 0x31a8
movq %rax, %rdi
movq %rbx, %rdx
callq 0x90b1
movq %rax, 0x20(%rbx)
xorl %ebp, %ebp
testq %rax, %rax
jne 0x30a8
callq 0x20a0
cmpl $0x0, (%rax)
je 0x304c
movq %rax, %r14
leaq 0x83cb(%rip), %rdi      # 0xb369
xorl %eax, %eax
callq 0x80c9
andl $0x0, (%r14)
jmp 0x305a
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3005
movq %rax, %rbx
leaq 0x8327(%rip), %rdi      # 0xb2e9
xorl %eax, %eax
callq 0x80c9
andl $0x0, (%rbx)
jmp 0x3013
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3033
movq %rax, %r14
leaq 0x8322(%rip), %rdi      # 0xb304
jmp 0x2ff8
callq 0x20a0
cmpl $0x0, (%rax)
je 0x303c
movq %rax, %r14
leaq 0x8330(%rip), %rdi      # 0xb328
xorl %eax, %eax
callq 0x80c9
andl $0x0, (%r14)
jmp 0x306c
leaq 0x82dd(%rip), %rdi      # 0xb2e9
xorl %eax, %eax
callq 0x8258
pushq $-0x1
popq %rbp
jmp 0x30a8
leaq 0x8327(%rip), %rdi      # 0xb349
xorl %eax, %eax
callq 0x8258
callq 0x20a0
andl $0x0, (%rax)
jmp 0x3063
leaq 0x82ca(%rip), %rdi      # 0xb304
jmp 0x3043
leaq 0x82e5(%rip), %rdi      # 0xb328
xorl %eax, %eax
callq 0x8258
jmp 0x306c
leaq 0x8316(%rip), %rdi      # 0xb369
xorl %eax, %eax
callq 0x8258
movq 0x8(%rbx), %rdi
callq 0x546b
movq 0x10(%rbx), %rdi
callq 0x5820
movl (%rbx), %edi
callq 0x21d0
pushq $-0x1
popq %rbp
testl %eax, %eax
je 0x30a8
callq 0x20a0
cmpl $0x0, (%rax)
je 0x309a
movq %rax, %rbx
leaq 0x8ccc(%rip), %rdi      # 0xbd5a
xorl %eax, %eax
callq 0x80c9
andl $0x0, (%rbx)
jmp 0x30a8
leaq 0x8cb9(%rip), %rdi      # 0xbd5a
xorl %eax, %eax
callq 0x8258
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq