// File: /workspace/github_c_makefile_star2_O0/dlbeer[P]dhara/dhara/journal.c
// Function: push_meta
static int push_meta(struct dhara_journal *j, const uint8_t *meta,
		     dhara_error_t *err)
{
	const dhara_page_t old_head = j->head;
	dhara_error_t my_err;
	const size_t offset =
		hdr_user_offset(j->head & ((1 << j->log2_ppc) - 1));

	/* We've just written a user page. Add the metadata to the
	 * buffer.
	 */
	if (meta)
		memcpy(j->page_buf + offset, meta, DHARA_META_SIZE);
	else
		memset(j->page_buf + offset, 0xff, DHARA_META_SIZE);

	/* Unless we've filled the buffer, don't do any IO */
	if (!is_aligned(j->head + 2, j->log2_ppc)) {
		j->root = j->head;
		j->head++;
		return 0;
	}

	/* We don't need to check for immediate recover, because that'll
	 * never happen -- we're not block-aligned.
	 */
	hdr_put_magic(j->page_buf);
	hdr_set_epoch(j->page_buf, j->epoch);
	hdr_set_tail(j->page_buf, j->tail);
	hdr_set_bb_current(j->page_buf, j->bb_current);
	hdr_set_bb_last(j->page_buf, j->bb_last);

	if (dhara_nand_prog(j->nand, j->head + 1, j->page_buf, &my_err) < 0)
		return recover_from(j, my_err, err);

	j->flags &= ~DHARA_JOURNAL_F_DIRTY;

	j->root = old_head;
	j->head = next_upage(j, j->head);

	if (!j->head)
		roll_stats(j);

	if (j->flags & DHARA_JOURNAL_F_ENUM_DONE)
		finish_recovery(j);

	if (!(j->flags & DHARA_JOURNAL_F_RECOVERY))
		j->tail_sync = j->tail;

	return 0;
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x28(%rsp)
movq %rsi, 0x20(%rsp)
movq %rdx, 0x18(%rsp)
movq 0x28(%rsp), %rax
movl 0x24(%rax), %eax
movl %eax, 0x14(%rsp)
movq 0x28(%rsp), %rax
movl 0x24(%rax), %eax
movq 0x28(%rsp), %rcx
movzbl 0x10(%rcx), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
subl $0x1, %ecx
andl %ecx, %eax
movzbl %al, %edi
callq 0x3100
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x20(%rsp)
je 0x3792
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rdi
addq 0x8(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl $0x84, %edx
callq 0x10a0
jmp 0x37af
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rdi
addq 0x8(%rsp), %rdi
movl $0xff, %esi
movl $0x84, %edx
callq 0x1070
movq 0x28(%rsp), %rax
movl 0x24(%rax), %edi
addl $0x2, %edi
movq 0x28(%rsp), %rax
movzbl 0x10(%rax), %esi
callq 0x3280
cmpl $0x0, %eax
jne 0x37f8
movq 0x28(%rsp), %rax
movl 0x24(%rax), %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0x28(%rax)
movq 0x28(%rsp), %rax
movl 0x24(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x24(%rax)
movl $0x0, 0x34(%rsp)
jmp 0x3936
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x3e80
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x28(%rsp), %rax
movzbl 0x11(%rax), %esi
callq 0x3ea0
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x28(%rsp), %rax
movl 0x20(%rax), %esi
callq 0x3ec0
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x28(%rsp), %rax
movl 0x14(%rax), %esi
callq 0x3ef0
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x28(%rsp), %rax
movl 0x18(%rax), %esi
callq 0x3f20
movq 0x28(%rsp), %rax
movq (%rax), %rdi
movq 0x28(%rsp), %rax
movl 0x24(%rax), %esi
addl $0x1, %esi
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rdx
leaq 0x10(%rsp), %rcx
callq 0x5050
cmpl $0x0, %eax
jge 0x38a6
movq 0x28(%rsp), %rdi
movl 0x10(%rsp), %esi
movq 0x18(%rsp), %rdx
callq 0x3940
movl %eax, 0x34(%rsp)
jmp 0x3936
movq 0x28(%rsp), %rax
movzbl 0x12(%rax), %ecx
andl $-0x2, %ecx
movb %cl, 0x12(%rax)
movl 0x14(%rsp), %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0x28(%rax)
movq 0x28(%rsp), %rdi
movq 0x28(%rsp), %rax
movl 0x24(%rax), %esi
callq 0x33c0
movl %eax, %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0x24(%rax)
movq 0x28(%rsp), %rax
cmpl $0x0, 0x24(%rax)
jne 0x38f2
movq 0x28(%rsp), %rdi
callq 0x3da0
movq 0x28(%rsp), %rax
movzbl 0x12(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x390d
movq 0x28(%rsp), %rdi
callq 0x3f50
movq 0x28(%rsp), %rax
movzbl 0x12(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x392e
movq 0x28(%rsp), %rax
movl 0x20(%rax), %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0x1c(%rax)
movl $0x0, 0x34(%rsp)
movl 0x34(%rsp), %eax
addq $0x38, %rsp
retq
nop