// File: /workspace/github_c_makefile_star2_O0/haxlang[P]hax/haxCkalloc.c
// Function: ValidateMemory
static void
ValidateMemory (
    Memoryp           *memoryp,
    struct mem_header *memHeaderP,
    char              *file,
    int                line,
    int                nukeGuards)
{
    unsigned char *hiPtr;
    int   idx;
    int   guard_failed = FALSE;
    int byte;

    for (idx = 0; idx < GUARD_SIZE; idx++) {
        byte = *(memHeaderP->low_guard + idx);
        if (byte != GUARD_VALUE) {
            guard_failed = TRUE;
	    byte &= 0xff;
            printf("low guard byte %d is 0x%x  \t%c\n", idx, byte,
	    	    (isprint(byte) ? byte : ' '));
        }
    }
    if (guard_failed) {
        dump_memory_info (memoryp);
        printf ("low guard failed at %p, %s %d\n",
                 memHeaderP->body, file, line);
        printf ("%lu bytes allocated at (%s %d)\n", memHeaderP->length,
		memHeaderP->file, memHeaderP->line);
        Hax_Panic ((char *) "Memory validation failure");
    }

    hiPtr = (unsigned char *)memHeaderP->body + memHeaderP->length;
    for (idx = 0; idx < GUARD_SIZE; idx++) {
        byte = *(hiPtr + idx);
        if (byte != GUARD_VALUE) {
            guard_failed = TRUE;
	    byte &= 0xff;
            printf("hi guard byte %d is 0x%x  \t%c\n", idx, byte,
	    	    (isprint(byte) ? byte : ' '));
        }
    }

    if (guard_failed) {
        dump_memory_info (memoryp);
        printf ("high guard failed at %p, %s %d\n",
                 memHeaderP->body, file, line);
        printf ("%lu bytes allocated at (%s %d)\n", memHeaderP->length,
		memHeaderP->file, memHeaderP->line);
        Hax_Panic ((char *) "Memory validation failure");
    }

    if (nukeGuards) {
        memset ((char *) memHeaderP->low_guard, 0, GUARD_SIZE);
        memset ((char *) hiPtr, 0, GUARD_SIZE);
    }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x2c(%rbp)
cmpl $0x8, -0x2c(%rbp)
jge 0x84ad
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movzbl 0x28(%rax,%rcx), %eax
movl %eax, -0x34(%rbp)
cmpl $0xe1, -0x34(%rbp)
je 0x849d
movl $0x1, -0x30(%rbp)
movl -0x34(%rbp), %eax
andl $0xff, %eax
movl %eax, -0x34(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x38(%rbp)
callq 0x4630
movq (%rax), %rax
movslq -0x34(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
je 0x847c
movl -0x34(%rbp), %eax
movl %eax, -0x40(%rbp)
jmp 0x8486
movl $0x20, %eax
movl %eax, -0x40(%rbp)
jmp 0x8486
movl -0x38(%rbp), %edx
movl -0x3c(%rbp), %esi
movl -0x40(%rbp), %ecx
leaq 0x1508e(%rip), %rdi     # 0x1d524
movb $0x0, %al
callq 0x4240
jmp 0x849f
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x8419
cmpl $0x0, -0x30(%rbp)
je 0x850b
movq -0x8(%rbp), %rdi
callq 0x89b0
movq -0x10(%rbp), %rsi
addq $0x30, %rsi
movq -0x18(%rbp), %rdx
movl -0x1c(%rbp), %ecx
leaq 0x15072(%rip), %rdi     # 0x1d544
movb $0x0, %al
callq 0x4240
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x10(%rbp), %rax
movl 0x10(%rax), %ecx
leaq 0x1506d(%rip), %rdi     # 0x1d563
movb $0x0, %al
callq 0x4240
leaq 0x1507f(%rip), %rdi     # 0x1d583
movb $0x0, %al
callq 0x4120
movq -0x10(%rbp), %rax
addq $0x30, %rax
movq -0x10(%rbp), %rcx
addq (%rcx), %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
cmpl $0x8, -0x2c(%rbp)
jge 0x85b8
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x34(%rbp)
cmpl $0xe1, -0x34(%rbp)
je 0x85a8
movl $0x1, -0x30(%rbp)
movl -0x34(%rbp), %eax
andl $0xff, %eax
movl %eax, -0x34(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x44(%rbp)
callq 0x4630
movq (%rax), %rax
movslq -0x34(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
je 0x8587
movl -0x34(%rbp), %eax
movl %eax, -0x4c(%rbp)
jmp 0x8591
movl $0x20, %eax
movl %eax, -0x4c(%rbp)
jmp 0x8591
movl -0x44(%rbp), %edx
movl -0x48(%rbp), %esi
movl -0x4c(%rbp), %ecx
leaq 0x14ffc(%rip), %rdi     # 0x1d59d
movb $0x0, %al
callq 0x4240
jmp 0x85aa
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x8525
cmpl $0x0, -0x30(%rbp)
je 0x8616
movq -0x8(%rbp), %rdi
callq 0x89b0
movq -0x10(%rbp), %rsi
addq $0x30, %rsi
movq -0x18(%rbp), %rdx
movl -0x1c(%rbp), %ecx
leaq 0x14fdf(%rip), %rdi     # 0x1d5bc
movb $0x0, %al
callq 0x4240
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x10(%rbp), %rax
movl 0x10(%rax), %ecx
leaq 0x14f62(%rip), %rdi     # 0x1d563
movb $0x0, %al
callq 0x4240
leaq 0x14f74(%rip), %rdi     # 0x1d583
movb $0x0, %al
callq 0x4120
cmpl $0x0, -0x20(%rbp)
je 0x8640
movq -0x10(%rbp), %rdi
addq $0x28, %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x4290
movq -0x28(%rbp), %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x4290
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)