// File: /workspace/github_c_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0x20(%rsp), %r14
andq $0x0, (%r14)
leaq 0x2f3(%rip), %rsi       # 0x1cd8c
movq %r14, %rdx
callq 0x1cd34
movl 0x4(%r14), %ebp
leaq 0x88(%rbx), %rax
movq %rax, 0x10(%rsp)
xorl %r14d, %r14d
cmpq $0x19, %r14
je 0x1cbed
pushq $0x1
popq %rax
movl %r14d, %ecx
shll %cl, %eax
movl %eax, 0x4(%rsp)
movq %r14, %rax
shlq $0x8, %rax
addq 0x10(%rsp), %rax
movq %rax, 0x18(%rsp)
xorl %r13d, %r13d
cmpq $0x20, %r13
je 0x1cbe5
pushq $0x1
popq %rdx
movl %r13d, %ecx
shll %cl, %edx
movl 0x24(%rbx,%r14,4), %eax
movq 0x18(%rsp), %rcx
movq (%rcx,%r13,8), %r15
movl 0x4(%rsp), %ecx
testl %ecx, 0x20(%rbx)
je 0x1cbcc
testl %edx, %eax
je 0x1cbd4
testl %eax, %eax
je 0x1ccf6
cmpq %rbx, %r15
je 0x1ccd7
cmpq %rbx, %r15
je 0x1cbdd
movq 0x8(%r15), %rax
testb $0x1, %al
je 0x1cc3c
testb $0x2, %al
jne 0x1cc1d
movq %r15, %rdi
callq 0x1ce5a
testb $0x1, 0x8(%rax)
jne 0x1cbfe
movq %r15, %rdi
callq 0x1ce5a
movq 0x8(%rax), %r12
movq %r15, %rdi
callq 0x1ce5a
testb $0x2, 0x8(%rax)
je 0x1cc5b
notl %r12d
movq %r15, %rdi
callq 0x1ce5a
orl $-0x2, %r12d
btl $0x1, 0x8(%rax)
adcl %r12d, %ebp
movq 0x8(%r15), %rdi
cmpq $0x17, %rdi
jbe 0x1cc99
andq $-0x4, %rdi
leaq 0xc(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x1ce90
movl 0xc(%rsp), %eax
cmpq %rax, %r14
jne 0x1cc7a
movl 0x8(%rsp), %eax
cmpq %rax, %r13
jne 0x1cc7a
movq 0x10(%r15), %r15
jmp 0x1cb24
testl %edx, %eax
jne 0x1cd15
cmpq %rbx, %r15
jne 0x1ccb8
incq %r13
jmp 0x1cade
incq %r14
jmp 0x1cab4
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6902(%rip), %rdi      # 0x23507
leaq 0x67c3(%rip), %rsi      # 0x233cf
leaq 0x67c8(%rip), %rcx      # 0x233db
movl $0x2b9, %edx            # imm = 0x2B9
callq 0x31e0
leaq 0x68a6(%rip), %rdi      # 0x234ca
leaq 0x67a4(%rip), %rsi      # 0x233cf
leaq 0x67a9(%rip), %rcx      # 0x233db
movl $0x2b8, %edx            # imm = 0x2B8
callq 0x31e0
leaq 0x6858(%rip), %rdi      # 0x2349b
leaq 0x6785(%rip), %rsi      # 0x233cf
leaq 0x678a(%rip), %rcx      # 0x233db
movl $0x2b7, %edx            # imm = 0x2B7
callq 0x31e0
leaq 0x68e9(%rip), %rdi      # 0x2354b
leaq 0x6766(%rip), %rsi      # 0x233cf
leaq 0x676b(%rip), %rcx      # 0x233db
movl $0x2ba, %edx            # imm = 0x2BA
callq 0x31e0
leaq 0x694a(%rip), %rdi      # 0x235cb
leaq 0x6747(%rip), %rsi      # 0x233cf
leaq 0x674c(%rip), %rcx      # 0x233db
movl $0x2be, %edx            # imm = 0x2BE
callq 0x31e0
leaq 0x68eb(%rip), %rdi      # 0x2358b
leaq 0x6728(%rip), %rsi      # 0x233cf
leaq 0x672d(%rip), %rcx      # 0x233db
movl $0x2bb, %edx            # imm = 0x2BB
callq 0x31e0
leaq 0x673b(%rip), %rdi      # 0x233fa
leaq 0x6709(%rip), %rsi      # 0x233cf
leaq 0x670e(%rip), %rcx      # 0x233db
movl $0x2ac, %edx            # imm = 0x2AC
callq 0x31e0
leaq 0x6784(%rip), %rdi      # 0x23462
leaq 0x66ea(%rip), %rsi      # 0x233cf
leaq 0x66ef(%rip), %rcx      # 0x233db
movl $0x2b2, %edx            # imm = 0x2B2
callq 0x31e0
leaq 0x6735(%rip), %rdi      # 0x23432
leaq 0x66cb(%rip), %rsi      # 0x233cf
leaq 0x66d0(%rip), %rcx      # 0x233db
movl $0x2b1, %edx            # imm = 0x2B1
callq 0x31e0
leaq 0x6688(%rip), %rdi      # 0x233a4
leaq 0x66ac(%rip), %rsi      # 0x233cf
leaq 0x66b1(%rip), %rcx      # 0x233db
movl $0x2a7, %edx            # imm = 0x2A7
callq 0x31e0