// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/lbs-dynamodb/metadata.c
// Function: callback_readmetadata
static int
callback_readmetadata(void * cookie, int status,
    const uint8_t * buf, size_t len)
{
	struct metadata * M = cookie;
	uint8_t nbuf[104];

	/* Failures are bad. */
	if (status == 1)
		goto err0;

	/* Did the item exist? */
	if (status == 2) {
		warnp("metadata table is not initialized");
		goto err0;
	}

	/* We should have 104 bytes. */
	if (len != 104) {
		warn0("metadata has incorrect size: %zu", len);
		goto err0;
	}

	/* Parse it. */
	M->M_stored.nextblk = be64dec(&buf[0]);
	M->M_stored.deletedto = be64dec(&buf[8]);
	M->M_stored.generation = be64dec(&buf[16]);
	M->M_stored.lastblk = be64dec(&buf[24]);
	M->itemsz = be64dec(&buf[64]);
	memcpy(M->tableid, &buf[72], 32);

	/* Generate a random process ID. */
	if (entropy_read(M->process_id, 32)) {
		warn0("Failed to generate random process ID");
		goto err0;
	}

	/* Write new metadata back. */
	memcpy(nbuf, buf, 104);
	memcpy(&nbuf[32], M->process_id, 32);
	if (proto_dynamodb_kv_request_icas(M->Q, "metadata", buf, 104,
	    nbuf, 104, callback_claimmetadata, M))
		goto err0;

	/* Success! */
	return (0);

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpl $0x1, -0x14(%rbp)
jne 0x4d2d
jmp 0x4f0f
cmpl $0x2, -0x14(%rbp)
jne 0x4d6f
jmp 0x4d35
callq 0x20a0
cmpl $0x0, (%rax)
je 0x4d5a
leaq 0xec8c(%rip), %rdi      # 0x139d2
movb $0x0, %al
callq 0xd010
callq 0x20a0
movl $0x0, (%rax)
jmp 0x4d68
leaq 0xec71(%rip), %rdi      # 0x139d2
movb $0x0, %al
callq 0xd260
jmp 0x4d6a
jmp 0x4f0f
cmpq $0x68, -0x28(%rbp)
je 0x4d9a
jmp 0x4d78
movq -0x28(%rbp), %rsi
leaq 0xec71(%rip), %rdi      # 0x139f4
movb $0x0, %al
callq 0xd260
callq 0x20a0
movl $0x0, (%rax)
jmp 0x4f0f
movq -0x20(%rbp), %rdi
callq 0x5470
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rdi
addq $0x8, %rdi
callq 0x5470
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rdi
addq $0x10, %rdi
callq 0x5470
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rdi
addq $0x18, %rdi
callq 0x5470
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x20(%rbp), %rdi
addq $0x40, %rdi
callq 0x5470
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0xd8(%rax)
movq -0x30(%rbp), %rax
movq -0x20(%rbp), %rcx
movq 0x48(%rcx), %rdx
movq %rdx, 0xe0(%rax)
movq 0x50(%rcx), %rdx
movq %rdx, 0xe8(%rax)
movq 0x58(%rcx), %rdx
movq %rdx, 0xf0(%rax)
movq 0x60(%rcx), %rcx
movq %rcx, 0xf8(%rax)
movq -0x30(%rbp), %rdi
addq $0x98, %rdi
movl $0x20, %esi
callq 0x9b10
cmpl $0x0, %eax
je 0x4e7f
jmp 0x4e61
leaq 0xebad(%rip), %rdi      # 0x13a15
movb $0x0, %al
callq 0xd260
callq 0x20a0
movl $0x0, (%rax)
jmp 0x4f0f
leaq -0xa0(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl $0x68, %edx
callq 0x2260
movq -0x30(%rbp), %rax
movq 0x98(%rax), %rcx
movq %rcx, -0x80(%rbp)
movq 0xa0(%rax), %rcx
movq %rcx, -0x78(%rbp)
movq 0xa8(%rax), %rcx
movq %rcx, -0x70(%rbp)
movq 0xb0(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
leaq -0xa0(%rbp), %r8
movq -0x30(%rbp), %rax
leaq 0xe9a7(%rip), %rsi      # 0x13888
movl $0x68, %r9d
leaq 0x612(%rip), %r10       # 0x5500
movq %r9, %rcx
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0xd820
cmpl $0x0, %eax
je 0x4f06
jmp 0x4f0f
movl $0x0, -0x4(%rbp)
jmp 0x4f16
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)