// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/liball/../lib/dynamodb/dynamodb_request_queue.c
// Function: extractcapacity
static int
extractcapacity(struct http_response * res, double * pcap)
{
	const uint8_t * buf = res->body;
	const uint8_t * end = res->body + res->bodylen;
	char * capacity;
	size_t len;

	/* Look for ConsumedCapacity. */
	buf = json_find(buf, end, "ConsumedCapacity");

	/* Look for CapacityUnits inside that. */
	buf = json_find(buf, end, "CapacityUnits");

	/*
	 * If there is no ConsumedCapacity->CapacityUnits, no capacity was
	 * consumed by the request in question.
	 */
	if (buf == end) {
		*pcap = 0.0;
		return (0);
	}

	/* Figure out how long the numeric value is. */
	for (len = 0; &buf[len] < end; len++) {
		if (strchr("+-0123456789.eE", buf[len]) == NULL)
			break;
	}

	/* Extract it into a (NUL-terminated) string. */
	if ((capacity = malloc(len + 1)) == NULL)
		goto err0;
	memcpy(capacity, buf, len);
	capacity[len] = '\0';

	/* Parse the string. */
	if (PARSENUM(pcap, capacity, 0, 400)) {
		/*
		 * As specified right now, DynamoDB should never return a
		 * CapacityUnits outside [0, 400]; but just in case that
		 * changes in the future, print a warning but don't treat
		 * it as an error.
		 */
		warn0("Invalid DynamoDB CapacityUnits returned: %s",
		    capacity);
		*pcap = 0.0;
	}

	/* Free the capacity string. */
	free(capacity);

	/* Success! */
	return (0);

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x10(%rbp), %rcx
addq 0x18(%rcx), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
leaq 0x15471(%rip), %rdx     # 0x1e980
callq 0x104a0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
leaq 0x1546a(%rip), %rdx     # 0x1e991
callq 0x104a0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x28(%rbp), %rax
jne 0x9551
movq -0x18(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x976b
movq $0x0, -0x38(%rbp)
movq -0x20(%rbp), %rax
addq -0x38(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x9597
movq -0x20(%rbp), %rax
movq -0x38(%rbp), %rcx
movzbl (%rax,%rcx), %esi
leaq 0x15425(%rip), %rdi     # 0x1e99f
callq 0x3170
cmpq $0x0, %rax
jne 0x9587
jmp 0x9597
jmp 0x9589
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x9559
movq -0x38(%rbp), %rdi
addq $0x1, %rdi
callq 0x34c0
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x95b3
jmp 0x9764
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x32c0
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
movb $0x0, (%rax,%rcx)
callq 0x3040
movl $0x0, (%rax)
movq -0x18(%rbp), %rax
movsd 0x14eb9(%rip), %xmm0    # 0x1e4a0
movsd %xmm0, (%rax)
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
movsd 0x152f5(%rip), %xmm1    # 0x1e8f0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax)
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x962f
movq -0x30(%rbp), %rdi
xorps %xmm0, %xmm0
movsd 0x152ed(%rip), %xmm1    # 0x1e908
xorl %esi, %esi
callq 0x9780
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x971e
movq -0x18(%rbp), %rax
movsd 0x152bd(%rip), %xmm0    # 0x1e8f8
movsd %xmm0, (%rax)
movb $0x1, %al
testb $0x1, %al
jne 0x9647
jmp 0x969d
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rax
movsd (%rax), %xmm1
xorps %xmm0, %xmm0
xorl %eax, %eax
ucomisd %xmm1, %xmm0
cmovael %eax, %eax
movslq %eax, %rsi
movq -0x18(%rbp), %rax
movsd (%rax), %xmm1
xorps %xmm0, %xmm0
xorl %eax, %eax
movl $0x190, %ecx            # imm = 0x190
ucomisd %xmm1, %xmm0
cmovael %ecx, %eax
movslq %eax, %rdx
xorl %r8d, %r8d
movl %r8d, %ecx
callq 0x9830
cvtsi2sd %rax, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
movsd %xmm0, -0x40(%rbp)
jmp 0x9719
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
movsd 0x1524f(%rip), %xmm2    # 0x1e900
movaps %xmm0, %xmm1
subsd %xmm2, %xmm1
cvttsd2si %xmm1, %rax
cvttsd2si %xmm0, %rcx
movq %rcx, %rdx
sarq $0x3f, %rdx
andq %rdx, %rax
orq %rax, %rcx
xorl %r9d, %r9d
movl %r9d, %esi
movl $0x190, %edx            # imm = 0x190
movl %r9d, %r8d
callq 0x98f0
movq %rax, %xmm0
movaps 0x15222(%rip), %xmm1    # 0x1e910
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x15226(%rip), %xmm1    # 0x1e920
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x40(%rbp), %xmm0
callq 0x3040
cmpl $0x0, (%rax)
je 0x9752
jmp 0x972a
movq -0x30(%rbp), %rsi
leaq 0x1527a(%rip), %rdi     # 0x1e9af
movb $0x0, %al
callq 0x6930
callq 0x3040
movl $0x0, (%rax)
movq -0x18(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movq -0x30(%rbp), %rdi
callq 0x3460
movl $0x0, -0x4(%rbp)
jmp 0x976b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)