// File: /workspace/github_c_makefile_star2_O3/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 0x2500
callq 0x10c0
jmp 0x250a
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 0x2538
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 0x32ba
testl %eax, %eax
js 0x2644
movb 0x12(%rbx), %sil
movl %esi, %edx
andb $-0x2, %dl
movb %dl, 0x12(%rbx)
movl %ebp, 0x28(%rbx)
movl 0x24(%rbx), %r8d
movq (%rbx), %rdi
movb 0x10(%rbx), %cl
movzbl 0x1(%rdi), %eax
movl 0x4(%rdi), %r9d
leal 0x1(%r8), %r10d
addl $0x2, %r8d
movl $0xffffffff, %r11d      # imm = 0xFFFFFFFF
shll %cl, %r11d
notl %r11d
testl %r11d, %r8d
cmovnel %r10d, %r8d
movl %eax, %ecx
shll %cl, %r9d
xorl %ecx, %ecx
cmpl %r9d, %r8d
cmovbl %r8d, %ecx
movl %ecx, 0x24(%rbx)
testl %ecx, %ecx
jne 0x25ec
movl 0x14(%rbx), %ecx
movl %ecx, 0x18(%rbx)
movl $0x0, 0x14(%rbx)
incb 0x11(%rbx)
testb $0x8, %sil
je 0x262e
movl 0x30(%rbx), %esi
movl %eax, %ecx
shrl %cl, %esi
callq 0x31cb
movb 0x12(%rbx), %dl
testb $0x2, %dl
je 0x2619
movq (%rbx), %rdi
movl 0x34(%rbx), %esi
movb 0x1(%rdi), %cl
shrl %cl, %esi
callq 0x31cb
movb 0x12(%rbx), %dl
movq $-0x1, 0x2c(%rbx)
movl $0xffffffff, 0x34(%rbx) # imm = 0xFFFFFFFF
andb $-0xf, %dl
movb %dl, 0x12(%rbx)
xorl %eax, %eax
testb $0x4, %dl
jne 0x252f
movl 0x20(%rbx), %ecx
movl %ecx, 0x1c(%rbx)
jmp 0x252f
movl 0xc(%rsp), %esi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x2658
jmp 0x252f