// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movl -0x14(%rbp), %eax
movq -0x20(%rbp), %rcx
movl %eax, 0x54(%rcx)
cmpl $-0x1, %eax
jne 0x4002
jmp 0x3fc8
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3fed
leaq 0xe6ef(%rip), %rdi      # 0x126c8
movb $0x0, %al
callq 0xf070
callq 0x20a0
movl $0x0, (%rax)
jmp 0x3ffb
leaq 0xe6d4(%rip), %rdi      # 0x126c8
movb $0x0, %al
callq 0xf2c0
jmp 0x3ffd
jmp 0x4203
movq -0x20(%rbp), %rax
movq $0x0, 0x70(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x78(%rax)
movq -0x20(%rbp), %rax
movl 0x54(%rax), %edi
movl $0x4, %esi
movl $0x800, %edx            # imm = 0x800
movb $0x0, %al
callq 0x2130
cmpl $-0x1, %eax
jne 0x4073
jmp 0x4039
callq 0x20a0
cmpl $0x0, (%rax)
je 0x405e
leaq 0xe699(%rip), %rdi      # 0x126e3
movb $0x0, %al
callq 0xf070
callq 0x20a0
movl $0x0, (%rax)
jmp 0x406c
leaq 0xe67e(%rip), %rdi      # 0x126e3
movb $0x0, %al
callq 0xf2c0
jmp 0x406e
jmp 0x41b7
movq -0x20(%rbp), %rax
movl 0x54(%rax), %edi
movq -0x20(%rbp), %rdx
leaq 0x45b(%rip), %rsi       # 0x44e0
callq 0xa2a0
movq -0x20(%rbp), %rcx
movq %rax, 0x58(%rcx)
cmpq $0x0, %rax
jne 0x40d4
jmp 0x409a
callq 0x20a0
cmpl $0x0, (%rax)
je 0x40bf
leaq 0xe65c(%rip), %rdi      # 0x12707
movb $0x0, %al
callq 0xf070
callq 0x20a0
movl $0x0, (%rax)
jmp 0x40cd
leaq 0xe641(%rip), %rdi      # 0x12707
movb $0x0, %al
callq 0xf2c0
jmp 0x40cf
jmp 0x41b7
movq -0x20(%rbp), %rax
movl 0x54(%rax), %edi
callq 0x9bc0
movq -0x20(%rbp), %rcx
movq %rax, 0x60(%rcx)
cmpq $0x0, %rax
jne 0x412a
jmp 0x40f0
callq 0x20a0
cmpl $0x0, (%rax)
je 0x4115
leaq 0xe627(%rip), %rdi      # 0x12728
movb $0x0, %al
callq 0xf070
callq 0x20a0
movl $0x0, (%rax)
jmp 0x4123
leaq 0xe60c(%rip), %rdi      # 0x12728
movb $0x0, %al
callq 0xf2c0
jmp 0x4125
jmp 0x41aa
movq -0x20(%rbp), %rax
movq 0x60(%rax), %rdi
movq -0x20(%rbp), %rdx
leaq 0x433(%rip), %rsi       # 0x4570
callq 0xff90
movq -0x20(%rbp), %rcx
movq %rax, 0x68(%rcx)
cmpq $0x0, %rax
jne 0x4189
jmp 0x4152
callq 0x20a0
cmpl $0x0, (%rax)
je 0x4177
leaq 0xe5e5(%rip), %rdi      # 0x12748
movb $0x0, %al
callq 0xf070
callq 0x20a0
movl $0x0, (%rax)
jmp 0x4185
leaq 0xe5ca(%rip), %rdi      # 0x12748
movb $0x0, %al
callq 0xf2c0
jmp 0x4187
jmp 0x419d
movq -0x20(%rbp), %rax
movl $0x0, 0x50(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x420a
movq -0x20(%rbp), %rax
movq 0x60(%rax), %rdi
callq 0xa210
movq -0x20(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0xa8e0
movq -0x20(%rbp), %rax
movl 0x54(%rax), %edi
callq 0x2260
cmpl $0x0, %eax
je 0x4201
jmp 0x41ca
callq 0x20a0
cmpl $0x0, (%rax)
je 0x41ef
leaq 0xf449(%rip), %rdi      # 0x13624
movb $0x0, %al
callq 0xf070
callq 0x20a0
movl $0x0, (%rax)
jmp 0x41fd
leaq 0xf42e(%rip), %rdi      # 0x13624
movb $0x0, %al
callq 0xf2c0
jmp 0x41ff
jmp 0x4201
jmp 0x4203
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)