// File: /workspace/github_c_makefile_star2_O0/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 %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, 0x1c(%rcx)
cmpl $-0x1, %eax
jne 0x40a2
jmp 0x4068
callq 0x20a0
cmpl $0x0, (%rax)
je 0x408d
leaq 0x1a6d8(%rip), %rdi     # 0x1e751
movb $0x0, %al
callq 0xe670
callq 0x20a0
movl $0x0, (%rax)
jmp 0x409b
leaq 0x1a6bd(%rip), %rdi     # 0x1e751
movb $0x0, %al
callq 0xe8c0
jmp 0x409d
jmp 0x428b
movq -0x20(%rbp), %rax
movl 0x1c(%rax), %edi
movl $0x4, %esi
movl $0x800, %edx            # imm = 0x800
movb $0x0, %al
callq 0x2120
cmpl $-0x1, %eax
jne 0x40fb
jmp 0x40c1
callq 0x20a0
cmpl $0x0, (%rax)
je 0x40e6
leaq 0x1a69a(%rip), %rdi     # 0x1e76c
movb $0x0, %al
callq 0xe670
callq 0x20a0
movl $0x0, (%rax)
jmp 0x40f4
leaq 0x1a67f(%rip), %rdi     # 0x1e76c
movb $0x0, %al
callq 0xe8c0
jmp 0x40f6
jmp 0x423f
movq -0x20(%rbp), %rax
movl 0x1c(%rax), %edi
movq -0x20(%rbp), %rdx
leaq 0x313(%rip), %rsi       # 0x4420
callq 0x93c0
movq -0x20(%rbp), %rcx
movq %rax, 0x20(%rcx)
cmpq $0x0, %rax
jne 0x415c
jmp 0x4122
callq 0x20a0
cmpl $0x0, (%rax)
je 0x4147
leaq 0x1a65d(%rip), %rdi     # 0x1e790
movb $0x0, %al
callq 0xe670
callq 0x20a0
movl $0x0, (%rax)
jmp 0x4155
leaq 0x1a642(%rip), %rdi     # 0x1e790
movb $0x0, %al
callq 0xe8c0
jmp 0x4157
jmp 0x423f
movq -0x20(%rbp), %rax
movl 0x1c(%rax), %edi
callq 0x8ce0
movq -0x20(%rbp), %rcx
movq %rax, 0x28(%rcx)
cmpq $0x0, %rax
jne 0x41b2
jmp 0x4178
callq 0x20a0
cmpl $0x0, (%rax)
je 0x419d
leaq 0x1a628(%rip), %rdi     # 0x1e7b1
movb $0x0, %al
callq 0xe670
callq 0x20a0
movl $0x0, (%rax)
jmp 0x41ab
leaq 0x1a60d(%rip), %rdi     # 0x1e7b1
movb $0x0, %al
callq 0xe8c0
jmp 0x41ad
jmp 0x4232
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x20(%rbp), %rdx
leaq 0x2cb(%rip), %rsi       # 0x4490
callq 0x10cd0
movq -0x20(%rbp), %rcx
movq %rax, 0x30(%rcx)
cmpq $0x0, %rax
jne 0x4211
jmp 0x41da
callq 0x20a0
cmpl $0x0, (%rax)
je 0x41ff
leaq 0x1a5e6(%rip), %rdi     # 0x1e7d1
movb $0x0, %al
callq 0xe670
callq 0x20a0
movl $0x0, (%rax)
jmp 0x420d
leaq 0x1a5cb(%rip), %rdi     # 0x1e7d1
movb $0x0, %al
callq 0xe8c0
jmp 0x420f
jmp 0x4225
movq -0x20(%rbp), %rax
movl $0x0, 0x18(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x4292
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x9330
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x9a00
movq -0x20(%rbp), %rax
movl 0x1c(%rax), %edi
callq 0x2220
cmpl $0x0, %eax
je 0x4289
jmp 0x4252
callq 0x20a0
cmpl $0x0, (%rax)
je 0x4277
leaq 0x1a860(%rip), %rdi     # 0x1eac3
movb $0x0, %al
callq 0xe670
callq 0x20a0
movl $0x0, (%rax)
jmp 0x4285
leaq 0x1a845(%rip), %rdi     # 0x1eac3
movb $0x0, %al
callq 0xe8c0
jmp 0x4287
jmp 0x4289
jmp 0x428b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)