// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/liball/../lib/dynamodb/dynamodb_request_queue.c
// Function: runqueue
static int
runqueue(struct dynamodb_request_queue * Q)
{
	struct request * R;
	struct timeval tnow;

	/* Increase burst capacity. */
	if (monoclock_get(&tnow))
		goto err0;
	Q->bucket_cap += timeval_diff(Q->bucket_cap_lastbump, tnow) *
	    Q->cappers;
	Q->bucket_cap_lastbump = tnow;

	/* Send requests as long as we have enough capacity. */
	while (((double)(Q->inflight + 1) * Q->mu_capperreq <= Q->maxburst_cap) &&
	    ((double)(Q->inflight + 1) * Q->mu_capperreq <= Q->bucket_cap)) {
		/* Find the highest-priority request in the queue. */
		R = ptrheap_getmin(Q->reqs);

		/* Nothing left to send? */
		if ((R == NULL) || (R->timeout_cookie != NULL))
			break;

		/* Send the highest-priority request. */
		if (sendreq(Q, R))
			goto err0;
	}

	/* Do we need to (re)start the capacity-accumulation timer? */
	if ((Q->timer_cookie == NULL) &&
	    ((double)(Q->inflight + 1) * Q->mu_capperreq > Q->bucket_cap)) {
		if ((Q->timer_cookie = events_timer_register_double(
		        poke_timer, Q, Q->spercap)) == NULL)
			goto err0;
	}

	/* Success! */
	return (0);

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
leaq 0x28(%rsp), %rdi
callq 0x5134
testl %eax, %eax
je 0x639a
pushq $-0x1
popq %rbp
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
subq 0x40(%rbx), %rax
cvtsi2sd %rax, %xmm0
subq 0x48(%rbx), %rcx
cvtsi2sd %rcx, %xmm1
mulsd 0xa0da(%rip), %xmm1     # 0x10498
addsd %xmm0, %xmm1
mulsd 0x28(%rbx), %xmm1
addsd 0x38(%rbx), %xmm1
movsd %xmm1, 0x38(%rbx)
movupd 0x28(%rsp), %xmm0
movupd %xmm0, 0x40(%rbx)
pushq $0x1
popq %rbp
leaq 0x22c(%rip), %r14       # 0x6612
leaq 0x275(%rip), %r13       # 0x6662
movq 0x68(%rbx), %rax
incq %rax
movq %rax, %xmm1
punpckldq 0xa31f(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xa327(%rip), %xmm1     # 0x10730
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x20(%rbx), %xmm0
movsd 0x50(%rbx), %xmm1
ucomisd %xmm0, %xmm1
jb 0x654c
movsd 0x38(%rbx), %xmm1
ucomisd %xmm0, %xmm1
jb 0x654c
movq 0x70(%rbx), %rdi
callq 0x8119
testq %rax, %rax
je 0x654c
movq %rax, %r12
cmpq $0x0, 0x58(%rax)
jne 0x654c
movq 0x18(%rbx), %rdi
callq 0x7830
leaq 0x40(%r12), %r15
movq %rax, 0x40(%r12)
movq %r12, %rdi
addq $0x68, %rdi
callq 0x5134
testl %eax, %eax
jne 0x65b7
movq 0x60(%r12), %rcx
movsd 0xa2cc(%rip), %xmm3     # 0x10758
movapd %xmm3, %xmm0
cmpq $0x13, %rcx
ja 0x64d0
movsd 0x90(%rbx), %xmm1
mulsd 0xa2ba(%rip), %xmm1     # 0x10760
movl %ebp, %eax
shll %cl, %eax
movsd 0x88(%rbx), %xmm2
mulsd 0xa2ae(%rip), %xmm2     # 0x10768
cvtsi2sd %eax, %xmm0
addsd %xmm1, %xmm2
mulsd %xmm2, %xmm0
ucomisd %xmm3, %xmm0
jbe 0x64d0
movapd %xmm3, %xmm0
incq %rcx
movq %rcx, 0x60(%r12)
movq %r14, %rdi
movq %r12, %rsi
callq 0x4f7e
movq %rax, 0x58(%r12)
testq %rax, %rax
je 0x65f7
incq 0x68(%rbx)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0x10(%rbx), %rcx
movq 0x8(%r12), %r8
movq 0x10(%r12), %r9
movupd 0x18(%r12), %xmm0
movq %r12, 0x18(%rsp)
movq %r13, 0x10(%rsp)
movupd %xmm0, (%rsp)
movq %r15, %rdi
callq 0xbb1b
movq %rax, 0x50(%r12)
testq %rax, %rax
je 0x65d7
movq 0x70(%rbx), %rdi
movq 0x88(%r12), %rsi
callq 0x830c
jmp 0x63ed
xorl %ebp, %ebp
cmpq $0x0, 0x58(%rbx)
jne 0x6389
movq 0x68(%rbx), %rax
incq %rax
movq %rax, %xmm0
punpckldq 0xa1b3(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xa1bb(%rip), %xmm0     # 0x10730
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x20(%rbx), %xmm1
ucomisd 0x38(%rbx), %xmm1
jbe 0x6389
movsd 0x30(%rbx), %xmm0
leaq 0x6b(%rip), %rdi        # 0x6608
movq %rbx, %rsi
callq 0x4f7e
movq %rax, 0x58(%rbx)
testq %rax, %rax
jne 0x6389
jmp 0x6386
callq 0x3040
cmpl $0x0, (%rax)
je 0x65e9
movq %rax, %rbx
leaq 0xa1c5(%rip), %rdi      # 0x10790
xorl %eax, %eax
callq 0x53ad
andl $0x0, (%rbx)
jmp 0x65f7
movq 0x58(%r12), %rdi
callq 0x4fb3
andq $0x0, 0x58(%r12)
jmp 0x65f7
leaq 0xa1a0(%rip), %rdi      # 0x10790
xorl %eax, %eax
callq 0x553c
movq (%r15), %rdi
callq 0xb1bb
andq $0x0, (%r15)
jmp 0x6386