// File: /workspace/github_c_makefile_star2_O0/dlbeer[P]dhara/tests/jtutil.c
// Function: jt_dequeue_sequence
void jt_dequeue_sequence(struct dhara_journal *j, int next, int count)
{
	const int max_garbage = 1 << j->log2_ppc;
	int garbage_count = 0;

	while (count > 0) {
		uint8_t meta[DHARA_META_SIZE];
		uint32_t id;
		dhara_page_t tail = dhara_journal_peek(j);
		dhara_error_t err;

		assert(tail != DHARA_PAGE_NONE);

		jt_check(j);
		if (dhara_journal_read_meta(j, tail, meta, &err) < 0)
			dabort("read_meta", err);

		jt_check(j);
		dhara_journal_dequeue(j);
		id = dhara_r32(meta);

		if (id == 0xffffffff) {
			garbage_count++;
			assert(garbage_count < max_garbage);
		} else {
			const int page_size = 1 << j->nand->log2_page_size;
			uint8_t r[page_size];

			assert(id == next);
			garbage_count = 0;
			next++;
			count--;

			if (dhara_nand_read(j->nand, tail, 0,
					    page_size, r, &err) < 0)
				dabort("nand_read", err);

			seq_assert(id, r, page_size);
		}

		if (count == 1)
			printf("head=%d, tail=%d, root=%d\n",
				j->head, j->tail, j->root);
	}

	jt_check(j);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rax
movzbl 0x10(%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
cmpl $0x0, -0x10(%rbp)
jle 0x4932
movq -0x8(%rbp), %rdi
callq 0x1ee0
movl %eax, -0xa8(%rbp)
cmpl $-0x1, -0xa8(%rbp)
je 0x4752
jmp 0x4771
leaq 0xfd0(%rip), %rdi       # 0x5729
leaq 0xec4(%rip), %rsi       # 0x5624
movl $0xb0, %edx
leaq 0xfd5(%rip), %rcx       # 0x5741
callq 0x1060
movq -0x8(%rbp), %rdi
callq 0x41c0
movq -0x8(%rbp), %rdi
movl -0xa8(%rbp), %esi
leaq -0xa0(%rbp), %rdx
leaq -0xac(%rbp), %rcx
callq 0x1d70
cmpl $0x0, %eax
jge 0x47ae
movl -0xac(%rbp), %esi
leaq 0xf59(%rip), %rdi       # 0x5702
callq 0x4110
movq -0x8(%rbp), %rdi
callq 0x41c0
movq -0x8(%rbp), %rdi
callq 0x2070
leaq -0xa0(%rbp), %rdi
callq 0x46c0
movl %eax, -0xa4(%rbp)
cmpl $-0x1, -0xa4(%rbp)
jne 0x4812
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x47ee
jmp 0x480d
leaq 0xf87(%rip), %rdi       # 0x577c
leaq 0xe28(%rip), %rsi       # 0x5624
movl $0xbc, %edx
leaq 0xf39(%rip), %rcx       # 0x5741
callq 0x1060
jmp 0x4904
movq -0x8(%rbp), %rax
movq (%rax), %rax
movb (%rax), %cl
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0xb0(%rbp)
movl -0xb0(%rbp), %eax
movq %rsp, %rcx
movq %rcx, -0xb8(%rbp)
movq %rax, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0xc8(%rbp)
movq %rcx, %rsp
movq %rax, -0xc0(%rbp)
movl -0xa4(%rbp), %eax
cmpl -0xc(%rbp), %eax
jne 0x4867
jmp 0x4886
leaq 0xf2a(%rip), %rdi       # 0x5798
leaq 0xdaf(%rip), %rsi       # 0x5624
movl $0xc1, %edx
leaq 0xec0(%rip), %rcx       # 0x5741
callq 0x1060
movq -0xc8(%rbp), %r8
movl $0x0, -0x18(%rbp)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
movl -0x10(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movl -0xa8(%rbp), %esi
movslq -0xb0(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
leaq -0xac(%rbp), %r9
callq 0x3ab0
cmpl $0x0, %eax
jge 0x48e1
movl -0xac(%rbp), %esi
leaq 0xec7(%rip), %rdi       # 0x57a3
callq 0x4110
movq -0xc8(%rbp), %rsi
movl -0xa4(%rbp), %edi
movslq -0xb0(%rbp), %rdx
callq 0x4060
movq -0xb8(%rbp), %rax
movq %rax, %rsp
cmpl $0x1, -0x10(%rbp)
jne 0x492d
movq -0x8(%rbp), %rax
movl 0x24(%rax), %esi
movq -0x8(%rbp), %rax
movl 0x20(%rax), %edx
movq -0x8(%rbp), %rax
movl 0x28(%rax), %ecx
leaq 0xe87(%rip), %rdi       # 0x57ad
movb $0x0, %al
callq 0x1050
jmp 0x472e
movq -0x8(%rbp), %rdi
callq 0x41c0
movq %rbp, %rsp
popq %rbp
retq