// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/liball/../lib/dynamodb/dynamodb_kv.c
// Function: dynamodb_kv_create
char *
dynamodb_kv_create(const char * table, const char * key,
    const uint8_t * buf, size_t len)
{
	/**
	 * A CREATE is a PutItem request with a body (with spaces added) of:
	 * { "TableName": "TABLE",
	 *   "Item": {
	 *     "K": { "S": "KEY" },
	 *     "V": { "B": "BASE64NEW" }
	 *   },
	 *   "ConditionExpression": "(attribute_not_exists(V)) OR (V = :new)",
	 *   "ExpressionAttributeValues": {
	 *       ":new": { "B": "BASE64NEW" }
	 *   },
	 *   "ReturnConsumedCapacity": "TOTAL"
	 * }
	 */
	const char * s1 = "{\"TableName\":\"";
	const char * s2 = "\",\"Item\":{\"K\":{\"S\":\"";
	const char * s3 = "\"},\"V\":{\"B\":\"";
	const char * s4 = "\"}},\"ConditionExpression\":\"(attribute_not_exists(V))OR(V=:new)\",";
	const char * s5 = "\"ExpressionAttributeValues\":{\":new\":{\"B\":\"";
	const char * s6 = "\"}},\"ReturnConsumedCapacity\":\"TOTAL\"}";
	size_t slen = strlen(s1) + strlen(table) + strlen(s2) + strlen(key) +
	    strlen(s3) + b64len(len) + strlen(s4) + strlen(s5) + b64len(len) +
	    strlen(s6);
	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);
	COPYANDINCR(s, spos, s5);
	b64encode(buf, &s[spos], len);
	spos += b64len(len);
	COPYANDINCR(s, spos, s6);
	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
movq %r15, 0x10(%rsp)
leaq 0x2(%r15), %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
mulq %rcx
movq %rdx, %r15
leaq (%r14,%rbx), %rax
shrq %r15
leaq (%rax,%r15,8), %rdi
addq $0xbf, %rdi
callq 0x34c0
movq %rax, %r12
testq %rax, %rax
je 0x5f87
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 0xb754(%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 0xd(%r12,%rbx), %rsi
movq 0x8(%rsp), %rbp
movq %rbp, %rdi
movq 0x10(%rsp), %r13
movq %r13, %rdx
callq 0xb29c
leaq (%rbx,%r15,4), %rax
addq $0xd, %rax
leaq (%r12,%rax), %r14
movups 0xb88e(%rip), %xmm0     # 0x11774
movups %xmm0, 0x30(%r12,%rax)
movups 0xb871(%rip), %xmm0     # 0x11764
movups %xmm0, 0x20(%r12,%rax)
movups 0xb854(%rip), %xmm0     # 0x11754
movups %xmm0, 0x10(%r12,%rax)
movups 0xb837(%rip), %xmm0     # 0x11744
movups %xmm0, (%r12,%rax)
movups 0xb86c(%rip), %xmm0     # 0x11785
movups %xmm0, 0x40(%r12,%rax)
movups 0xb86f(%rip), %xmm0     # 0x11795
movups %xmm0, 0x50(%r12,%rax)
movups 0xb86c(%rip), %xmm0     # 0x1179f
movups %xmm0, 0x5a(%r12,%rax)
leaq (%r12,%rax), %rsi
addq $0x6a, %rsi
movq %rbp, %rdi
movq %r13, %rdx
callq 0xb29c
movabsq $0x7d224c41544f5422, %rax # imm = 0x7D224C41544F5422
movq %rax, 0x87(%r14,%r15,4)
movups 0xb682(%rip), %xmm0     # 0x115e7
movups %xmm0, 0x7a(%r14,%r15,4)
movups 0xb665(%rip), %xmm0     # 0x115d7
movups %xmm0, 0x6a(%r14,%r15,4)
movb $0x0, 0x8f(%r14,%r15,4)
cmpq %rbx, (%rsp)
jne 0x5f99
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb65d(%rip), %rdi      # 0x115fd
leaq 0xb663(%rip), %rsi      # 0x1160a
leaq 0xb802(%rip), %rcx      # 0x117b0
movl $0xc0, %edx
callq 0x3200