// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/liball/../lib/dynamodb/dynamodb_kv.c
// Function: dynamodb_kv_put
char *
dynamodb_kv_put(const char * table, const char * key,
    const uint8_t * buf, size_t len)
{
	/**
	 * The body of a PutItem request (with spaces added) is:
	 * { "TableName": "TABLE",
	 *   "Item": {
	 *     "K": { "S": "KEY" },
	 *     "V": { "B": "BASE64VALUE" }
	 *   },
	 *   "ReturnConsumedCapacity": "TOTAL"
	 * }
	 */
	const char * s1 = "{\"TableName\":\"";
	const char * s2 = "\",\"Item\":{\"K\":{\"S\":\"";
	const char * s3 = "\"},\"V\":{\"B\":\"";
	const char * s4 = "\"}},\"ReturnConsumedCapacity\":\"TOTAL\"}";
	size_t slen = strlen(s1) + strlen(table) + strlen(s2) + strlen(key) +
	    strlen(s3) + b64len(len) + strlen(s4);
	size_t spos = 0;
	char * s;

	/* Allocate request string. */
	if ((s = malloc(slen + 1)) == NULL)
		goto done;

	/* Construct the request, piece by piece. */
	COPYANDINCR(s, spos, s1);
	COPYANDINCR(s, spos, table);
	COPYANDINCR(s, spos, s2);
	COPYANDINCR(s, spos, key);
	COPYANDINCR(s, spos, s3);
	b64encode(buf, &s[spos], len);
	spos += b64len(len);
	COPYANDINCR(s, spos, s4);
	s[spos] = '\0';

	/* Check that we got the buffer size right. */
	assert(slen == spos);

done:
	/* Return string (or NULL if allocation failed). */
	return (s);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r15
movq %rdx, 0x8(%rsp)
movq %rsi, %r13
movq %rdi, %rbp
callq 0x3190
movq %rax, %r14
movq %r13, %rdi
callq 0x3190
movq %rax, %rbx
leaq (%r14,%rax), %rcx
movq %r15, 0x10(%rsp)
leaq 0x2(%r15), %rax
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
mulq %rdx
movq %rdx, %r15
addq %rdx, %r15
andq $-0x4, %r15
leaq (%r15,%rcx), %rdi
addq $0x55, %rdi
callq 0x34c0
movq %rax, %r12
testq %rax, %rax
je 0x5b32
leaq (%r14,%rbx), %rax
addq $0x22, %rax
movq %rax, (%rsp)
movabsq $0x223a22656d614e65, %rax # imm = 0x223A22656D614E65
movq %rax, 0x6(%r12)
movabsq $0x4e656c626154227b, %rax # imm = 0x4E656C626154227B
movq %rax, (%r12)
leaq 0xe(%r12), %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x3280
movq %rbp, %rdi
callq 0x3190
movq %rax, %rbx
movups 0xbb2d(%rip), %xmm0     # 0x115b4
movups %xmm0, 0xe(%r12,%rax)
movl $0x223a2253, 0x1e(%r12,%rax) # imm = 0x223A2253
leaq (%r12,%rax), %r14
addq $0x22, %r14
movq %r13, %rdi
callq 0x3190
movq %r14, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x3280
movq %r13, %rdi
callq 0x3190
addq %rax, %rbx
addq $0x22, %rbx
movabsq $0x7b3a2256222c7d22, %rax # imm = 0x7B3A2256222C7D22
movq %rax, (%r12,%rbx)
movabsq $0x223a2242227b3a22, %rax # imm = 0x223A2242227B3A22
movq %rax, 0x5(%r12,%rbx)
leaq (%r12,%rbx), %rsi
addq $0xd, %rsi
movq %r12, %r14
addq %rbx, %r14
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rdx
callq 0xb29c
movabsq $0x7d224c41544f5422, %rax # imm = 0x7D224C41544F5422
movq %rax, 0x2a(%r15,%r14)
movups 0xbad4(%rip), %xmm0     # 0x115e7
movups %xmm0, 0x1d(%r15,%r14)
movups 0xbab7(%rip), %xmm0     # 0x115d7
movups %xmm0, 0xd(%r15,%r14)
movb $0x0, 0x32(%r15,%r14)
cmpq %rbx, (%rsp)
jne 0x5b44
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xbab2(%rip), %rdi      # 0x115fd
leaq 0xbab8(%rip), %rsi      # 0x1160a
leaq 0xbacf(%rip), %rcx      # 0x11628
movl $0x3d, %edx
callq 0x3200