// File: /workspace/github_c_makefile_star2_O3/Tarsnap[P]spiped/tests/nc-server/simple_server.c
// Function: callback_gotconn
static int
callback_gotconn(void * cookie, int s)
{
	struct accept_state * A = cookie;
	struct conn_list_node * node_new;

	/* This accept is no longer in progress. */
	A->accept_cookie = NULL;

	/* If we got a -1 descriptor, something went seriously wrong. */
	if (s == -1) {
		warnp("network_accept");
		goto err0;
	}

	/* We have gained a connection. */
	A->nconn += 1;

	/* Create new conn_list_node. */
	if ((node_new = malloc(sizeof(struct conn_list_node))) == NULL) {
		warn0("Out of memory");
		goto err1;
	}
	node_new->A = A;
	node_new->sock_read = s;

	/* Schedule reading from this connection. */
	if ((node_new->network_read_cookie = network_read(node_new->sock_read,
	    node_new->buf, BUFLEN, 1, callback_read, node_new)) == NULL) {
		warnp("network_read");
		goto err2;
	}

	/* Insert node_new to the beginning of the conn_cookies list. */
	LIST_INSERT_HEAD(&A->conn_cookies, node_new, entries);

	/* Accept another connection if we can. */
	if (doaccept(A)) {
		warn0("doaccept");
		goto err0;
	}

	/* Success! */
	return (0);

err2:
	free(node_new);
err1:
	A->nconn -= 1;
	if (close(s))
		warnp("close");
err0:
	/* Failure! */
	return (-1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq $0x0, 0x30(%rdi)
cmpl $-0x1, %esi
je 0x2d0a
movl %esi, %ebp
movq %rdi, %rbx
incq 0x20(%rdi)
movl $0x2028, %edi           # imm = 0x2028
callq 0x21f0
testq %rax, %rax
je 0x2d2d
movq %rax, %r14
movq %rbx, 0x10(%rax)
movl %ebp, 0x18(%rax)
movq %rax, %rsi
addq $0x1c, %rsi
leaq 0x14f(%rip), %r8        # 0x2dee
movl $0x2000, %edx           # imm = 0x2000
movl $0x1, %ecx
movl %ebp, %edi
movq %rax, %r9
callq 0x450c
movq %rax, 0x2020(%r14)
testq %rax, %rax
je 0x2d48
leaq 0x38(%rbx), %rax
movq 0x38(%rbx), %rcx
movq %rcx, (%r14)
testq %rcx, %rcx
je 0x2cd7
movq %r14, 0x8(%rcx)
movq %r14, 0x38(%rbx)
movq %rax, 0x8(%r14)
movq %rbx, %rdi
callq 0x2bd7
testl %eax, %eax
je 0x2d81
leaq 0x4480(%rip), %rdi      # 0x7176
xorl %eax, %eax
callq 0x5e17
callq 0x2090
movl $0x0, (%rax)
jmp 0x2d7a
callq 0x2090
cmpl $0x0, (%rax)
je 0x2d6c
movq %rax, %rbx
leaq 0x447a(%rip), %rdi      # 0x7198
xorl %eax, %eax
callq 0x5cf8
movl $0x0, (%rbx)
jmp 0x2d7a
leaq 0x4434(%rip), %rdi      # 0x7168
xorl %eax, %eax
callq 0x5e17
callq 0x2090
movl $0x0, (%rax)
jmp 0x2d9b
callq 0x2090
cmpl $0x0, (%rax)
je 0x2d85
movq %rax, %r15
leaq 0x444b(%rip), %rdi      # 0x71a7
xorl %eax, %eax
callq 0x5cf8
movl $0x0, (%r15)
jmp 0x2d93
leaq 0x4425(%rip), %rdi      # 0x7198
xorl %eax, %eax
callq 0x5e17
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x2de1
xorl %ebx, %ebx
jmp 0x2de1
leaq 0x441b(%rip), %rdi      # 0x71a7
xorl %eax, %eax
callq 0x5e17
movq %r14, %rdi
callq 0x2040
decq 0x20(%rbx)
movl %ebp, %edi
callq 0x2180
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %eax, %eax
je 0x2de1
callq 0x2090
cmpl $0x0, (%rax)
je 0x2dd3
movq %rax, %r14
leaq 0x42ea(%rip), %rdi      # 0x70ad
xorl %eax, %eax
callq 0x5cf8
movl $0x0, (%r14)
jmp 0x2de1
leaq 0x42d3(%rip), %rdi      # 0x70ad
xorl %eax, %eax
callq 0x5e17
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq