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

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

	/* Make the accepted connection non-blocking. */
	if (fcntl(D->s, 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->s, 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->s)) == NULL) {
		warn0("Cannot create packet read queue");
		goto err2;
	}

	/* Start listening for packets. */
	if (readreqs(D))
		goto err3;

	/* Success! */
	return (0);

err3:
	netbuf_read_free(D->readq);
err2:
	netbuf_write_free(D->writeq);
err1:
	if (close(D->s))
		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, 0x4(%rcx)
cmpl $-0x1, %eax
jne 0x4122
jmp 0x40e8
callq 0x20a0
cmpl $0x0, (%rax)
je 0x410d
leaq 0x1a82f(%rip), %rdi     # 0x1e928
movb $0x0, %al
callq 0x180a0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x411b
leaq 0x1a814(%rip), %rdi     # 0x1e928
movb $0x0, %al
callq 0x182f0
jmp 0x411d
jmp 0x428f
movq -0x20(%rbp), %rax
movl 0x4(%rax), %edi
movl $0x4, %esi
movl $0x800, %edx            # imm = 0x800
movb $0x0, %al
callq 0x2120
cmpl $-0x1, %eax
jne 0x417b
jmp 0x4141
callq 0x20a0
cmpl $0x0, (%rax)
je 0x4166
leaq 0x1a7f1(%rip), %rdi     # 0x1e943
movb $0x0, %al
callq 0x180a0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x4174
leaq 0x1a7d6(%rip), %rdi     # 0x1e943
movb $0x0, %al
callq 0x182f0
jmp 0x4176
jmp 0x4243
movq -0x20(%rbp), %rax
movl 0x4(%rax), %edi
movq -0x20(%rbp), %rdx
leaq 0xe83(%rip), %rsi       # 0x5010
callq 0x13110
movq -0x20(%rbp), %rcx
movq %rax, 0x10(%rcx)
cmpq $0x0, %rax
jne 0x41d9
jmp 0x41a2
callq 0x20a0
cmpl $0x0, (%rax)
je 0x41c7
leaq 0x1a7b4(%rip), %rdi     # 0x1e967
movb $0x0, %al
callq 0x180a0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x41d5
leaq 0x1a799(%rip), %rdi     # 0x1e967
movb $0x0, %al
callq 0x182f0
jmp 0x41d7
jmp 0x4243
movq -0x20(%rbp), %rax
movl 0x4(%rax), %edi
callq 0x12a30
movq -0x20(%rbp), %rcx
movq %rax, 0x8(%rcx)
cmpq $0x0, %rax
jne 0x4210
jmp 0x41f5
leaq 0x1a78c(%rip), %rdi     # 0x1e988
movb $0x0, %al
callq 0x182f0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x4236
movq -0x20(%rbp), %rdi
callq 0x4b10
cmpl $0x0, %eax
je 0x4220
jmp 0x4229
movl $0x0, -0x4(%rbp)
jmp 0x4296
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x13080
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x13750
movq -0x20(%rbp), %rax
movl 0x4(%rax), %edi
callq 0x21f0
cmpl $0x0, %eax
je 0x428d
jmp 0x4256
callq 0x20a0
cmpl $0x0, (%rax)
je 0x427b
leaq 0x1c17b(%rip), %rdi     # 0x203e2
movb $0x0, %al
callq 0x180a0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x4289
leaq 0x1c160(%rip), %rdi     # 0x203e2
movb $0x0, %al
callq 0x182f0
jmp 0x428b
jmp 0x428d
jmp 0x428f
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nop