// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/liball/../lib/wire/wire_requestqueue.c
// Function: readpackets
static int
readpackets(void * cookie, int status)
{
	struct wire_requestqueue * Q = cookie;
	struct wire_packet P;
	struct request * R;

	/* We're not waiting for a packet to be available any more. */
	Q->read_cookie = NULL;

	/* If the wait failed, the connection is dying. */
	if (status)
		goto fail;

	/* Handle packets until there are no more or we encounter an error. */
	do {
		/* Grab a packet. */
		if (wire_readpacket_peek(Q->R, &P))
			goto fail;

		/* Exit the loop if no packet is available. */
		if (P.buf == NULL)
			break;

		/* Look up the request associated with this response. */
		if ((R = seqptrmap_get(Q->reqs, (int64_t)P.ID)) == NULL) {
			/* Is this response ID reasonable? */
			warn0("Received bogus response ID: %016" PRIx64, P.ID);

			/* This connection is not useful. */
			goto fail;
		}

		/* Delete the request from the pending request map. */
		seqptrmap_delete(Q->reqs, (int64_t)P.ID);

		/* Invoke the upstream callback. */
		if ((R->callback)(R->cookie, P.buf, P.len))
			goto err0;

		/* Free the request structure. */
		mpool_request_free(R);

		/* Consume the packet. */
		wire_readpacket_consume(Q->R, &P);
	} while (1);

	/* Wait for another packet to arrive. */
	if ((Q->read_cookie =
	    wire_readpacket_wait(Q->R, readpackets, Q)) == NULL)
		goto err0;

	/* Success! */
	return (0);

fail:
	/* This request queue has failed. */
	return (failqueue(Q));

err0:
	/* Failure! */
	return (-1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq $0x0, 0x10(%rdi)
testl %esi, %esi
jne 0x6d94
movq (%rbx), %rdi
movq %rsp, %rsi
callq 0x940c
testl %eax, %eax
je 0x6dab
movq %rbx, %rdi
callq 0x6c7b
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsp, %r14
cmpq $0x0, 0x10(%rsp)
je 0x6ede
movq 0x18(%rbx), %rdi
movq (%rsp), %rsi
callq 0x7e04
testq %rax, %rax
je 0x6f0c
movq %rax, %r15
movq 0x18(%rbx), %rdi
movq (%rsp), %rsi
callq 0x7e44
movq 0x8(%r15), %rdi
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rsi
callq *(%r15)
testl %eax, %eax
jne 0x6f02
movq 0xa710(%rip), %rax      # 0x11510
movq 0xa711(%rip), %r12      # 0x11518
cmpq %r12, %rax
jae 0x6e27
movq 0xa70d(%rip), %rcx      # 0x11520
leaq 0x1(%rax), %rdx
movq %rdx, 0xa6f2(%rip)      # 0x11510
movq %r15, (%rcx,%rax,8)
jmp 0x6ebb
movq 0xa6fa(%rip), %rax      # 0x11528
shrq $0x8, %rax
cmpq %rax, 0xa6f7(%rip)      # 0x11530
jbe 0x6ea9
testq %r12, %r12
je 0x6f2e
movq %r12, %rdi
shlq $0x4, %rdi
callq 0x2220
testq %rax, %rax
je 0x6ea9
movq %rax, %r13
movq 0xa6c1(%rip), %rbp      # 0x11520
shlq $0x3, %r12
movq %rax, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x2200
cmpq 0xa6c8(%rip), %rbp      # 0x11540
je 0x6e82
movq %rbp, %rdi
callq 0x2040
movq %r13, 0xa697(%rip)      # 0x11520
shlq 0xa688(%rip)            # 0x11518
movq 0xa679(%rip), %rax      # 0x11510
leaq 0x1(%rax), %rcx
movq %rcx, 0xa66e(%rip)      # 0x11510
movq %r15, (%r13,%rax,8)
jmp 0x6eb1
movq %r15, %rdi
callq 0x2040
xorps %xmm0, %xmm0
movups %xmm0, 0xa66d(%rip)     # 0x11528
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x98b4
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x940c
testl %eax, %eax
je 0x6dae
jmp 0x6d94
movq (%rbx), %rdi
leaq -0x180(%rip), %rsi      # 0x6d68
movq %rbx, %rdx
callq 0x953d
movq %rax, %rcx
movq %rax, 0x10(%rbx)
xorl %eax, %eax
testq %rcx, %rcx
jne 0x6d9c
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x6d9c
movq (%rsp), %rsi
leaq 0x4ed9(%rip), %rdi      # 0xbdf0
xorl %eax, %eax
callq 0x514b
callq 0x2090
movl $0x0, (%rax)
jmp 0x6d94
leaq 0x419b(%rip), %rdi      # 0xb0d0
leaq 0x41a5(%rip), %rsi      # 0xb0e1
leaq 0x41c0(%rip), %rcx      # 0xb103
movl $0x5a, %edx
callq 0x2180