// File: /workspace/github_c_makefile_star2_O3/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
movq %rsi, -0x38(%rbp)
movq %rdi, %rbx
movb 0x10(%rdi), %cl
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x3c(%rbp)
testl %edx, %edx
jle 0x317f
movl %edx, %r14d
xorl %r15d, %r15d
movq %rbx, %rdi
callq 0x192f
cmpl $-0x1, %eax
je 0x3196
movl %eax, %r12d
movq %rbx, %rdi
callq 0x2c68
movq %rbx, %rdi
movl %r12d, %esi
leaq -0xd0(%rbp), %rdx
leaq -0x2c(%rbp), %rcx
callq 0x18a9
testl %eax, %eax
jns 0x30b7
movl -0x2c(%rbp), %esi
leaq 0x167e(%rip), %rdi      # 0x4730
callq 0x2c09
movq %rbx, %rdi
callq 0x2c68
movq %rbx, %rdi
callq 0x19bf
movl -0xd0(%rbp), %eax
cmpl $-0x1, %eax
je 0x3150
movq (%rbx), %rcx
movb (%rcx), %cl
movl $0x1, %edx
shlq %cl, %rdx
movq %rsp, -0x48(%rbp)
leaq 0xf(%rdx), %rcx
andq $-0x10, %rcx
movq %rsp, %r13
subq %rcx, %r13
movq %r13, %rsp
cmpl -0x38(%rbp), %eax
jne 0x31b5
movq (%rbx), %rdi
movslq %edx, %r15
movl %r12d, %esi
xorl %edx, %edx
movq %r15, %rcx
movq %r13, %r8
leaq -0x2c(%rbp), %r9
callq 0x27e4
testl %eax, %eax
jns 0x312a
movl -0x2c(%rbp), %esi
leaq 0x16ac(%rip), %rdi      # 0x47d1
callq 0x2c09
movq -0x38(%rbp), %rdi
leal 0x1(%rdi), %r12d
decl %r14d
movq %r13, %rsi
movq %r15, %rdx
callq 0x2ba3
xorl %r15d, %r15d
movq -0x48(%rbp), %rsp
movl %r12d, %eax
movq %rax, -0x38(%rbp)
jmp 0x3159
incl %r15d
cmpl -0x3c(%rbp), %r15d
jge 0x31d4
cmpl $0x1, %r14d
jne 0x3176
movl 0x20(%rbx), %edx
movl 0x24(%rbx), %esi
movl 0x28(%rbx), %ecx
leaq 0x166c(%rip), %rdi      # 0x47db
xorl %eax, %eax
callq 0x1070
testl %r14d, %r14d
jg 0x3072
movq %rbx, %rdi
callq 0x2c68
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x15ba(%rip), %rdi      # 0x4757
leaq 0x14ae(%rip), %rsi      # 0x4652
leaq 0x15c4(%rip), %rcx      # 0x476f
movl $0xb0, %edx
callq 0x1080
leaq 0x160a(%rip), %rdi      # 0x47c6
leaq 0x148f(%rip), %rsi      # 0x4652
leaq 0x15a5(%rip), %rcx      # 0x476f
movl $0xc1, %edx
callq 0x1080
leaq 0x15cf(%rip), %rdi      # 0x47aa
leaq 0x1470(%rip), %rsi      # 0x4652
leaq 0x1586(%rip), %rcx      # 0x476f
movl $0xbc, %edx
callq 0x1080