// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %esi, -0x30(%rbp)
movq %rdi, %rbx
movb 0x10(%rdi), %cl
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x38(%rbp)
testl %edx, %edx
jle 0x31d2
movl %edx, %r12d
xorl %r14d, %r14d
movl %r12d, -0x34(%rbp)
movq %rbx, %rdi
callq 0x1958
cmpl $-0x1, %eax
je 0x31e9
movl %eax, %r12d
movq %rbx, %rdi
callq 0x2ca4
movq %rbx, %rdi
movl %r12d, %esi
leaq -0xd0(%rbp), %rdx
leaq -0x2c(%rbp), %rcx
callq 0x18d2
testl %eax, %eax
jns 0x3108
movl -0x2c(%rbp), %esi
leaq 0x162d(%rip), %rdi      # 0x4730
callq 0x2c45
movq %rbx, %rdi
callq 0x2ca4
movq %rbx, %rdi
callq 0x19fb
movl -0xd0(%rbp), %r13d
cmpl $-0x1, %r13d
je 0x319f
movq (%rbx), %rax
movb (%rax), %cl
movl $0x1, %eax
shlq %cl, %rax
movq %rsp, -0x40(%rbp)
leaq 0xf(%rax), %rcx
andq $-0x10, %rcx
movq %rsp, %r15
subq %rcx, %r15
movq %r15, %rsp
cmpl -0x30(%rbp), %r13d
jne 0x3208
movq (%rbx), %rdi
movslq %eax, %r14
movl %r12d, %esi
xorl %edx, %edx
movq %r14, %rcx
movq %r15, %r8
leaq -0x2c(%rbp), %r9
callq 0x2801
testl %eax, %eax
jns 0x317e
movl -0x2c(%rbp), %esi
leaq 0x1658(%rip), %rdi      # 0x47d1
callq 0x2c45
incl -0x30(%rbp)
movl -0x34(%rbp), %r12d
decl %r12d
movl %r13d, %edi
movq %r15, %rsi
movq %r14, %rdx
callq 0x2bdf
xorl %r14d, %r14d
movq -0x40(%rbp), %rsp
jmp 0x31ac
incl %r14d
cmpl -0x38(%rbp), %r14d
movl -0x34(%rbp), %r12d
jge 0x3227
cmpl $0x1, %r12d
jne 0x31c9
movl 0x20(%rbx), %edx
movl 0x24(%rbx), %esi
movl 0x28(%rbx), %ecx
leaq 0x1619(%rip), %rdi      # 0x47db
xorl %eax, %eax
callq 0x1070
testl %r12d, %r12d
jg 0x30bf
movq %rbx, %rdi
callq 0x2ca4
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1567(%rip), %rdi      # 0x4757
leaq 0x145b(%rip), %rsi      # 0x4652
leaq 0x1571(%rip), %rcx      # 0x476f
movl $0xb0, %edx
callq 0x1080
leaq 0x15b7(%rip), %rdi      # 0x47c6
leaq 0x143c(%rip), %rsi      # 0x4652
leaq 0x1552(%rip), %rcx      # 0x476f
movl $0xc1, %edx
callq 0x1080
leaq 0x157c(%rip), %rdi      # 0x47aa
leaq 0x141d(%rip), %rsi      # 0x4652
leaq 0x1533(%rip), %rcx      # 0x476f
movl $0xbc, %edx
callq 0x1080