// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/s3/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;
	}

	/* 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, 0x1c(%rdi)
cmpl $-0x1, %esi
je 0x35f7
movq %rdi, %rbx
pushq $0x4
popq %rax
movl %esi, %edi
movl %eax, %esi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x2110
cmpl $-0x1, %eax
je 0x3617
movl 0x1c(%rbx), %edi
leaq 0x2b9(%rip), %rsi       # 0x3860
movq %rbx, %rdx
callq 0x64a0
movq %rax, 0x20(%rbx)
testq %rax, %rax
je 0x362d
movl 0x1c(%rbx), %edi
callq 0x6124
movq %rax, 0x28(%rbx)
testq %rax, %rax
je 0x3667
leaq 0x2c2(%rip), %rsi       # 0x3896
movq %rax, %rdi
movq %rbx, %rdx
callq 0xab0d
movq %rax, 0x30(%rbx)
testq %rax, %rax
je 0x3691
andl $0x0, 0x18(%rbx)
xorl %ebx, %ebx
jmp 0x3730
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3651
movq %rax, %rbx
leaq 0xcde1(%rip), %rdi      # 0x103ec
xorl %eax, %eax
callq 0x945d
andl $0x0, (%rbx)
jmp 0x365f
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3688
movq %rax, %r14
leaq 0xcddc(%rip), %rdi      # 0x10407
jmp 0x3641
callq 0x20a0
cmpl $0x0, (%rax)
je 0x36b2
movq %rax, %r14
leaq 0xcdea(%rip), %rdi      # 0x1042b
xorl %eax, %eax
callq 0x945d
andl $0x0, (%r14)
jmp 0x36f2
leaq 0xcd94(%rip), %rdi      # 0x103ec
xorl %eax, %eax
callq 0x95ec
pushq $-0x1
popq %rbx
jmp 0x3730
callq 0x20a0
cmpl $0x0, (%rax)
je 0x36c2
movq %rax, %r14
leaq 0xcdd1(%rip), %rdi      # 0x1044c
xorl %eax, %eax
callq 0x945d
andl $0x0, (%r14)
jmp 0x36e9
leaq 0xcd78(%rip), %rdi      # 0x10407
jmp 0x36b9
callq 0x20a0
cmpl $0x0, (%rax)
je 0x36d2
movq %rax, %r14
leaq 0xcdc7(%rip), %rdi      # 0x1046c
xorl %eax, %eax
callq 0x945d
andl $0x0, (%r14)
jmp 0x36e0
leaq 0xcd72(%rip), %rdi      # 0x1042b
xorl %eax, %eax
callq 0x95ec
jmp 0x36f2
leaq 0xcd83(%rip), %rdi      # 0x1044c
xorl %eax, %eax
callq 0x95ec
jmp 0x36e9
leaq 0xcd93(%rip), %rdi      # 0x1046c
xorl %eax, %eax
callq 0x95ec
movq 0x28(%rbx), %rdi
callq 0x6437
movq 0x20(%rbx), %rdi
callq 0x67ec
movl 0x1c(%rbx), %edi
callq 0x2200
pushq $-0x1
popq %rbx
testl %eax, %eax
je 0x3730
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3722
movq %rax, %r14
leaq 0xcf68(%rip), %rdi      # 0x1067d
xorl %eax, %eax
callq 0x945d
andl $0x0, (%r14)
jmp 0x3730
leaq 0xcf54(%rip), %rdi      # 0x1067d
xorl %eax, %eax
callq 0x95ec
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq