// File: /workspace/github_c_makefile_star2_O1/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 0xa5c5(%rip)            # 0x11528
movq %rsi, %r14
movq %rdi, %r15
movq 0xa5a0(%rip), %rax      # 0x11510
testq %rax, %rax
je 0x6f8e
movq 0xa5a4(%rip), %rcx      # 0x11520
leaq -0x1(%rax), %rdx
movq %rdx, 0xa589(%rip)      # 0x11510
movq -0x8(%rcx,%rax,8), %rbx
jmp 0x6fc1
incq 0xa59b(%rip)            # 0x11530
cmpl $0x0, 0xa59c(%rip)      # 0x11538
jne 0x6fb4
movq 0xa5a3(%rip), %rdi      # 0x11548
callq 0xa050
movl $0x1, 0xa584(%rip)      # 0x11538
movl $0x10, %edi
callq 0x2220
movq %rax, %rbx
testq %rbx, %rbx
je 0x70f9
movq %r13, (%rbx)
movq %r12, 0x8(%rbx)
cmpl $0x0, 0x20(%r15)
je 0x6fff
leaq 0x145(%rip), %rdi       # 0x7124
movq %rbx, %rsi
xorl %edx, %edx
callq 0x2d70
testq %rax, %rax
je 0x7038
movq %r14, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x2220
movq 0x18(%r15), %rdi
movq %rbx, %rsi
callq 0x7d6f
cmpq $-0x1, %rax
je 0x7038
movq %rax, %r12
movq 0x8(%r15), %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x737c
testq %rax, %rax
jne 0x70fb
movq 0x18(%r15), %rdi
movq %r12, %rsi
callq 0x7e44
movq 0xa4d1(%rip), %rax      # 0x11510
movq 0xa4d2(%rip), %r14      # 0x11518
cmpq %r14, %rax
jae 0x7066
movq 0xa4ce(%rip), %rcx      # 0x11520
leaq 0x1(%rax), %rdx
movq %rdx, 0xa4b3(%rip)      # 0x11510
movq %rbx, (%rcx,%rax,8)
jmp 0x70f9
movq 0xa4bb(%rip), %rax      # 0x11528
shrq $0x8, %rax
cmpq %rax, 0xa4b8(%rip)      # 0x11530
jbe 0x70e7
testq %r14, %r14
je 0x7105
movq %r14, %rdi
shlq $0x4, %rdi
callq 0x2220
testq %rax, %rax
je 0x70e7
movq %rax, %r15
movq 0xa482(%rip), %r12      # 0x11520
shlq $0x3, %r14
movq %rax, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x2200
cmpq 0xa489(%rip), %r12      # 0x11540
je 0x70c1
movq %r12, %rdi
callq 0x2040
movq %r15, 0xa458(%rip)      # 0x11520
shlq 0xa449(%rip)            # 0x11518
movq 0xa43a(%rip), %rax      # 0x11510
leaq 0x1(%rax), %rcx
movq %rcx, 0xa42f(%rip)      # 0x11510
movq %rbx, (%r15,%rax,8)
jmp 0x70ef
movq %rbx, %rdi
callq 0x2040
xorps %xmm0, %xmm0
movups %xmm0, 0xa42f(%rip)     # 0x11528
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x3fc4(%rip), %rdi      # 0xb0d0
leaq 0x3fce(%rip), %rsi      # 0xb0e1
leaq 0x3fe9(%rip), %rcx      # 0xb103
movl $0x5a, %edx
callq 0x2180