// File: /workspace/github_c_makefile_star2_O1/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:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdx, %r14
movq %rdi, %rbx
movl 0x24(%rdi), %ebp
movb 0x10(%rdi), %cl
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
shll %cl, %eax
notl %eax
andl %ebp, %eax
movzbl %al, %eax
movl %eax, %ecx
shll $0x7, %ecx
leal (%rcx,%rax,4), %eax
movq 0x8(%rdi), %rcx
leaq (%rcx,%rax), %rdi
addq $0x14, %rdi
movl $0x84, %edx
testq %rsi, %rsi
je 0x25b0
callq 0x10c0
jmp 0x25ba
movl $0xff, %esi
callq 0x1090
movl 0x24(%rbx), %eax
movb 0x10(%rbx), %cl
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
shll %cl, %edx
movl $0x7ffffffd, %ecx       # imm = 0x7FFFFFFD
subl %eax, %ecx
orl %edx, %ecx
cmpl $-0x1, %ecx
je 0x25e8
movl %eax, 0x28(%rbx)
incl %eax
movl %eax, 0x24(%rbx)
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq 0x8(%rbx), %rax
movw $0x6844, (%rax)         # imm = 0x6844
movb $0x61, 0x2(%rax)
movq 0x8(%rbx), %rax
movb 0x11(%rbx), %cl
movb %cl, 0x3(%rax)
movq 0x8(%rbx), %rax
movl 0x20(%rbx), %ecx
movl %ecx, 0x4(%rax)
movq 0x8(%rbx), %rax
movl 0x14(%rbx), %ecx
movl %ecx, 0x8(%rax)
movq 0x8(%rbx), %rax
movl 0x18(%rbx), %ecx
movl %ecx, 0xc(%rax)
movl 0x24(%rbx), %esi
incl %esi
movq (%rbx), %rdi
movq 0x8(%rbx), %rdx
leaq 0xc(%rsp), %rcx
callq 0x335f
testl %eax, %eax
js 0x26df
movb 0x12(%rbx), %al
movl %eax, %ecx
andb $-0x2, %cl
movb %cl, 0x12(%rbx)
movl %ebp, 0x28(%rbx)
movl 0x24(%rbx), %edx
leal 0x1(%rdx), %esi
addl $0x2, %edx
movb 0x10(%rbx), %cl
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
shll %cl, %edi
notl %edi
testl %edi, %edx
cmovnel %esi, %edx
movq (%rbx), %rdi
movl 0x4(%rdi), %esi
movzbl 0x1(%rdi), %ecx
shll %cl, %esi
xorl %r8d, %r8d
cmpl %esi, %edx
cmovbl %edx, %r8d
movl %r8d, 0x24(%rbx)
testl %r8d, %r8d
jne 0x2691
movl 0x14(%rbx), %edx
movl %edx, 0x18(%rbx)
movl $0x0, 0x14(%rbx)
incb 0x11(%rbx)
testb $0x8, %al
je 0x26c8
movl 0x30(%rbx), %esi
shrl %cl, %esi
callq 0x326f
testb $0x2, 0x12(%rbx)
je 0x26b5
movq (%rbx), %rdi
movl 0x34(%rbx), %esi
movb 0x1(%rdi), %cl
shrl %cl, %esi
callq 0x326f
movq $-0x1, 0x2c(%rbx)
movl $0xffffffff, 0x34(%rbx) # imm = 0xFFFFFFFF
andb $-0xf, 0x12(%rbx)
xorl %eax, %eax
testb $0x4, 0x12(%rbx)
jne 0x25df
movl 0x20(%rbx), %ecx
movl %ecx, 0x1c(%rbx)
jmp 0x25df
movl 0xc(%rsp), %esi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x26f3
jmp 0x25df