// File: /workspace/github_c_makefile_star2_O2/dlbeer[P]dhara/dhara/journal.c
// Function: recover_from
static int recover_from(struct dhara_journal *j,
			dhara_error_t write_err,
			dhara_error_t *err)
{
	const dhara_page_t old_head = j->head;

	if (write_err != DHARA_E_BAD_BLOCK) {
		dhara_set_error(err, write_err);
		return -1;
	}

	/* Advance to the next free page */
	j->bb_current++;
	if (skip_block(j, err) < 0)
		return -1;

	/* Are we already in the middle of a recovery? */
	if (dhara_journal_in_recovery(j)) {
		restart_recovery(j, old_head);
		dhara_set_error(err, DHARA_E_RECOVER);
		return -1;
	}

	/* Were we block aligned? No recovery required! */
	if (is_aligned(old_head, j->nand->log2_ppb)) {
		dhara_nand_mark_bad(j->nand, old_head >> j->nand->log2_ppb);
		return 0;
	}

	j->recover_root = j->root;
	j->recover_next =
		j->recover_root & ~((1 << j->nand->log2_ppb) - 1);

	/* Are we holding buffered metadata? Dump it first. */
	if (!is_aligned(old_head, j->log2_ppc) &&
	    dump_meta(j, err) < 0)
		return -1;

	j->flags |= DHARA_JOURNAL_F_RECOVERY;
	dhara_set_error(err, DHARA_E_RECOVER);
	return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdx, %r14
cmpl $0x1, %esi
jne 0x245c
movq %rdi, %r15
movl 0x24(%rdi), %ebp
incl 0x14(%rdi)
movq %r14, %rsi
callq 0x2686
pushq $-0x1
popq %rbx
testl %eax, %eax
js 0x2543
movb 0x12(%r15), %al
testb $0x4, %al
jne 0x2470
movq (%r15), %rdi
movzbl 0x1(%rdi), %ecx
movl %ebx, %edx
shll %cl, %edx
movl %edx, %esi
notl %esi
testl %esi, %ebp
je 0x249e
movl 0x28(%r15), %ecx
movl %ecx, 0x30(%r15)
andl %ecx, %edx
movl %edx, 0x2c(%r15)
movb 0x10(%r15), %cl
movl %ebx, %edx
shll %cl, %edx
notl %edx
testl %edx, %ebp
je 0x2531
pushq $0x9
popq %rbp
leaq 0xc(%rsp), %r12
decl %ebp
je 0x24ca
movq %r15, %rdi
movq %r12, %rsi
callq 0x214a
testl %eax, %eax
jne 0x2426
movl 0x24(%r15), %esi
movq (%r15), %rdi
movq 0x8(%r15), %rdx
movq %r12, %rcx
callq 0x2f9d
testl %eax, %eax
je 0x24e2
movl 0xc(%rsp), %eax
cmpl $0x1, %eax
jne 0x24d8
incl 0x14(%r15)
movq (%r15), %rdi
movl 0x24(%r15), %esi
movb 0x1(%rdi), %cl
shrl %cl, %esi
callq 0x2e52
movq %r15, %rdi
movq %r14, %rsi
callq 0x2686
testl %eax, %eax
jns 0x23f4
jmp 0x2543
pushq $-0x1
popq %rbx
testq %r14, %r14
je 0x2543
movl %esi, (%r14)
jmp 0x2543
movl 0x34(%r15), %edx
movq (%r15), %rdi
movzbl 0x1(%rdi), %ecx
cmpl $-0x1, %edx
je 0x2488
xorl %ebp, %edx
shrl %cl, %edx
testl %edx, %edx
je 0x24ae
shrl %cl, %ebp
movl %ebp, %esi
callq 0x2e52
movb 0x12(%r15), %al
movq (%r15), %rcx
movzbl 0x1(%rcx), %ecx
jmp 0x24b0
shrl %cl, %ebp
movl %ebp, %esi
callq 0x2e52
xorl %ebx, %ebx
jmp 0x2543
orb $0x2, %al
andb $-0x9, %al
movb %al, 0x12(%r15)
movl 0x30(%r15), %eax
movl %eax, %edx
shrl %cl, %edx
shll %cl, %edx
movl %edx, 0x2c(%r15)
movl %eax, 0x28(%r15)
jmp 0x2537
testq %r14, %r14
je 0x2543
movl $0x3, (%r14)
jmp 0x2543
testq %r14, %r14
je 0x2543
movl %eax, (%r14)
jmp 0x2543
movl 0x24(%r15), %esi
movl %esi, 0x34(%r15)
movq %r15, %rdi
callq 0x2053
movl %eax, 0x24(%r15)
testl %eax, %eax
jne 0x250b
movl 0x14(%r15), %eax
movl %eax, 0x18(%r15)
andl $0x0, 0x14(%r15)
incb 0x11(%r15)
movq (%r15), %rax
movb (%rax), %cl
pushq $0x1
popq %rax
shll %cl, %eax
movq 0x8(%r15), %rdi
addq $0x14, %rdi
addl $-0x14, %eax
movslq %eax, %rdx
movl $0xff, %esi
callq 0x1090
movb 0x12(%r15), %al
orb $0x4, %al
movb %al, 0x12(%r15)
testq %r14, %r14
je 0x2543
movl $0x4, (%r14)
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq