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

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

	/* We have no pending requests and no queued reads. */
	D->npending = 0;
	D->readq_head = NULL;

	/* Make the accepted connection non-blocking. */
	if (fcntl(D->sconn, 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->sconn,
	    dropconnection, D)) == NULL) {
		warnp("Cannot create packet write queue");
		goto err1;
	}

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

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

	/* We are no longer waiting for a connection. */
	D->accepting = 0;

	/* Success! */
	return (0);

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

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %esi, 0x54(%rdi)
cmpl $-0x1, %esi
je 0x35fc
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, 0x70(%rdi)
pushq $0x4
popq %rax
movl %esi, %edi
movl %eax, %esi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x2120
cmpl $-0x1, %eax
je 0x361c
movl 0x54(%rbx), %edi
leaq 0x386(%rip), %rsi       # 0x3932
movq %rbx, %rdx
callq 0x7064
movq %rax, 0x58(%rbx)
testq %rax, %rax
je 0x3632
movl 0x54(%rbx), %edi
callq 0x6ce8
movq %rax, 0x60(%rbx)
testq %rax, %rax
je 0x366c
leaq 0x38f(%rip), %rsi       # 0x3968
movq %rax, %rdi
movq %rbx, %rdx
callq 0xa4e1
movq %rax, 0x68(%rbx)
testq %rax, %rax
je 0x3696
andl $0x0, 0x50(%rbx)
xorl %ebx, %ebx
jmp 0x3735
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3656
movq %rax, %rbx
leaq 0x8ed4(%rip), %rdi      # 0xc4e4
xorl %eax, %eax
callq 0x9d39
andl $0x0, (%rbx)
jmp 0x3664
callq 0x20a0
cmpl $0x0, (%rax)
je 0x368d
movq %rax, %r14
leaq 0x8ecf(%rip), %rdi      # 0xc4ff
jmp 0x3646
callq 0x20a0
cmpl $0x0, (%rax)
je 0x36b7
movq %rax, %r14
leaq 0x8edd(%rip), %rdi      # 0xc523
xorl %eax, %eax
callq 0x9d39
andl $0x0, (%r14)
jmp 0x36f7
leaq 0x8e87(%rip), %rdi      # 0xc4e4
xorl %eax, %eax
callq 0x9ec8
pushq $-0x1
popq %rbx
jmp 0x3735
callq 0x20a0
cmpl $0x0, (%rax)
je 0x36c7
movq %rax, %r14
leaq 0x8ec4(%rip), %rdi      # 0xc544
xorl %eax, %eax
callq 0x9d39
andl $0x0, (%r14)
jmp 0x36ee
leaq 0x8e6b(%rip), %rdi      # 0xc4ff
jmp 0x36be
callq 0x20a0
cmpl $0x0, (%rax)
je 0x36d7
movq %rax, %r14
leaq 0x8eba(%rip), %rdi      # 0xc564
xorl %eax, %eax
callq 0x9d39
andl $0x0, (%r14)
jmp 0x36e5
leaq 0x8e65(%rip), %rdi      # 0xc523
xorl %eax, %eax
callq 0x9ec8
jmp 0x36f7
leaq 0x8e76(%rip), %rdi      # 0xc544
xorl %eax, %eax
callq 0x9ec8
jmp 0x36ee
leaq 0x8e86(%rip), %rdi      # 0xc564
xorl %eax, %eax
callq 0x9ec8
movq 0x60(%rbx), %rdi
callq 0x6ffb
movq 0x58(%rbx), %rdi
callq 0x73b0
movl 0x54(%rbx), %edi
callq 0x2240
pushq $-0x1
popq %rbx
testl %eax, %eax
je 0x3735
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3727
movq %rax, %r14
leaq 0x9d52(%rip), %rdi      # 0xd46c
xorl %eax, %eax
callq 0x9d39
andl $0x0, (%r14)
jmp 0x3735
leaq 0x9d3e(%rip), %rdi      # 0xd46c
xorl %eax, %eax
callq 0x9ec8
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq