// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/lbs-dynamodb/metadata.c
// Function: writemetadata
static int
writemetadata(struct metadata * M)
{
	uint8_t obuf[104];
	uint8_t buf[104];

	/* Is a write already in progress? */
	if (M->write_inprogress == 1) {
		M->write_wanted = 1;
		return (0);
	}

	/* We're going to start a write now. */
	M->write_inprogress = 1;
	M->write_wanted = 0;

	/* We're going to store the latest metadata values. */
	M->M_storing = M->M_latest;

	/* The requested callback will be performed when the store completes. */
	M->M_latest.callback_state = NULL;

	/* Increment metadata generation for the next metadata stored. */
	M->M_latest.generation++;

	/* Encode metadata. */
	be64enc(&obuf[0], M->M_stored.nextblk);
	be64enc(&obuf[8], M->M_stored.deletedto);
	be64enc(&obuf[16], M->M_stored.generation);
	be64enc(&obuf[24], M->M_stored.lastblk);
	memcpy(&obuf[32], M->process_id, 32);
	be64enc(&obuf[64], M->itemsz);
	memcpy(&obuf[72], M->tableid, 32);
	be64enc(&buf[0], M->M_storing.nextblk);
	be64enc(&buf[8], M->M_storing.deletedto);
	be64enc(&buf[16], M->M_storing.generation);
	be64enc(&buf[24], M->M_storing.lastblk);
	memcpy(&buf[32], M->process_id, 32);
	be64enc(&buf[64], M->itemsz);
	memcpy(&buf[72], M->tableid, 32);

	/* Write metadata. */
	if (proto_dynamodb_kv_request_icas(M->Q, "metadata", obuf, 104,
	    buf, 104, callback_writemetadata, M))
		goto err0;

	/* Success! */
	return (0);

err0:
	/* Failure! */
	return (-1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x1, 0xc8(%rax)
jne 0x5026
movq -0x10(%rbp), %rax
movl $0x1, 0xcc(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x5284
movq -0x10(%rbp), %rax
movl $0x1, 0xc8(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0xcc(%rax)
movq -0x10(%rbp), %rdi
addq $0x38, %rdi
movq -0x10(%rbp), %rsi
addq $0x68, %rsi
movl $0x30, %edx
callq 0x2260
movq -0x10(%rbp), %rax
movq $0x0, 0x88(%rax)
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x78(%rax)
leaq -0x80(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x55a0
leaq -0x80(%rbp), %rdi
addq $0x8, %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x55a0
leaq -0x80(%rbp), %rdi
addq $0x10, %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x55a0
leaq -0x80(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x55a0
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rcx
movq %rcx, -0x60(%rbp)
movq 0xa0(%rax), %rcx
movq %rcx, -0x58(%rbp)
movq 0xa8(%rax), %rcx
movq %rcx, -0x50(%rbp)
movq 0xb0(%rax), %rax
movq %rax, -0x48(%rbp)
leaq -0x80(%rbp), %rdi
addq $0x40, %rdi
movq -0x10(%rbp), %rax
movq 0xd8(%rax), %rsi
callq 0x55a0
movq -0x10(%rbp), %rax
movq 0xe0(%rax), %rcx
movq %rcx, -0x38(%rbp)
movq 0xe8(%rax), %rcx
movq %rcx, -0x30(%rbp)
movq 0xf0(%rax), %rcx
movq %rcx, -0x28(%rbp)
movq 0xf8(%rax), %rax
movq %rax, -0x20(%rbp)
leaq -0xf0(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rsi
callq 0x55a0
leaq -0xf0(%rbp), %rdi
addq $0x8, %rdi
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rsi
callq 0x55a0
leaq -0xf0(%rbp), %rdi
addq $0x10, %rdi
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rsi
callq 0x55a0
leaq -0xf0(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rsi
callq 0x55a0
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rcx
movq %rcx, -0xd0(%rbp)
movq 0xa0(%rax), %rcx
movq %rcx, -0xc8(%rbp)
movq 0xa8(%rax), %rcx
movq %rcx, -0xc0(%rbp)
movq 0xb0(%rax), %rax
movq %rax, -0xb8(%rbp)
leaq -0xf0(%rbp), %rdi
addq $0x40, %rdi
movq -0x10(%rbp), %rax
movq 0xd8(%rax), %rsi
callq 0x55a0
movq -0x10(%rbp), %rax
movq 0xe0(%rax), %rcx
movq %rcx, -0xa8(%rbp)
movq 0xe8(%rax), %rcx
movq %rcx, -0xa0(%rbp)
movq 0xf0(%rax), %rcx
movq %rcx, -0x98(%rbp)
movq 0xf8(%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq -0x80(%rbp), %rdx
leaq -0xf0(%rbp), %r8
movq -0x10(%rbp), %rax
leaq 0xe639(%rip), %rsi      # 0x13888
movl $0x68, %r9d
leaq 0x414(%rip), %r10       # 0x5670
movq %r9, %rcx
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0xd820
cmpl $0x0, %eax
je 0x5274
jmp 0x527d
movl $0x0, -0x4(%rbp)
jmp 0x5284
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq