// File: /workspace/github_c_makefile_star2_O1/cogbee[P]vmir-latest/tlsf/tlsf.c
// Function: tlsf_check_heap
int tlsf_check_heap(tlsf_pool tlsf)
{
	int i, j;

	pool_t* pool = tlsf_cast(pool_t*, tlsf);
	int status = 0;

	/* Check that the blocks are physically correct. */
	integrity_t integ = { 0, 0 };
	tlsf_walk_heap(tlsf, integrity_walker, &integ);
	status = integ.status;

	/* Check that the free lists and bitmaps are accurate. */
	for (i = 0; i < FL_INDEX_COUNT; ++i)
	{
		for (j = 0; j < SL_INDEX_COUNT; ++j)
		{
			const int fl_map = pool->fl_bitmap & (1 << i);
			const int sl_list = pool->sl_bitmap[i];
			const int sl_map = sl_list & (1 << j);
			const block_header_t* block = pool->blocks[i][j];

			/* Check that first- and second-level lists agree. */
			if (!fl_map)
			{
				tlsf_insist(!sl_map && "second-level map must be null");
			}

			if (!sl_map)
			{
				tlsf_insist(block == &pool->block_null && "block list must be null");
				continue;
			}

			/* Check that there is at least one free block. */
			tlsf_insist(sl_list && "no free blocks in second-level map");
			tlsf_insist(block != &pool->block_null && "block should not be null");

			while (block != &pool->block_null)
			{
				int fli, sli;
				tlsf_insist(block_is_free(block) && "block should be free");
				tlsf_insist(!block_is_prev_free(block) && "blocks should have coalesced");
				tlsf_insist(!block_is_free(block_next(block)) && "blocks should have coalesced");
				tlsf_insist(block_is_prev_free(block_next(block)) && "block should be free");
				tlsf_insist(block_size(block) >= block_size_min && "block not minimum size");

				mapping_insert(block_size(block), &fli, &sli);
				tlsf_insist(fli == i && sli == j && "block size indexed in wrong list");
				block = block->next_free;
			}
		}
	}

	return status;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leaq 0x8(%rsp), %r14
movq $0x0, (%r14)
leaq 0x333(%rip), %rsi       # 0x21bbd
movq %r14, %rdx
callq 0x21b30
movl 0x4(%r14), %eax
movl 0x20(%rbx), %edi
leaq 0x88(%rbx), %r8
xorl %edx, %edx
movl $0x1, %r9d
movl %edx, %ecx
shll %cl, %r9d
andl %edi, %r9d
movl 0x24(%rbx,%rdx,4), %r10d
movq %rdx, %r11
shlq $0x8, %r11
addq %r8, %r11
xorl %esi, %esi
movl $0x1, %ebp
movl %esi, %ecx
shll %cl, %ebp
movq (%r11,%rsi,8), %r14
testl %r9d, %r9d
je 0x219a2
testl %ebp, %r10d
je 0x219ab
testl %r10d, %r10d
je 0x21af2
cmpq %rbx, %r14
je 0x21ad3
movq 0x8(%r14), %rcx
testb $0x1, %cl
je 0x21a76
testb $0x2, %cl
jne 0x21a19
cmpq $0x3, %rcx
jbe 0x219db
movq %rcx, %r15
andq $-0x4, %r15
movl 0x10(%r14,%r15), %ebp
testb $0x1, %bpl
jne 0x219fa
testb $0x2, %bpl
je 0x21a57
cmpq $0x17, %rcx
jbe 0x21a38
cmpq $0xff, %rcx
ja 0x2194d
shrl $0x3, %ecx
xorl %r12d, %r12d
jmp 0x2197f
xorl %ebp, %ebp
shrq $0x20, %rcx
setne %bpl
cmovel %r15d, %ecx
shll $0x5, %ebp
orl $0x1f, %ebp
bsrl %ecx, %r12d
xorl %ebp, %r12d
xorl $0x1f, %r12d
leal -0x5(%r12), %ecx
shrq %cl, %r15
xorl $0x20, %r15d
addl $-0x7, %r12d
movl %r15d, %ecx
cmpq %rdx, %r12
jne 0x21a95
movl %ecx, %ecx
cmpq %rcx, %rsi
jne 0x21a95
movq 0x10(%r14), %r14
cmpq %rbx, %r14
jne 0x218f2
jmp 0x219b4
testl %ebp, %r10d
jne 0x21b11
cmpq %rbx, %r14
jne 0x21ab4
incq %rsi
cmpq $0x20, %rsi
jne 0x218c1
incq %rdx
cmpq $0x19, %rdx
jne 0x218a2
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6bc5(%rip), %rdi      # 0x285a7
leaq 0x6831(%rip), %rsi      # 0x2821a
leaq 0x6bcd(%rip), %rcx      # 0x285bd
movl $0xf8, %edx
callq 0x31e0
leaq 0x6951(%rip), %rdi      # 0x28352
leaq 0x6812(%rip), %rsi      # 0x2821a
leaq 0x6817(%rip), %rcx      # 0x28226
movl $0x2b9, %edx            # imm = 0x2B9
callq 0x31e0
leaq 0x68f5(%rip), %rdi      # 0x28315
leaq 0x67f3(%rip), %rsi      # 0x2821a
leaq 0x67f8(%rip), %rcx      # 0x28226
movl $0x2b8, %edx            # imm = 0x2B8
callq 0x31e0
leaq 0x6997(%rip), %rdi      # 0x283d6
leaq 0x67d4(%rip), %rsi      # 0x2821a
leaq 0x67d9(%rip), %rcx      # 0x28226
movl $0x2bb, %edx            # imm = 0x2BB
callq 0x31e0
leaq 0x6938(%rip), %rdi      # 0x28396
leaq 0x67b5(%rip), %rsi      # 0x2821a
leaq 0x67ba(%rip), %rcx      # 0x28226
movl $0x2ba, %edx            # imm = 0x2BA
callq 0x31e0
leaq 0x6869(%rip), %rdi      # 0x282e6
leaq 0x6796(%rip), %rsi      # 0x2821a
leaq 0x679b(%rip), %rcx      # 0x28226
movl $0x2b7, %edx            # imm = 0x2B7
callq 0x31e0
leaq 0x697a(%rip), %rdi      # 0x28416
leaq 0x6777(%rip), %rsi      # 0x2821a
leaq 0x677c(%rip), %rcx      # 0x28226
movl $0x2be, %edx            # imm = 0x2BE
callq 0x31e0
leaq 0x678a(%rip), %rdi      # 0x28245
leaq 0x6758(%rip), %rsi      # 0x2821a
leaq 0x675d(%rip), %rcx      # 0x28226
movl $0x2ac, %edx            # imm = 0x2AC
callq 0x31e0
leaq 0x67d3(%rip), %rdi      # 0x282ad
leaq 0x6739(%rip), %rsi      # 0x2821a
leaq 0x673e(%rip), %rcx      # 0x28226
movl $0x2b2, %edx            # imm = 0x2B2
callq 0x31e0
leaq 0x6784(%rip), %rdi      # 0x2827d
leaq 0x671a(%rip), %rsi      # 0x2821a
leaq 0x671f(%rip), %rcx      # 0x28226
movl $0x2b1, %edx            # imm = 0x2B1
callq 0x31e0
leaq 0x66d7(%rip), %rdi      # 0x281ef
leaq 0x66fb(%rip), %rsi      # 0x2821a
leaq 0x6700(%rip), %rcx      # 0x28226
movl $0x2a7, %edx            # imm = 0x2A7
callq 0x31e0