// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/liball/../lib/dynamodb/dynamodb_request_queue.c
// Function: dynamodb_request_queue_init
struct dynamodb_request_queue *
dynamodb_request_queue_init(const char * key_id, const char * key_secret,
    const char * region, struct serverpool * SP)
{
	struct dynamodb_request_queue * Q;

	/* Allocate a request queue structure. */
	if ((Q = malloc(sizeof(struct dynamodb_request_queue))) == NULL)
		goto err0;

	/* Copy in strings. */
	if ((Q->key_id = strdup(key_id)) == NULL)
		goto err1;
	if ((Q->key_secret = strdup(key_secret)) == NULL)
		goto err2;
	if ((Q->region = strdup(region)) == NULL)
		goto err3;

	/* Record the server pool to draw IP addresses from. */
	Q->SP = SP;

	/*
	 * Initialize rate-limiting parameters.  The initial bucket capacity
	 * is set to 300 seconds of 50k capacity units per second; this
	 * allows an effectively unlimited burst until the first "capacity
	 * exceeded" warning is seen, after which bucket_cap is limited to
	 * 300 seconds of provisioned capacity.
	 */
	Q->mu_capperreq = 1.0;
	Q->bucket_cap = 300.0 * 50000.0;
	dynamodb_request_queue_setcapacity(Q, 0);
	if (monoclock_get(&Q->bucket_cap_lastbump))
		goto err4;

	/* Initialize request timeout statistics to conservative values. */
	Q->tmu = 1.0;
	Q->tmud = 0.25;

	/* We have no pending events. */
	Q->timer_cookie = NULL;
	Q->immediate_cookie = NULL;

	/* No requests yet. */
	if ((Q->reqs = ptrheap_init(compar, setreccookie, Q)) == NULL)
		goto err4;
	Q->reqnum = 0;
	Q->inflight = 0;

	/* No log file yet. */
	Q->logfile = NULL;

	/* Success! */
	return (Q);

err4:
	free(Q->region);
err3:
	insecure_memzero(Q->key_secret, strlen(Q->key_secret));
	free(Q->key_secret);
err2:
	free(Q->key_id);
err1:
	free(Q);
err0:
	/* Failure! */
	return (NULL);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
movl $0x98, %edi
callq 0x34c0
testq %rax, %rax
je 0x6521
movq %rax, %rbx
movq %r13, %rdi
callq 0x35e0
movq %rax, (%rbx)
testq %rax, %rax
je 0x6519
movq %r12, %rdi
callq 0x35e0
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x6511
movq %r15, %rdi
callq 0x35e0
movq %rax, 0x10(%rbx)
testq %rax, %rax
je 0x64ea
movq %r14, 0x18(%rbx)
movabsq $0x3ff0000000000000, %r14 # imm = 0x3FF0000000000000
movq %r14, 0x20(%rbx)
movabsq $0x416c9c3800000000, %rax # imm = 0x416C9C3800000000
movq %rax, 0x38(%rbx)
movabsq $0x412e848000000000, %rax # imm = 0x412E848000000000
movq %rax, 0x28(%rbx)
movq $0x0, 0x30(%rbx)
movabsq $0x407f400000000000, %rax # imm = 0x407F400000000000
movq %rax, 0x50(%rbx)
movq %rbx, %rdi
addq $0x40, %rdi
callq 0x54d0
testl %eax, %eax
je 0x6530
movq 0x10(%rbx), %rdi
callq 0x3450
movq 0x8(%rbx), %r14
movq %r14, %rdi
callq 0x3190
leaq 0x120db(%rip), %rcx     # 0x185d8
movq (%rcx), %rcx
movq %r14, %rdi
movq %rax, %rsi
callq *%rcx
movq 0x8(%rbx), %rdi
callq 0x3450
movq (%rbx), %rdi
callq 0x3450
movq %rbx, %rdi
callq 0x3450
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %r14, 0x88(%rbx)
movabsq $0x3fd0000000000000, %rax # imm = 0x3FD0000000000000
movq %rax, 0x90(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x58(%rbx)
leaq 0x82(%rip), %rdi        # 0x65d8
leaq 0xce(%rip), %rsi        # 0x662b
movq %rbx, %rdx
callq 0x8504
movq %rax, 0x70(%rbx)
testq %rax, %rax
je 0x64e1
movq $0x0, 0x68(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x78(%rbx)
jmp 0x6523