// File: /workspace/github_c_makefile_star2_O3/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       # 0x21ce9
movq %r14, %rdx
callq 0x21c5c
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 0x21ace
testl %ebp, %r10d
je 0x21ad7
testl %r10d, %r10d
je 0x21c1e
cmpq %rbx, %r14
je 0x21bff
movq 0x8(%r14), %rcx
testb $0x1, %cl
je 0x21ba2
testb $0x2, %cl
jne 0x21b45
cmpq $0x3, %rcx
jbe 0x21b07
movq %rcx, %r15
andq $-0x4, %r15
movl 0x10(%r14,%r15), %ebp
testb $0x1, %bpl
jne 0x21b26
testb $0x2, %bpl
je 0x21b83
cmpq $0x17, %rcx
jbe 0x21b64
cmpq $0xff, %rcx
ja 0x21a79
shrl $0x3, %ecx
xorl %r12d, %r12d
jmp 0x21aab
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 0x21bc1
movl %ecx, %ecx
cmpq %rcx, %rsi
jne 0x21bc1
movq 0x10(%r14), %r14
cmpq %rbx, %r14
jne 0x21a1e
jmp 0x21ae0
testl %ebp, %r10d
jne 0x21c3d
cmpq %rbx, %r14
jne 0x21be0
incq %rsi
cmpq $0x20, %rsi
jne 0x219ed
incq %rdx
cmpq $0x19, %rdx
jne 0x219ce
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6ae3(%rip), %rdi      # 0x285f1
leaq 0x674f(%rip), %rsi      # 0x28264
leaq 0x6aeb(%rip), %rcx      # 0x28607
movl $0xf8, %edx
callq 0x31e0
leaq 0x686f(%rip), %rdi      # 0x2839c
leaq 0x6730(%rip), %rsi      # 0x28264
leaq 0x6735(%rip), %rcx      # 0x28270
movl $0x2b9, %edx            # imm = 0x2B9
callq 0x31e0
leaq 0x6813(%rip), %rdi      # 0x2835f
leaq 0x6711(%rip), %rsi      # 0x28264
leaq 0x6716(%rip), %rcx      # 0x28270
movl $0x2b8, %edx            # imm = 0x2B8
callq 0x31e0
leaq 0x68b5(%rip), %rdi      # 0x28420
leaq 0x66f2(%rip), %rsi      # 0x28264
leaq 0x66f7(%rip), %rcx      # 0x28270
movl $0x2bb, %edx            # imm = 0x2BB
callq 0x31e0
leaq 0x6856(%rip), %rdi      # 0x283e0
leaq 0x66d3(%rip), %rsi      # 0x28264
leaq 0x66d8(%rip), %rcx      # 0x28270
movl $0x2ba, %edx            # imm = 0x2BA
callq 0x31e0
leaq 0x6787(%rip), %rdi      # 0x28330
leaq 0x66b4(%rip), %rsi      # 0x28264
leaq 0x66b9(%rip), %rcx      # 0x28270
movl $0x2b7, %edx            # imm = 0x2B7
callq 0x31e0
leaq 0x6898(%rip), %rdi      # 0x28460
leaq 0x6695(%rip), %rsi      # 0x28264
leaq 0x669a(%rip), %rcx      # 0x28270
movl $0x2be, %edx            # imm = 0x2BE
callq 0x31e0
leaq 0x66a8(%rip), %rdi      # 0x2828f
leaq 0x6676(%rip), %rsi      # 0x28264
leaq 0x667b(%rip), %rcx      # 0x28270
movl $0x2ac, %edx            # imm = 0x2AC
callq 0x31e0
leaq 0x66f1(%rip), %rdi      # 0x282f7
leaq 0x6657(%rip), %rsi      # 0x28264
leaq 0x665c(%rip), %rcx      # 0x28270
movl $0x2b2, %edx            # imm = 0x2B2
callq 0x31e0
leaq 0x66a2(%rip), %rdi      # 0x282c7
leaq 0x6638(%rip), %rsi      # 0x28264
leaq 0x663d(%rip), %rcx      # 0x28270
movl $0x2b1, %edx            # imm = 0x2B1
callq 0x31e0
leaq 0x65f5(%rip), %rdi      # 0x28239
leaq 0x6619(%rip), %rsi      # 0x28264
leaq 0x661e(%rip), %rcx      # 0x28270
movl $0x2a7, %edx            # imm = 0x2A7
callq 0x31e0