// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
leaq 0x170f3(%rip), %rax     # 0x1e575
movq %rax, -0x28(%rbp)
leaq 0x170f7(%rip), %rax     # 0x1e584
movq %rax, -0x30(%rbp)
leaq 0x17101(%rip), %rax     # 0x1e599
movq %rax, -0x38(%rbp)
leaq 0x17271(%rip), %rax     # 0x1e714
movq %rax, -0x40(%rbp)
leaq 0x172a7(%rip), %rax     # 0x1e755
movq %rax, -0x48(%rbp)
leaq 0x170ee(%rip), %rax     # 0x1e5a7
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %rdi
callq 0x31a0
movq %rax, -0xb0(%rbp)
movq -0x8(%rbp), %rdi
callq 0x31a0
movq %rax, %rcx
movq -0xb0(%rbp), %rax
addq %rcx, %rax
movq %rax, -0xa8(%rbp)
movq -0x30(%rbp), %rdi
callq 0x31a0
movq %rax, %rcx
movq -0xa8(%rbp), %rax
addq %rcx, %rax
movq %rax, -0xa0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x31a0
movq %rax, %rcx
movq -0xa0(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x98(%rbp)
movq -0x38(%rbp), %rdi
callq 0x31a0
movq %rax, %rcx
movq -0x98(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x90(%rbp)
movq -0x20(%rbp), %rax
addq $0x2, %rax
movl $0x3, %ecx
xorl %edx, %edx
divq %rcx
movq %rax, %rcx
movq -0x90(%rbp), %rax
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x40(%rbp), %rdi
callq 0x31a0
movq %rax, %rcx
movq -0x88(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x48(%rbp), %rdi
callq 0x31a0
movq %rax, %rcx
movq -0x80(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x20(%rbp), %rax
addq $0x2, %rax
movl $0x3, %ecx
xorl %edx, %edx
divq %rcx
movq %rax, %rcx
movq -0x78(%rbp), %rax
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x50(%rbp), %rdi
callq 0x31a0
movq %rax, %rcx
movq -0x70(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x58(%rbp), %rdi
addq $0x1, %rdi
callq 0x34c0
movq %rax, -0x68(%rbp)
cmpq $0x0, %rax
jne 0x75fb
jmp 0x78f6
jmp 0x75fd
movq -0x68(%rbp), %rax
addq -0x60(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x28(%rbp), %rdi
callq 0x31a0
movq -0xc0(%rbp), %rdi
movq -0xb8(%rbp), %rsi
movq %rax, %rdx
callq 0x32c0
movq -0x28(%rbp), %rdi
callq 0x31a0
addq -0x60(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x7649
movq -0x68(%rbp), %rax
addq -0x60(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x31a0
movq -0xd0(%rbp), %rdi
movq -0xc8(%rbp), %rsi
movq %rax, %rdx
callq 0x32c0
movq -0x8(%rbp), %rdi
callq 0x31a0
addq -0x60(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x7695
movq -0x68(%rbp), %rax
addq -0x60(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x30(%rbp), %rdi
callq 0x31a0
movq -0xe0(%rbp), %rdi
movq -0xd8(%rbp), %rsi
movq %rax, %rdx
callq 0x32c0
movq -0x30(%rbp), %rdi
callq 0x31a0
addq -0x60(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x76e1
movq -0x68(%rbp), %rax
addq -0x60(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x31a0
movq -0xf0(%rbp), %rdi
movq -0xe8(%rbp), %rsi
movq %rax, %rdx
callq 0x32c0
movq -0x10(%rbp), %rdi
callq 0x31a0
addq -0x60(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x772d
movq -0x68(%rbp), %rax
addq -0x60(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x38(%rbp), %rdi
callq 0x31a0
movq -0x100(%rbp), %rdi
movq -0xf8(%rbp), %rsi
movq %rax, %rdx
callq 0x32c0
movq -0x38(%rbp), %rdi
callq 0x31a0
addq -0x60(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rdi
movq -0x68(%rbp), %rsi
addq -0x60(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x101a0
movq -0x20(%rbp), %rax
addq $0x2, %rax
movl $0x3, %ecx
xorl %edx, %edx
divq %rcx
shlq $0x2, %rax
addq -0x60(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x68(%rbp), %rax
addq -0x60(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x40(%rbp), %rdi
callq 0x31a0
movq -0x110(%rbp), %rdi
movq -0x108(%rbp), %rsi
movq %rax, %rdx
callq 0x32c0
movq -0x40(%rbp), %rdi
callq 0x31a0
addq -0x60(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x77f6
movq -0x68(%rbp), %rax
addq -0x60(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x48(%rbp), %rdi
callq 0x31a0
movq -0x120(%rbp), %rdi
movq -0x118(%rbp), %rsi
movq %rax, %rdx
callq 0x32c0
movq -0x48(%rbp), %rdi
callq 0x31a0
addq -0x60(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rdi
movq -0x68(%rbp), %rsi
addq -0x60(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x101a0
movq -0x20(%rbp), %rax
addq $0x2, %rax
movl $0x3, %ecx
xorl %edx, %edx
divq %rcx
shlq $0x2, %rax
addq -0x60(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x68(%rbp), %rax
addq -0x60(%rbp), %rax
movq %rax, -0x130(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0x50(%rbp), %rdi
callq 0x31a0
movq -0x130(%rbp), %rdi
movq -0x128(%rbp), %rsi
movq %rax, %rdx
callq 0x32c0
movq -0x50(%rbp), %rdi
callq 0x31a0
addq -0x60(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x68(%rbp), %rax
movq -0x60(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x58(%rbp), %rax
cmpq -0x60(%rbp), %rax
jne 0x78d5
jmp 0x78f4
leaq 0x16cf1(%rip), %rdi     # 0x1e5cd
leaq 0x16cf7(%rip), %rsi     # 0x1e5da
movl $0xc0, %edx
leaq 0x16e91(%rip), %rcx     # 0x1e780
callq 0x3240
jmp 0x78f6
movq -0x68(%rbp), %rax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
nopw %cs:(%rax,%rax)