// File: /workspace/github_c_makefile_star2_O3/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
movq $0x0, 0x18(%rdi)
movl %esi, (%rdi)
cmpl $-0x1, %esi
je 0x351a
movq %rdi, %rbx
movl %esi, %edi
movl $0x4, %esi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x2100
cmpl $-0x1, %eax
je 0x353d
movl (%rbx), %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5ef4
movq %rax, 0x10(%rbx)
testq %rax, %rax
je 0x3553
movl (%rbx), %edi
callq 0x5b5c
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x358f
leaq 0x254(%rip), %rsi       # 0x3729
movq %rax, %rdi
movq %rbx, %rdx
callq 0xa006
movq %rax, 0x20(%rbx)
xorl %ebp, %ebp
testq %rax, %rax
jne 0x3624
callq 0x20a0
cmpl $0x0, (%rax)
je 0x35c3
movq %rax, %r14
leaq 0x9e62(%rip), %rdi      # 0xd369
xorl %eax, %eax
callq 0x8f6c
movl $0x0, (%r14)
jmp 0x35d1
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3577
movq %rax, %rbx
leaq 0x9dbb(%rip), %rdi      # 0xd2e9
xorl %eax, %eax
callq 0x8f6c
movl $0x0, (%rbx)
jmp 0x3585
callq 0x20a0
cmpl $0x0, (%rax)
je 0x35aa
movq %rax, %r14
leaq 0x9db3(%rip), %rdi      # 0xd304
jmp 0x3567
callq 0x20a0
cmpl $0x0, (%rax)
je 0x35b3
movq %rax, %r14
leaq 0x9dc1(%rip), %rdi      # 0xd328
xorl %eax, %eax
callq 0x8f6c
movl $0x0, (%r14)
jmp 0x35e3
leaq 0x9d6b(%rip), %rdi      # 0xd2e9
xorl %eax, %eax
callq 0x908b
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x3624
leaq 0x9db3(%rip), %rdi      # 0xd349
xorl %eax, %eax
callq 0x908b
callq 0x20a0
movl $0x0, (%rax)
jmp 0x35da
leaq 0x9d53(%rip), %rdi      # 0xd304
jmp 0x35ba
leaq 0x9d6e(%rip), %rdi      # 0xd328
xorl %eax, %eax
callq 0x908b
jmp 0x35e3
leaq 0x9d9f(%rip), %rdi      # 0xd369
xorl %eax, %eax
callq 0x908b
movq 0x8(%rbx), %rdi
callq 0x5e8a
movq 0x10(%rbx), %rdi
callq 0x6253
movl (%rbx), %edi
callq 0x21d0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %eax, %eax
je 0x3624
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3616
movq %rax, %rbx
leaq 0xa753(%rip), %rdi      # 0xdd5a
xorl %eax, %eax
callq 0x8f6c
movl $0x0, (%rbx)
jmp 0x3624
leaq 0xa73d(%rip), %rdi      # 0xdd5a
xorl %eax, %eax
callq 0x908b
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq