// File: /workspace/github_c_makefile_star2_O1/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 0x3bef
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 0x3c12
movl 0x54(%rbx), %edi
leaq 0x3ad(%rip), %rsi       # 0x3f49
movq %rbx, %rdx
callq 0x7b18
movq %rax, 0x58(%rbx)
testq %rax, %rax
je 0x3c28
movl 0x54(%rbx), %edi
callq 0x7784
movq %rax, 0x60(%rbx)
testq %rax, %rax
je 0x3c6b
leaq 0x3b9(%rip), %rsi       # 0x3f82
movq %rax, %rdi
movq %rbx, %rdx
callq 0xb391
movq %rax, 0x68(%rbx)
testq %rax, %rax
je 0x3c98
movl $0x0, 0x50(%rbx)
xorl %ebx, %ebx
jmp 0x3d3f
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3c53
movq %rax, %rbx
leaq 0x9925(%rip), %rdi      # 0xd528
xorl %eax, %eax
callq 0xac18
movl $0x0, (%rbx)
jmp 0x3c61
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3c8f
movq %rax, %r14
leaq 0x991d(%rip), %rdi      # 0xd543
jmp 0x3c40
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3cbc
movq %rax, %r14
leaq 0x9927(%rip), %rdi      # 0xd567
xorl %eax, %eax
callq 0xac18
movl $0x0, (%r14)
jmp 0x3cfc
leaq 0x98ce(%rip), %rdi      # 0xd528
xorl %eax, %eax
callq 0xad37
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x3d3f
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3ccc
movq %rax, %r14
leaq 0x9909(%rip), %rdi      # 0xd588
xorl %eax, %eax
callq 0xac18
movl $0x0, (%r14)
jmp 0x3cf3
leaq 0x98ad(%rip), %rdi      # 0xd543
jmp 0x3cc3
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3cdc
movq %rax, %r14
leaq 0x98fc(%rip), %rdi      # 0xd5a8
xorl %eax, %eax
callq 0xac18
movl $0x0, (%r14)
jmp 0x3cea
leaq 0x98a4(%rip), %rdi      # 0xd567
xorl %eax, %eax
callq 0xad37
jmp 0x3cfc
leaq 0x98b5(%rip), %rdi      # 0xd588
xorl %eax, %eax
callq 0xad37
jmp 0x3cf3
leaq 0x98c5(%rip), %rdi      # 0xd5a8
xorl %eax, %eax
callq 0xad37
movq 0x60(%rbx), %rdi
callq 0x7aac
movq 0x58(%rbx), %rdi
callq 0x7e97
movl 0x54(%rbx), %edi
callq 0x2240
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %eax, %eax
je 0x3d3f
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3d31
movq %rax, %r14
leaq 0xa77b(%rip), %rdi      # 0xe49c
xorl %eax, %eax
callq 0xac18
movl $0x0, (%r14)
jmp 0x3d3f
leaq 0xa764(%rip), %rdi      # 0xe49c
xorl %eax, %eax
callq 0xad37
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq