// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
leaq -0x24(%rbp), %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x31f0
movq -0x8(%rbp), %rdi
leaq 0x54a(%rip), %rsi       # 0x399d0
leaq -0x24(%rbp), %rdx
callq 0x398f0
movl -0x20(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl $0x0, -0xc(%rbp)
cmpl $0x19, -0xc(%rbp)
jge 0x398e1
movl $0x0, -0x10(%rbp)
cmpl $0x20, -0x10(%rbp)
jge 0x398d1
movq -0x18(%rbp), %rax
movl 0x20(%rax), %eax
movl -0xc(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
movl %eax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movslq -0xc(%rbp), %rcx
movl 0x24(%rax,%rcx,4), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl -0x10(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
movl %eax, -0x30(%rbp)
movq -0x18(%rbp), %rax
addq $0x88, %rax
movslq -0xc(%rbp), %rcx
shlq $0x8, %rcx
addq %rcx, %rax
movslq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
cmpl $0x0, -0x28(%rbp)
jne 0x39561
cmpl $0x0, -0x30(%rbp)
jne 0x39529
movb $0x1, %al
testb $0x1, %al
jne 0x39527
jmp 0x39529
jmp 0x39548
leaq 0x7fb0(%rip), %rdi      # 0x414e0
leaq 0x7fd4(%rip), %rsi      # 0x4150b
movl $0x2a7, %edx            # imm = 0x2A7
leaq 0x7fd4(%rip), %rcx      # 0x41517
callq 0x31c0
cmpl $0x0, -0x30(%rbp)
jne 0x39556
movb $0x1, %al
testb $0x1, %al
jne 0x3955f
jmp 0x39556
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x39561
cmpl $0x0, -0x30(%rbp)
jne 0x395c0
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq %rcx, %rax
jne 0x3957e
movb $0x1, %al
testb $0x1, %al
jne 0x3957c
jmp 0x3957e
jmp 0x3959d
leaq 0x7fc9(%rip), %rdi      # 0x4154e
leaq 0x7f7f(%rip), %rsi      # 0x4150b
movl $0x2ac, %edx            # imm = 0x2AC
leaq 0x7f7f(%rip), %rcx      # 0x41517
callq 0x31c0
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq %rcx, %rax
jne 0x395b2
movb $0x1, %al
testb $0x1, %al
jne 0x395bb
jmp 0x395b2
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x398c3
cmpl $0x0, -0x2c(%rbp)
je 0x395d0
movb $0x1, %al
testb $0x1, %al
jne 0x395ce
jmp 0x395d0
jmp 0x395ef
leaq 0x7fd2(%rip), %rdi      # 0x415a9
leaq 0x7f2d(%rip), %rsi      # 0x4150b
movl $0x2b1, %edx            # imm = 0x2B1
leaq 0x7f2d(%rip), %rcx      # 0x41517
callq 0x31c0
cmpl $0x0, -0x2c(%rbp)
je 0x395fd
movb $0x1, %al
testb $0x1, %al
jne 0x39606
jmp 0x395fd
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq %rcx, %rax
je 0x3961d
movb $0x1, %al
testb $0x1, %al
jne 0x3961b
jmp 0x3961d
jmp 0x3963c
leaq 0x7fce(%rip), %rdi      # 0x415f2
leaq 0x7ee0(%rip), %rsi      # 0x4150b
movl $0x2b2, %edx            # imm = 0x2B2
leaq 0x7ee0(%rip), %rcx      # 0x41517
callq 0x31c0
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq %rcx, %rax
je 0x39651
movb $0x1, %al
testb $0x1, %al
jne 0x3965a
jmp 0x39651
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x3965c
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq %rcx, %rax
je 0x398c1
movq -0x38(%rbp), %rdi
callq 0x39b80
cmpl $0x0, %eax
je 0x39685
movb $0x1, %al
testb $0x1, %al
jne 0x39683
jmp 0x39685
jmp 0x396a4
leaq 0x7fb4(%rip), %rdi      # 0x41640
leaq 0x7e78(%rip), %rsi      # 0x4150b
movl $0x2b7, %edx            # imm = 0x2B7
leaq 0x7e78(%rip), %rcx      # 0x41517
callq 0x31c0
movq -0x38(%rbp), %rdi
callq 0x39b80
cmpl $0x0, %eax
je 0x396ba
movb $0x1, %al
testb $0x1, %al
jne 0x396c3
jmp 0x396ba
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x38(%rbp), %rdi
callq 0x39ba0
cmpl $0x0, %eax
jne 0x396db
movb $0x1, %al
testb $0x1, %al
jne 0x396d9
jmp 0x396db
jmp 0x396fa
leaq 0x7faa(%rip), %rdi      # 0x4168c
leaq 0x7e22(%rip), %rsi      # 0x4150b
movl $0x2b8, %edx            # imm = 0x2B8
leaq 0x7e22(%rip), %rcx      # 0x41517
callq 0x31c0
movq -0x38(%rbp), %rdi
callq 0x39ba0
cmpl $0x0, %eax
jne 0x39710
movb $0x1, %al
testb $0x1, %al
jne 0x39719
jmp 0x39710
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x38(%rbp), %rdi
callq 0x39bc0
movq %rax, %rdi
callq 0x39b80
cmpl $0x0, %eax
jne 0x39739
movb $0x1, %al
testb $0x1, %al
jne 0x39737
jmp 0x39739
jmp 0x39758
leaq 0x7f89(%rip), %rdi      # 0x416c9
leaq 0x7dc4(%rip), %rsi      # 0x4150b
movl $0x2b9, %edx            # imm = 0x2B9
leaq 0x7dc4(%rip), %rcx      # 0x41517
callq 0x31c0
movq -0x38(%rbp), %rdi
callq 0x39bc0
movq %rax, %rdi
callq 0x39b80
cmpl $0x0, %eax
jne 0x39776
movb $0x1, %al
testb $0x1, %al
jne 0x3977f
jmp 0x39776
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x38(%rbp), %rdi
callq 0x39bc0
movq %rax, %rdi
callq 0x39ba0
cmpl $0x0, %eax
je 0x3979f
movb $0x1, %al
testb $0x1, %al
jne 0x3979d
jmp 0x3979f
jmp 0x397be
leaq 0x7f67(%rip), %rdi      # 0x4170d
leaq 0x7d5e(%rip), %rsi      # 0x4150b
movl $0x2ba, %edx            # imm = 0x2BA
leaq 0x7d5e(%rip), %rcx      # 0x41517
callq 0x31c0
movq -0x38(%rbp), %rdi
callq 0x39bc0
movq %rax, %rdi
callq 0x39ba0
cmpl $0x0, %eax
je 0x397dc
movb $0x1, %al
testb $0x1, %al
jne 0x397e5
jmp 0x397dc
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x38(%rbp), %rdi
callq 0x39c30
cmpq $0x18, %rax
jb 0x397fe
movb $0x1, %al
testb $0x1, %al
jne 0x397fc
jmp 0x397fe
jmp 0x3981d
leaq 0x7f5f(%rip), %rdi      # 0x41764
leaq 0x7cff(%rip), %rsi      # 0x4150b
movl $0x2bb, %edx            # imm = 0x2BB
leaq 0x7cff(%rip), %rcx      # 0x41517
callq 0x31c0
movq -0x38(%rbp), %rdi
callq 0x39c30
cmpq $0x18, %rax
jb 0x39834
movb $0x1, %al
testb $0x1, %al
jne 0x3983d
jmp 0x39834
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x38(%rbp), %rdi
callq 0x39c30
movq %rax, %rdi
leaq -0x3c(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x39c50
movl -0x3c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jne 0x39870
movl -0x40(%rbp), %eax
cmpl -0x10(%rbp), %eax
jne 0x39870
movb $0x1, %al
testb $0x1, %al
jne 0x3986e
jmp 0x39870
jmp 0x3988f
leaq 0x7f4e(%rip), %rdi      # 0x417c5
leaq 0x7c8d(%rip), %rsi      # 0x4150b
movl $0x2be, %edx            # imm = 0x2BE
leaq 0x7c8d(%rip), %rcx      # 0x41517
callq 0x31c0
movl -0x3c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jne 0x398a7
movl -0x40(%rbp), %eax
cmpl -0x10(%rbp), %eax
jne 0x398a7
movb $0x1, %al
testb $0x1, %al
jne 0x398b0
jmp 0x398a7
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x3965c
jmp 0x398c3
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x394ad
jmp 0x398d3
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x3949c
movl -0x1c(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)