// File: /workspace/github_c_makefile_star2_O3/Tarsnap[P]kivaloo/liball/../lib/wire/wire_requestqueue.c
// Function: wire_requestqueue_add_getbuf
uint8_t *
wire_requestqueue_add_getbuf(struct wire_requestqueue * Q, size_t len,
    int (* callback)(void *, uint8_t *, size_t), void * cookie)
{
	struct request * R;
	uint8_t * wbuf;
	uint64_t ID;

	/* Bake a cookie. */
	if ((R = mpool_request_malloc()) == NULL)
		goto err0;
	R->callback = callback;
	R->cookie = cookie;

	/* If the request queue has failed, we can't send a request. */
	if (Q->failed) {
		/* Schedule a failure callback. */
		if (events_immediate_register(failreq, R, 0) == NULL)
			goto err1;

		/* Return a dummy buffer for the request. */
		return (malloc(len));
	}

	/* Insert the cookie into the pending request map. */
	if ((ID = (uint64_t)seqptrmap_add(Q->reqs, R)) == (uint64_t)(-1))
		goto err1;

	/* Start writing a packet. */
	if ((wbuf = wire_writepacket_getbuf(Q->WQ, ID, len)) == NULL)
		goto err2;

	/* Return a pointer to the packet data buffer. */
	return (wbuf);

err2:
	seqptrmap_delete(Q->reqs, (int64_t)ID);
err1:
	mpool_request_free(R);
err0:
	/* Failure! */
	return (NULL);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %r12
movq %rdx, %r13
incq 0xa5ac(%rip)            # 0x11528
movq %rsi, %r14
movq %rdi, %r15
movq 0xa587(%rip), %rax      # 0x11510
testq %rax, %rax
je 0x6fa7
movq 0xa58b(%rip), %rcx      # 0x11520
leaq -0x1(%rax), %rdx
movq %rdx, 0xa570(%rip)      # 0x11510
movq -0x8(%rcx,%rax,8), %rbx
jmp 0x6fda
incq 0xa582(%rip)            # 0x11530
cmpl $0x0, 0xa583(%rip)      # 0x11538
jne 0x6fcd
movq 0xa58a(%rip), %rdi      # 0x11548
callq 0xa0d0
movl $0x1, 0xa56b(%rip)      # 0x11538
movl $0x10, %edi
callq 0x2220
movq %rax, %rbx
testq %rbx, %rbx
je 0x711f
movq %r13, (%rbx)
movq %r12, 0x8(%rbx)
cmpl $0x0, 0x20(%r15)
je 0x7018
leaq 0x152(%rip), %rdi       # 0x714a
movq %rbx, %rsi
xorl %edx, %edx
callq 0x2d94
testq %rax, %rax
je 0x7051
movq %r14, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x2220
movq 0x18(%r15), %rdi
movq %rbx, %rsi
callq 0x7d97
cmpq $-0x1, %rax
je 0x7051
movq %rax, %r12
movq 0x8(%r15), %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x73b4
testq %rax, %rax
jne 0x7121
movq 0x18(%r15), %rdi
movq %r12, %rsi
callq 0x7e6c
movq 0xa4b8(%rip), %r12      # 0x11510
movq 0xa4b9(%rip), %r13      # 0x11518
cmpq %r13, %r12
jae 0x7080
movq 0xa4b5(%rip), %rax      # 0x11520
leaq 0x1(%r12), %rcx
movq %rcx, 0xa499(%rip)      # 0x11510
movq %rbx, (%rax,%r12,8)
jmp 0x711f
movq 0xa4a1(%rip), %rax      # 0x11528
shrq $0x8, %rax
cmpq %rax, 0xa49e(%rip)      # 0x11530
jbe 0x710d
testq %r13, %r13
je 0x712b
movq %r13, %rdi
shlq $0x4, %rdi
callq 0x2220
testq %rax, %rax
je 0x710d
movq %rax, %r14
movq 0xa468(%rip), %r15      # 0x11520
leaq (,%r13,8), %rdx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2200
cmpq 0xa46e(%rip), %r15      # 0x11540
je 0x70ea
movq %r15, %rdi
callq 0x2040
movq 0xa435(%rip), %r13      # 0x11518
movq 0xa426(%rip), %r12      # 0x11510
movq %r14, 0xa42f(%rip)      # 0x11520
addq %r13, %r13
movq %r13, 0xa41d(%rip)      # 0x11518
leaq 0x1(%r12), %rax
movq %rax, 0xa409(%rip)      # 0x11510
movq %rbx, (%r14,%r12,8)
jmp 0x7115
movq %rbx, %rdi
callq 0x2040
xorps %xmm0, %xmm0
movups %xmm0, 0xa409(%rip)     # 0x11528
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x3f9e(%rip), %rdi      # 0xb0d0
leaq 0x3fa8(%rip), %rsi      # 0xb0e1
leaq 0x3fc3(%rip), %rcx      # 0xb103
movl $0x5a, %edx
callq 0x2180