// File: /workspace/github_c_makefile_star2_O3/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 0x3bf2
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, 0x70(%rdi)
movl %esi, %edi
movl $0x4, %esi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x2120
cmpl $-0x1, %eax
je 0x3c15
movl 0x54(%rbx), %edi
leaq 0x3ad(%rip), %rsi       # 0x3f4c
movq %rbx, %rdx
callq 0x7b6c
movq %rax, 0x58(%rbx)
testq %rax, %rax
je 0x3c2b
movl 0x54(%rbx), %edi
callq 0x77d4
movq %rax, 0x60(%rbx)
testq %rax, %rax
je 0x3c6e
leaq 0x3b9(%rip), %rsi       # 0x3f85
movq %rax, %rdi
movq %rbx, %rdx
callq 0xb44a
movq %rax, 0x68(%rbx)
testq %rax, %rax
je 0x3c9b
movl $0x0, 0x50(%rbx)
xorl %ebx, %ebx
jmp 0x3d42
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3c56
movq %rax, %rbx
leaq 0x98a2(%rip), %rdi      # 0xd4a8
xorl %eax, %eax
callq 0xacd8
movl $0x0, (%rbx)
jmp 0x3c64
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3c92
movq %rax, %r14
leaq 0x989a(%rip), %rdi      # 0xd4c3
jmp 0x3c43
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3cbf
movq %rax, %r14
leaq 0x98a4(%rip), %rdi      # 0xd4e7
xorl %eax, %eax
callq 0xacd8
movl $0x0, (%r14)
jmp 0x3cff
leaq 0x984b(%rip), %rdi      # 0xd4a8
xorl %eax, %eax
callq 0xadf7
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x3d42
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3ccf
movq %rax, %r14
leaq 0x9886(%rip), %rdi      # 0xd508
xorl %eax, %eax
callq 0xacd8
movl $0x0, (%r14)
jmp 0x3cf6
leaq 0x982a(%rip), %rdi      # 0xd4c3
jmp 0x3cc6
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3cdf
movq %rax, %r14
leaq 0x9879(%rip), %rdi      # 0xd528
xorl %eax, %eax
callq 0xacd8
movl $0x0, (%r14)
jmp 0x3ced
leaq 0x9821(%rip), %rdi      # 0xd4e7
xorl %eax, %eax
callq 0xadf7
jmp 0x3cff
leaq 0x9832(%rip), %rdi      # 0xd508
xorl %eax, %eax
callq 0xadf7
jmp 0x3cf6
leaq 0x9842(%rip), %rdi      # 0xd528
xorl %eax, %eax
callq 0xadf7
movq 0x60(%rbx), %rdi
callq 0x7b02
movq 0x58(%rbx), %rdi
callq 0x7ecb
movl 0x54(%rbx), %edi
callq 0x2240
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %eax, %eax
je 0x3d42
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3d34
movq %rax, %r14
leaq 0xa708(%rip), %rdi      # 0xe42c
xorl %eax, %eax
callq 0xacd8
movl $0x0, (%r14)
jmp 0x3d42
leaq 0xa6f1(%rip), %rdi      # 0xe42c
xorl %eax, %eax
callq 0xadf7
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq