// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/lbs-dynamodb/metadata.c
// Function: metadata_init
struct metadata *
metadata_init(struct wire_requestqueue * Q, uint64_t * itemsz,
    uint8_t * tableid)
{
	struct metadata * M;

	/* Bake a cookie. */
	if ((M = malloc(sizeof(struct metadata))) == NULL)
		goto err0;
	M->Q = Q;

	/* Read metadata and take ownership. */
tryagain:
	M->init_done = 0;
	if (proto_dynamodb_kv_request_getc(Q, "metadata",
	    callback_readmetadata, M)) {
		warnp("Error reading LBS metadata");
		goto err1;
	}
	if (events_spin(&M->init_done)) {
		warnp("Error claiming ownership of LBS metadata");
		goto err1;
	}

	/* Did we lose a race trying to claim the metadata? */
	if (M->init_lostrace) {
		warn0("Lost race claiming metadata; trying again...");
		goto tryagain;
	}

	/* The next metadata will be the same except one higher generation. */
	M->M_latest = M->M_stored;
	M->M_latest.generation++;

	/* Nothing in progress yet. */
	M->M_latest.callback_state = NULL;
	M->M_latest.cookie_state = NULL;
	M->callback_deletedto = NULL;
	M->cookie_deletedto = NULL;
	M->write_inprogress = 0;
	M->write_wanted = 0;

	/* Return the item size and table ID. */
	*itemsz = M->itemsz;
	memcpy(tableid, M->tableid, 32);

	/* Success! */
	return (M);

err1:
	free(M);
err0:
	/* Failure! */
	return (NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x100, %edi            # imm = 0x100
callq 0x2280
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x4b1d
jmp 0x4cea
movq -0x10(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movl $0x0, 0xd0(%rax)
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rcx
leaq 0xed43(%rip), %rsi      # 0x13888
leaq 0x1b4(%rip), %rdx       # 0x4d00
callq 0xe010
cmpl $0x0, %eax
je 0x4b92
jmp 0x4b58
callq 0x20a0
cmpl $0x0, (%rax)
je 0x4b7d
leaq 0xece4(%rip), %rdi      # 0x1384d
movb $0x0, %al
callq 0xd010
callq 0x20a0
movl $0x0, (%rax)
jmp 0x4b8b
leaq 0xecc9(%rip), %rdi      # 0x1384d
movb $0x0, %al
callq 0xd260
jmp 0x4b8d
jmp 0x4ce1
movq -0x28(%rbp), %rdi
addq $0xd0, %rdi
callq 0x5bd0
cmpl $0x0, %eax
je 0x4be3
jmp 0x4ba9
callq 0x20a0
cmpl $0x0, (%rax)
je 0x4bce
leaq 0xecae(%rip), %rdi      # 0x13868
movb $0x0, %al
callq 0xd010
callq 0x20a0
movl $0x0, (%rax)
jmp 0x4bdc
leaq 0xec93(%rip), %rdi      # 0x13868
movb $0x0, %al
callq 0xd260
jmp 0x4bde
jmp 0x4ce1
movq -0x28(%rbp), %rax
cmpl $0x0, 0xd4(%rax)
je 0x4c10
jmp 0x4bf2
leaq 0xec98(%rip), %rdi      # 0x13891
movb $0x0, %al
callq 0xd260
callq 0x20a0
movl $0x0, (%rax)
jmp 0x4b28
movq -0x28(%rbp), %rdi
addq $0x68, %rdi
movq -0x28(%rbp), %rsi
addq $0x8, %rsi
movl $0x30, %edx
callq 0x2260
movq -0x28(%rbp), %rax
movq 0x78(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x78(%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0x88(%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0x90(%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0xb8(%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0xc0(%rax)
movq -0x28(%rbp), %rax
movl $0x0, 0xc8(%rax)
movq -0x28(%rbp), %rax
movl $0x0, 0xcc(%rax)
movq -0x28(%rbp), %rax
movq 0xd8(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rcx
movq 0xe0(%rcx), %rdx
movq %rdx, (%rax)
movq 0xe8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0xf0(%rcx), %rdx
movq %rdx, 0x10(%rax)
movq 0xf8(%rcx), %rcx
movq %rcx, 0x18(%rax)
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x4cf2
movq -0x28(%rbp), %rdi
callq 0x2040
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)