// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/dhara/journal.c
// Function: dhara_journal_resume
int dhara_journal_resume(struct dhara_journal *j, dhara_error_t *err)
{
	dhara_block_t first, last;
	dhara_page_t last_group;

	/* Find the first checkpoint-containing block */
	if (find_checkblock(j, 0, &first, err) < 0) {
		reset_journal(j);
		return -1;
	}

	/* Find the last checkpoint-containing block in this epoch */
	j->epoch = hdr_get_epoch(j->page_buf);
	last = find_last_checkblock(j, first);

	/* Find the last programmed checkpoint group in the block */
	last_group = find_last_group(j, last);

	/* Perform a linear scan to find the last good checkpoint (and
	 * therefore the root).
	 */
	if (find_root(j, last_group, err) < 0) {
		reset_journal(j);
		return -1;
	}

	/* Restore settings from checkpoint */
	j->tail = hdr_get_tail(j->page_buf);
	j->bb_current = hdr_get_bb_current(j->page_buf);
	j->bb_last = hdr_get_bb_last(j->page_buf);
	hdr_clear_user(j->page_buf, j->nand->log2_page_size);

	/* Perform another linear scan to find the next free user page */
	if (find_head(j, last_group, err) < 0) {
		reset_journal(j);
		return -1;
	}

	j->flags = 0;
	j->tail_sync = j->tail;

	clear_recovery(j);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rcx
movq %rdi, %rbx
xorl %ebp, %ebp
leaq 0x14(%rsp), %rdx
xorl %esi, %esi
movq %rcx, 0x8(%rsp)
callq 0x20ef
testl %eax, %eax
js 0x1db7
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
movb 0x3(%rcx), %cl
movb %cl, 0x11(%rbx)
movl 0x14(%rsp), %ecx
movl 0x4(%rax), %r14d
decl %r14d
movl %ecx, (%rsp)
movl %ecx, %r12d
cmpl %r14d, %r12d
ja 0x1ded
leal (%r14,%r12), %r15d
movl %r15d, %ebp
shrl %ebp
movq %rbx, %rdi
movl %ebp, %esi
leaq 0x1c(%rsp), %rdx
xorl %ecx, %ecx
callq 0x20ef
testl %eax, %eax
js 0x1d8d
movq 0x8(%rbx), %rax
movb 0x3(%rax), %al
cmpb 0x11(%rbx), %al
jne 0x1d8d
movl 0x1c(%rsp), %ebp
leal 0x1(%rbp), %esi
movq (%rbx), %rax
cmpl 0x4(%rax), %esi
jae 0x1da6
xorl %r15d, %r15d
movq %rbx, %rdi
leaq 0x18(%rsp), %rdx
xorl %ecx, %ecx
callq 0x20ef
testl %eax, %eax
js 0x1da9
movq 0x8(%rbx), %rax
movb 0x3(%rax), %al
cmpb 0x11(%rbx), %al
jne 0x1da6
movb $0x1, %r15b
movl 0x18(%rsp), %r12d
movl %r13d, %ebp
jmp 0x1da9
cmpl $0x2, %r15d
jae 0x1d9c
xorl %r15d, %r15d
movl (%rsp), %r13d
jmp 0x1dac
decl %ebp
movb $0x1, %r15b
movl %ebp, %r14d
jmp 0x1dac
xorl %r15d, %r15d
movl %ebp, %r13d
testb %r15b, %r15b
jne 0x1d1c
jmp 0x1df1
movb %bpl, 0x11(%rbx)
movq (%rbx), %rax
movq 0x8(%rbx), %rdi
movl 0x4(%rax), %ecx
shrl $0x6, %ecx
movl %ecx, 0x18(%rbx)
movl %ebp, 0x14(%rbx)
movb %bpl, 0x12(%rbx)
movl %ebp, 0x24(%rbx)
movq $0x0, 0x1c(%rbx)
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x28(%rbx)
movb (%rax), %cl
jmp 0x20a3
movl (%rsp), %r13d
movq (%rbx), %rax
movzbl 0x1(%rax), %ecx
subl 0x10(%rbx), %ecx
movl $0x1, %eax
shll %cl, %eax
movq %rax, 0x20(%rsp)
leal -0x1(%rax), %r12d
xorl %r15d, %r15d
movq %rax, (%rsp)
cmpl %r12d, %r15d
jg 0x1e82
leal (%r15,%r12), %r14d
shrl %r14d
movb 0x10(%rbx), %cl
movl %r14d, %eax
shll %cl, %eax
movq (%rbx), %rcx
movb 0x1(%rcx), %cl
movl %r13d, %ebp
shll %cl, %ebp
orl %eax, %ebp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x28e9
testl %eax, %eax
je 0x1e4b
decl %r14d
movb $0x1, %al
movl %r14d, %r12d
jmp 0x1e75
incl %r14d
cmpl 0x20(%rsp), %r14d
jge 0x1e6d
movb 0x10(%rbx), %cl
movl $0x1, %esi
shll %cl, %esi
addl %ebp, %esi
movq %rbx, %rdi
callq 0x28e9
testl %eax, %eax
je 0x1e7b
xorl %eax, %eax
movl %ebp, %ecx
movq %rcx, (%rsp)
testb %al, %al
jne 0x1e12
jmp 0x1e92
movb $0x1, %al
movl %r14d, %r15d
jmp 0x1e75
movq (%rbx), %rax
movb 0x1(%rax), %cl
shll %cl, %r13d
movl %r13d, %eax
movq %rax, (%rsp)
movq (%rbx), %rax
movb 0x1(%rax), %cl
movq (%rsp), %rdx
movl %edx, %ebp
shrl %cl, %ebp
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
shll %cl, %eax
notl %eax
andl %edx, %eax
movb 0x10(%rbx), %cl
shrl %cl, %eax
leaq 0x28(%rbx), %r14
movl %eax, %r15d
testl %eax, %eax
js 0x1f31
movq (%rbx), %rdi
movb 0x1(%rdi), %cl
movl %ebp, %r12d
shll %cl, %r12d
movq 0x8(%rbx), %r8
leal 0x1(%r15), %r13d
movb 0x10(%rbx), %cl
shll %cl, %r13d
movb (%rdi), %cl
leal (%r12,%r13), %esi
decl %esi
movl $0x1, %eax
shll %cl, %eax
movslq %eax, %rcx
xorl %edx, %edx
movq 0x8(%rsp), %r9
callq 0x3495
testl %eax, %eax
jne 0x1f25
movq 0x8(%rbx), %rax
cmpb $0x44, (%rax)
jne 0x1f25
cmpb $0x68, 0x1(%rax)
jne 0x1f25
cmpb $0x61, 0x2(%rax)
jne 0x1f25
movb 0x3(%rax), %al
cmpb 0x11(%rbx), %al
jne 0x1f25
addl %r12d, %r13d
addl $-0x2, %r13d
movl %r13d, (%r14)
xorl %ecx, %ecx
movl %r15d, %eax
jmp 0x1f2b
leal -0x1(%r15), %eax
movb $0x1, %cl
testb %cl, %cl
jne 0x1eb4
jmp 0x1f44
cmpq $0x0, 0x8(%rsp)
je 0x1f44
movq 0x8(%rsp), %rax
movl $0x3, (%rax)
testl %r15d, %r15d
js 0x206f
movq (%rbx), %rax
movq 0x8(%rbx), %rdi
movl 0x4(%rdi), %ecx
movl %ecx, 0x20(%rbx)
movl 0x8(%rdi), %ecx
movl %ecx, 0x14(%rbx)
movl 0xc(%rdi), %ecx
movl %ecx, 0x18(%rbx)
movb (%rax), %cl
movl $0x1, %eax
shll %cl, %eax
addq $0x14, %rdi
addl $-0x14, %eax
movslq %eax, %rdx
movl $0xff, %esi
callq 0x1090
movq (%rsp), %rsi
leal 0x1(%rsi), %eax
addl $0x2, %esi
movb 0x10(%rbx), %cl
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
shll %cl, %edx
notl %edx
testl %edx, %esi
cmovnel %eax, %esi
movq (%rbx), %rax
movl 0x4(%rax), %edx
movb 0x1(%rax), %cl
shll %cl, %edx
xorl %eax, %eax
cmpl %edx, %esi
cmovael %eax, %esi
movl %esi, 0x24(%rbx)
testl %esi, %esi
jne 0x1fc7
movl 0x14(%rbx), %eax
movl %eax, 0x18(%rbx)
movl $0x0, 0x14(%rbx)
incb 0x11(%rbx)
movb 0x10(%rbx), %cl
movl $0x1, %r12d
shll %cl, %r12d
movl %r12d, %r13d
negl %r13d
movl 0x24(%rbx), %eax
andl %r13d, %eax
leal (%rax,%r12), %ebp
decl %ebp
movl %eax, %r15d
addl %r12d, %r15d
xorl %r14d, %r14d
movq (%rbx), %rdi
movl %ebp, %esi
callq 0x3459
testl %eax, %eax
je 0x200c
incl %r14d
decl %ebp
movl %r13d, %eax
addl %r14d, %eax
jne 0x1fee
movl %r12d, %r14d
cmpl $0x2, %r14d
jae 0x20be
movl %r15d, 0x24(%rbx)
movq (%rbx), %rcx
movl 0x4(%rcx), %eax
movzbl 0x1(%rcx), %ecx
movl %eax, %edx
shll %cl, %edx
cmpl %edx, %r15d
jb 0x203e
xorl %esi, %esi
movl %esi, 0x24(%rbx)
movl 0x14(%rbx), %edx
movl %edx, 0x18(%rbx)
movl %esi, 0x14(%rbx)
incb 0x11(%rbx)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
shll %cl, %edx
movl 0x24(%rbx), %esi
notl %edx
testl %edx, %esi
jne 0x1fc7
movl 0x20(%rbx), %edx
xorl %edx, %esi
shrl %cl, %esi
testl %esi, %esi
jne 0x20c5
shrl %cl, %edx
incl %edx
xorl %esi, %esi
cmpl %eax, %edx
cmovbl %edx, %esi
shll %cl, %esi
movl %esi, 0x20(%rbx)
jmp 0x20c5
xorl %eax, %eax
movb %al, 0x11(%rbx)
movq (%rbx), %rcx
movl 0x4(%rcx), %edx
shrl $0x6, %edx
movl %edx, 0x18(%rbx)
movl %eax, 0x14(%rbx)
movb %al, 0x12(%rbx)
movl %eax, 0x24(%rbx)
movq $0x0, 0x1c(%rbx)
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, (%r14)
movb %al, 0x12(%rbx)
movq 0x8(%rbx), %rdi
movb (%rcx), %cl
movl $0x1, %eax
shll %cl, %eax
movslq %eax, %rdx
movl $0xff, %esi
callq 0x1090
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x20e0
subl %r14d, %r15d
movl %r15d, 0x24(%rbx)
movb $0x0, 0x12(%rbx)
movl 0x20(%rbx), %eax
movl %eax, 0x1c(%rbx)
movq $-0x1, 0x2c(%rbx)
movl $0xffffffff, 0x34(%rbx) # imm = 0xFFFFFFFF
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq