// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/lib/memalloc.c
// Function: carefulCheckHeap
void carefulCheckHeap()
/* Walk through allocated memory and make sure that all cookies are
 * in place. */
{
int maxPieces = 10000000;    /* Assume no more than this many pieces allocated. */
struct carefulMemBlock *cmb;
char *pEndCookie;
size_t size;
char errMsg[1024];
boolean errFound = FALSE;

if (carefulParent == NULL)
    return;

pthread_mutex_lock( &carefulMutex );
for (cmb = (struct carefulMemBlock *)(cmbAllocedList->head); cmb->next != NULL; cmb = cmb->next)
    {
    size = cmb->size;
    pEndCookie = (((char *)(cmb+1)) + size);
    if (cmb->startCookie != cmbStartCookie)
	{
        safef(errMsg, sizeof errMsg, "Bad start cookie %x checking %llx\n", cmb->startCookie,
                 ptrToLL(cmb+1));
	errFound = TRUE;
	break;
	}
    if (memcmp(pEndCookie, cmbEndCookie, sizeof(cmbEndCookie)) != 0)
	{
        safef(errMsg, sizeof errMsg, "Bad end cookie %x%x%x%x checking %llx\n", 
                 pEndCookie[0], pEndCookie[1], pEndCookie[2], pEndCookie[3],
                 ptrToLL(cmb+1));
	errFound = TRUE;
	break;
	}
    if (--maxPieces == 0)
	{
        safef(errMsg, sizeof errMsg, "Loop or more than 10000000 pieces in memory list");
	errFound = TRUE;
	break;
	}
    }
pthread_mutex_unlock( &carefulMutex );
if (errFound)
    errAbort("%s", errMsg);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x440, %rsp            # imm = 0x440
movl $0x989680, -0x4(%rbp)   # imm = 0x989680
movl $0x0, -0x424(%rbp)
cmpq $0x0, 0xc8d04(%rip)     # 0x109ad8
jne 0x40ddb
jmp 0x40f48
leaq 0xc8cfe(%rip), %rdi     # 0x109ae0
callq 0x6ae0
movq 0xc8d1a(%rip), %rax     # 0x109b08
movq (%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x40f1e
movq -0x10(%rbp), %rax
movslq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
addq $0x18, %rax
addq -0x20(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
cmpl 0xc5f34(%rip), %eax     # 0x106d60
je 0x40e66
leaq -0x420(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x14(%rax), %ecx
movq -0x10(%rbp), %r8
addq $0x1, %r8
movl $0x400, %esi            # imm = 0x400
leaq 0x9ac7b(%rip), %rdx     # 0xdbacb
movb $0x0, %al
callq 0x31090
movl $0x1, -0x424(%rbp)
jmp 0x40f1e
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl 0xc5ef2(%rip), %ecx     # 0x106d64
subl %ecx, %eax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x40ed8
leaq -0x420(%rbp), %rdi
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %r8d
movq -0x18(%rbp), %rax
movsbl 0x2(%rax), %r9d
movq -0x18(%rbp), %rax
movsbl 0x3(%rax), %r10d
movq -0x10(%rbp), %rax
addq $0x1, %rax
movl $0x400, %esi            # imm = 0x400
leaq 0x9ac32(%rip), %rdx     # 0xdbaee
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x31090
movl $0x1, -0x424(%rbp)
jmp 0x40f1e
movl -0x4(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x4(%rbp)
cmpl $0x0, %eax
jne 0x40f0c
leaq -0x420(%rbp), %rdi
movl $0x400, %esi            # imm = 0x400
leaq 0x9ac1c(%rip), %rdx     # 0xdbb15
movb $0x0, %al
callq 0x31090
movl $0x1, -0x424(%rbp)
jmp 0x40f1e
jmp 0x40f0e
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0x40df5
leaq 0xc8bbb(%rip), %rdi     # 0x109ae0
callq 0x64e0
cmpl $0x0, -0x424(%rbp)
je 0x40f48
leaq -0x420(%rbp), %rsi
leaq 0x990d0(%rip), %rdi     # 0xda011
movb $0x0, %al
callq 0x35d40
addq $0x440, %rsp            # imm = 0x440
popq %rbp
retq
nopw %cs:(%rax,%rax)