// File: /workspace/github_c_makefile_star2_O0/open-mesh-mirror[P]batmand/allocate.c
// Function: checkIntegrity
void checkIntegrity(void)
{
	struct chunkHeader *walker;
	struct chunkTrailer *chunkTrailer;
	unsigned char *memory;


#if defined MEMORY_USAGE

	struct memoryUsage *memoryWalker;

	debug_output( 5, " \nMemory usage information:\n" );

	pthread_mutex_lock(&memory_mutex);
	for ( memoryWalker = memoryList; memoryWalker != NULL; memoryWalker = memoryWalker->next ) {

		if ( memoryWalker->counter != 0 )
			debug_output( 5, "   tag: %4i, num malloc: %4i, bytes per malloc: %4i, total: %6i\n", memoryWalker->tag, memoryWalker->counter, memoryWalker->length, memoryWalker->counter * memoryWalker->length );

	}
	pthread_mutex_unlock(&memory_mutex);

#endif

	pthread_mutex_lock(&chunk_mutex);

	for (walker = chunkList; walker != NULL; walker = walker->next)
	{
		if (walker->magicNumber != MAGIC_NUMBER)
		{
			debug_output( 0, "checkIntegrity - invalid magic number in header: %08x, malloc tag = %d\n", walker->magicNumber, walker->tag );
			pthread_mutex_unlock(&chunk_mutex);
			restore_and_exit(0);
		}

		memory = (unsigned char *)walker;

		chunkTrailer = (struct chunkTrailer *)(memory + sizeof(struct chunkHeader) + getHeaderPad() + walker->length + getTrailerPad(walker->length));

		if (chunkTrailer->magicNumber != MAGIC_NUMBER)
		{
			debug_output( 0, "checkIntegrity - invalid magic number in trailer: %08x, malloc tag = %d\n", chunkTrailer->magicNumber, walker->tag );
			pthread_mutex_unlock(&chunk_mutex);
			restore_and_exit(0);
		}
	}

	pthread_mutex_unlock(&chunk_mutex);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl $0x5, %edi
leaq 0xe6f0(%rip), %rsi      # 0x15664
movb $0x0, %al
callq 0x123f0
leaq 0x145c6(%rip), %rdi     # 0x1b548
callq 0x24e0
movq 0x145b2(%rip), %rax     # 0x1b540
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x6fec
movq -0x20(%rbp), %rax
cmpl $0x0, 0xc(%rax)
je 0x6fdd
movq -0x20(%rbp), %rax
movl 0x10(%rax), %edx
movq -0x20(%rbp), %rax
movl 0xc(%rax), %ecx
movq -0x20(%rbp), %rax
movl 0x8(%rax), %r8d
movq -0x20(%rbp), %rax
movl 0xc(%rax), %r9d
movq -0x20(%rbp), %rax
imull 0x8(%rax), %r9d
movl $0x5, %edi
leaq 0xe6ab(%rip), %rsi      # 0x15681
movb $0x0, %al
callq 0x123f0
jmp 0x6fdf
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x6f92
leaq 0x14555(%rip), %rdi     # 0x1b548
callq 0x2300
leaq 0x14571(%rip), %rdi     # 0x1b570
callq 0x24e0
movq 0x1452d(%rip), %rax     # 0x1b538
movq %rax, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x70f3
movq -0x8(%rbp), %rax
cmpl $0x12345678, 0x10(%rax) # imm = 0x12345678
je 0x7058
movq -0x8(%rbp), %rax
movl 0x10(%rax), %edx
movq -0x8(%rbp), %rax
movl 0xc(%rax), %ecx
xorl %edi, %edi
leaq 0xe684(%rip), %rsi      # 0x156c2
movb $0x0, %al
callq 0x123f0
leaq 0x14524(%rip), %rdi     # 0x1b570
callq 0x2300
xorl %edi, %edi
callq 0x10180
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x30(%rbp)
callq 0x7110
movq %rax, %rcx
movq -0x30(%rbp), %rax
addq %rcx, %rax
movq -0x8(%rbp), %rcx
movl 0x8(%rcx), %ecx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %edi
callq 0x7160
movq %rax, %rcx
movq -0x28(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x12345678, (%rax)     # imm = 0x12345678
je 0x70e1
movq -0x10(%rbp), %rax
movl (%rax), %edx
movq -0x8(%rbp), %rax
movl 0xc(%rax), %ecx
xorl %edi, %edi
leaq 0xe643(%rip), %rsi      # 0x1570a
movb $0x0, %al
callq 0x123f0
leaq 0x1449b(%rip), %rdi     # 0x1b570
callq 0x2300
xorl %edi, %edi
callq 0x10180
jmp 0x70e3
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x8(%rbp)
jmp 0x700f
leaq 0x14476(%rip), %rdi     # 0x1b570
callq 0x2300
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)