// File: /workspace/github_c_makefile_star2_O3/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 0x6da0
movq (%rbx), %rdi
movq %rsp, %rsi
callq 0x9468
testl %eax, %eax
je 0x6db7
movq %rbx, %rdi
callq 0x6c87
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsp, %r13
cmpq $0x0, 0x10(%rsp)
je 0x6ef7
movq 0x18(%rbx), %rdi
movq (%rsp), %rsi
callq 0x7e2c
testq %rax, %rax
je 0x6f25
movq %rax, %r15
movq 0x18(%rbx), %rdi
movq (%rsp), %rsi
callq 0x7e6c
movq 0x8(%r15), %rdi
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rsi
callq *(%r15)
testl %eax, %eax
jne 0x6f1b
movq 0xa704(%rip), %rbp      # 0x11510
movq 0xa705(%rip), %r14      # 0x11518
cmpq %r14, %rbp
jae 0x6e33
movq 0xa701(%rip), %rax      # 0x11520
leaq 0x1(%rbp), %rcx
movq %rcx, 0xa6e6(%rip)      # 0x11510
movq %r15, (%rax,%rbp,8)
jmp 0x6ed4
movq 0xa6ee(%rip), %rax      # 0x11528
shrq $0x8, %rax
cmpq %rax, 0xa6eb(%rip)      # 0x11530
jbe 0x6ec2
testq %r14, %r14
je 0x6f47
movq %r14, %rdi
shlq $0x4, %rdi
callq 0x2220
testq %rax, %rax
je 0x6ec2
movq %rax, %r12
movq 0xa6b5(%rip), %r13      # 0x11520
leaq (,%r14,8), %rdx
movq %rax, %rdi
movq %r13, %rsi
callq 0x2200
cmpq 0xa6bb(%rip), %r13      # 0x11540
je 0x6e9d
movq %r13, %rdi
callq 0x2040
movq 0xa682(%rip), %r14      # 0x11518
movq 0xa673(%rip), %rbp      # 0x11510
movq %r12, 0xa67c(%rip)      # 0x11520
addq %r14, %r14
movq %r14, 0xa66a(%rip)      # 0x11518
leaq 0x1(%rbp), %rax
movq %rax, 0xa657(%rip)      # 0x11510
movq %r15, (%r12,%rbp,8)
movq %rsp, %r13
jmp 0x6eca
movq %r15, %rdi
callq 0x2040
xorps %xmm0, %xmm0
movups %xmm0, 0xa654(%rip)     # 0x11528
movq (%rbx), %rdi
movq %r13, %rsi
callq 0x9925
movq (%rbx), %rdi
movq %r13, %rsi
callq 0x9468
testl %eax, %eax
je 0x6dba
jmp 0x6da0
movq (%rbx), %rdi
leaq -0x18d(%rip), %rsi      # 0x6d74
movq %rbx, %rdx
callq 0x9596
movq %rax, %rcx
movq %rax, 0x10(%rbx)
xorl %eax, %eax
testq %rcx, %rcx
jne 0x6da8
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x6da8
movq (%rsp), %rsi
leaq 0x4ed0(%rip), %rdi      # 0xbe00
xorl %eax, %eax
callq 0x516f
callq 0x2090
movl $0x0, (%rax)
jmp 0x6da0
leaq 0x4182(%rip), %rdi      # 0xb0d0
leaq 0x418c(%rip), %rsi      # 0xb0e1
leaq 0x41a7(%rip), %rcx      # 0xb103
movl $0x5a, %edx
callq 0x2180