// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/liball/../lib/dynamodb/dynamodb_kv.c
// Function: dynamodb_kv_icas
char *
dynamodb_kv_icas(const char * table, const char * key,
    const uint8_t * buf, size_t len, const uint8_t * buf2, size_t len2)
{
	/**
	 * An ICAS is a PutItem request with a body (with spaces added) of:
	 * { "TableName": "TABLE",
	 *   "Item": {
	 *     "K": { "S": "KEY" },
	 *     "V": { "B": "BASE64NEW" }
	 *   },
	 *   "ConditionExpression": "(V = :old) OR (V = :new)",
	 *   "ExpressionAttributeValues": {
	 *       ":old": { "B": "BASE64OLD" },
	 *       ":new": { "B": "BASE64NEW" }
	 *   },
	 *   "ReturnConsumedCapacity": "TOTAL"
	 * }
	 */
	const char * s1 = "{\"TableName\":\"";
	const char * s2 = "\",\"Item\":{\"K\":{\"S\":\"";
	const char * s3 = "\"},\"V\":{\"B\":\"";
	const char * s4 = "\"}},\"ConditionExpression\":\"(V=:old)OR(V=:new)\",";
	const char * s5 = "\"ExpressionAttributeValues\":{\":old\":{\"B\":\"";
	const char * s6 = "\"},\":new\":{\"B\":\"";
	const char * s7 = "\"}},\"ReturnConsumedCapacity\":\"TOTAL\"}";
	size_t slen = strlen(s1) + strlen(table) + strlen(s2) + strlen(key) +
	    strlen(s3) + b64len(len2) + strlen(s4) + strlen(s5) +
	    b64len(len) + strlen(s6) + b64len(len2) + strlen(s7);
	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(buf2, &s[spos], len2);
	spos += b64len(len2);
	COPYANDINCR(s, spos, s4);
	COPYANDINCR(s, spos, s5);
	b64encode(buf, &s[spos], len);
	spos += b64len(len);
	COPYANDINCR(s, spos, s6);
	b64encode(buf2, &s[spos], len2);
	spos += b64len(len2);
	COPYANDINCR(s, spos, s7);
	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 $0x28, %rsp
movq %r9, %r15
movq %r8, (%rsp)
movq %rcx, %r13
movq %rdx, 0x8(%rsp)
movq %rsi, %r14
movq %rdi, %r12
callq 0x3190
movq %rax, %rbx
movq %r14, %rdi
callq 0x3190
movq %rax, %rcx
movq %r15, 0x20(%rsp)
leaq 0x2(%r15), %rax
movabsq $-0x5555555555555555, %rsi # imm = 0xAAAAAAAAAAAAAAAB
mulq %rsi
movq %rdx, %r15
addq %rbx, %rcx
addq $0x22, %rcx
shrq %r15
movq %r13, 0x10(%rsp)
leaq 0x2(%r13), %rax
mulq %rsi
movq %rdx, %r13
addq %rdx, %r13
andq $-0x4, %r13
leaq (,%r15,8), %rax
addq %r13, %rax
movq %rcx, 0x18(%rsp)
leaq (%rax,%rcx), %rdi
addq $0x9c, %rdi
callq 0x34c0
movq %rax, %rbp
testq %rax, %rax
je 0x5d79
movabsq $0x223a22656d614e65, %rax # imm = 0x223A22656D614E65
movq %rax, 0x6(%rbp)
movabsq $0x4e656c626154227b, %rax # imm = 0x4E656C626154227B
movq %rax, (%rbp)
leaq 0xe(%rbp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x3280
movq %r12, %rdi
callq 0x3190
movq %rax, %rbx
movups 0xb979(%rip), %xmm0     # 0x115b4
movups %xmm0, 0xe(%rbp,%rax)
movl $0x223a2253, 0x1e(%rbp,%rax) # imm = 0x223A2253
leaq (%rax,%rbp), %r12
addq $0x22, %r12
movq %r14, %rdi
callq 0x3190
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x3280
movq %r14, %rdi
callq 0x3190
addq %rax, %rbx
addq $0x22, %rbx
movabsq $0x7b3a2256222c7d22, %rax # imm = 0x7B3A2256222C7D22
movq %rax, (%rbp,%rbx)
movabsq $0x223a2242227b3a22, %rax # imm = 0x223A2242227B3A22
movq %rax, 0x5(%rbp,%rbx)
leaq 0xd(%rbp,%rbx), %rsi
movq (%rsp), %rdi
movq 0x20(%rsp), %r12
movq %r12, %rdx
callq 0xb29c
leaq (%rbx,%r15,4), %r14
addq $0xd, %r14
movups 0xb9da(%rip), %xmm0     # 0x11692
movups %xmm0, 0x1f(%rbp,%r14)
movups 0xb9be(%rip), %xmm0     # 0x11683
movups %xmm0, 0x10(%rbp,%r14)
movups 0xb9a1(%rip), %xmm0     # 0x11673
movups %xmm0, (%rbp,%r14)
movups 0xb9c4(%rip), %xmm0     # 0x116a3
movups %xmm0, 0x2f(%rbp,%r14)
movups 0xb9c7(%rip), %xmm0     # 0x116b3
movups %xmm0, 0x3f(%rbp,%r14)
movups 0xb9c4(%rip), %xmm0     # 0x116bd
movups %xmm0, 0x49(%rbp,%r14)
leaq (%r14,%rbp), %rsi
addq $0x59, %rsi
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rdx
callq 0xb29c
leaq (%r14,%r13), %rax
addq $0x59, %rax
leaq (%rbp,%rax), %r14
movups 0xb9a4(%rip), %xmm0     # 0x116ce
movups %xmm0, (%rbp,%rax)
leaq (%rax,%rbp), %rsi
addq $0x10, %rsi
movq (%rsp), %rdi
movq %r12, %rdx
callq 0xb29c
movabsq $0x7d224c41544f5422, %rax # imm = 0x7D224C41544F5422
movq %rax, 0x2d(%r14,%r15,4)
movups 0xb88e(%rip), %xmm0     # 0x115e7
movups %xmm0, 0x20(%r14,%r15,4)
movups 0xb871(%rip), %xmm0     # 0x115d7
movups %xmm0, 0x10(%r14,%r15,4)
movb $0x0, 0x35(%r14,%r15,4)
cmpq %rbx, 0x18(%rsp)
jne 0x5d8b
movq %rbp, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb86b(%rip), %rdi      # 0x115fd
leaq 0xb871(%rip), %rsi      # 0x1160a
leaq 0xb93f(%rip), %rcx      # 0x116df
movl $0x81, %edx
callq 0x3200