// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/lbs-dynamodb/metadata.c
// Function: callback_writemetadata
static int
callback_writemetadata(void * _m, int status)
{
	struct metadata * M = _m;
	int (* callback)(void *);
	void * cookie;
	int rc = 0;
	int rc2;

	/* Sanity-check. */
	assert(M->write_inprogress);

	/* Did we succeed? */
	switch (status) {
	case 0:
		/* Request succeeded. */
		break;
	case 1:
		/* Request failed.  This is bad. */
		warn0("Failed to store metadata to DynamoDB!");
		goto err0;
	case 2:
		/* Another process stole the metadata from us. */
		warn0("Lost ownership of metadata in DynamoDB!");

		/*
		 * We could error out here, but it's safer to just abort;
		 * another process stealing our metadata tells us that we
		 * should not do anything else at all.
		 */
		_exit(0);
	}

	/* We're no longer storing metadata. */
	M->write_inprogress = 0;

	/* The values we were storing have now been stored. */
	M->M_stored = M->M_storing;

	/* Perform callbacks as appropriate. */
	if (M->M_stored.callback_state != NULL) {
		callback = M->M_stored.callback_state;
		cookie = M->M_stored.cookie_state;
		if ((rc2 = (callback)(cookie)) != 0)
			rc = rc2;
	}
	if (M->callback_deletedto != NULL) {
		callback = M->callback_deletedto;
		cookie = M->cookie_deletedto;
		if ((rc2 = (callback)(cookie)) != 0)
			rc = rc2;
	}

	/* Start another write if needed. */
	if (M->write_wanted) {
		if ((rc2 = writemetadata(M)) != 0)
			rc = rc2;
	}

	/* Return status from callbacks or writemetadata. */
	return (rc);

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, 0xc8(%rax)
je 0x569d
jmp 0x56bc
leaq 0xe3bd(%rip), %rdi      # 0x13a61
leaq 0xe236(%rip), %rsi      # 0x138e1
movl $0xc2, %edx
leaq 0xe3be(%rip), %rcx      # 0x13a75
callq 0x21b0
movl -0x14(%rbp), %eax
movl %eax, -0x3c(%rbp)
testl %eax, %eax
je 0x56dc
jmp 0x56c8
movl -0x3c(%rbp), %eax
subl $0x1, %eax
je 0x56de
jmp 0x56d2
movl -0x3c(%rbp), %eax
subl $0x2, %eax
je 0x56fe
jmp 0x5720
jmp 0x5720
jmp 0x56e0
leaq 0xe3b6(%rip), %rdi      # 0x13a9d
movb $0x0, %al
callq 0xd260
callq 0x20a0
movl $0x0, (%rax)
jmp 0x57f9
jmp 0x5700
leaq 0xe3bc(%rip), %rdi      # 0x13ac3
movb $0x0, %al
callq 0xd260
callq 0x20a0
movl $0x0, (%rax)
xorl %edi, %edi
callq 0x20c0
movq -0x20(%rbp), %rax
movl $0x0, 0xc8(%rax)
movq -0x20(%rbp), %rdi
addq $0x8, %rdi
movq -0x20(%rbp), %rsi
addq $0x38, %rsi
movl $0x30, %edx
callq 0x2260
movq -0x20(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x5785
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq -0x30(%rbp), %rdi
callq *%rax
movl %eax, -0x38(%rbp)
cmpl $0x0, %eax
je 0x5783
movl -0x38(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x5785
movq -0x20(%rbp), %rax
cmpq $0x0, 0xb8(%rax)
je 0x57cb
movq -0x20(%rbp), %rax
movq 0xb8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0xc0(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq -0x30(%rbp), %rdi
callq *%rax
movl %eax, -0x38(%rbp)
cmpl $0x0, %eax
je 0x57c9
movl -0x38(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x57cb
movq -0x20(%rbp), %rax
cmpl $0x0, 0xcc(%rax)
je 0x57f1
movq -0x20(%rbp), %rdi
callq 0x4ff0
movl %eax, -0x38(%rbp)
cmpl $0x0, %eax
je 0x57ef
movl -0x38(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x57f1
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5800
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)