// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, 0xc(%rsp)
movl %ecx, %r12d
movq %rdx, 0x18(%rsp)
movq %rsi, %rbx
movq %rdi, 0x10(%rsp)
leaq 0xe5f9(%rip), %r15      # 0x15540
xorl %ebp, %ebp
xorl %r13d, %r13d
movzbl 0x28(%rbx,%rbp), %r14d
cmpl $0xe1, %r14d
je 0x6f8d
callq 0x4640
movq (%rax), %rax
movl %r14d, %ecx
movzwl (%rax,%rcx,2), %eax
btl $0xe, %eax
movl $0x20, %ecx
jae 0x6f78
movl %r14d, %ecx
movq %r15, %rdi
movl %ebp, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x4260
movl $0x1, %r13d
incq %rbp
cmpq $0x8, %rbp
jne 0x6f4c
testl %r13d, %r13d
je 0x6fe5
movq 0x10(%rsp), %rdi
callq 0x72e6
leaq 0x30(%rbx), %rsi
leaq 0xe5b0(%rip), %rdi      # 0x15560
movq 0x18(%rsp), %rdx
movl %r12d, %ecx
xorl %eax, %eax
callq 0x4260
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movl 0x10(%rbx), %ecx
leaq 0xe5af(%rip), %rdi      # 0x1557f
xorl %eax, %eax
callq 0x4260
leaq 0xe5c1(%rip), %rdi      # 0x1559f
xorl %eax, %eax
callq 0x4140
movl %r12d, 0x8(%rsp)
leaq 0x30(%rbx), %rax
movq (%rbx), %r12
movq %rax, 0x20(%rsp)
addq %rax, %r12
leaq 0xe5b9(%rip), %rbp      # 0x155b9
xorl %r14d, %r14d
movzbl (%r12,%r14), %r15d
cmpl $0xe1, %r15d
je 0x7044
callq 0x4640
movq (%rax), %rax
movl %r15d, %ecx
movzwl (%rax,%rcx,2), %eax
btl $0xe, %eax
movl $0x20, %ecx
jae 0x702e
movl %r15d, %ecx
movq %rbp, %rdi
movl %r14d, %esi
movl %r15d, %edx
xorl %eax, %eax
callq 0x4260
movl $0x1, %r13d
incq %r14
cmpq $0x8, %r14
jne 0x7003
testl %r13d, %r13d
je 0x709e
movq 0x10(%rsp), %rdi
callq 0x72e6
leaq 0xe575(%rip), %rdi      # 0x155d8
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl 0x8(%rsp), %ecx
xorl %eax, %eax
callq 0x4260
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movl 0x10(%rbx), %ecx
leaq 0xe4f6(%rip), %rdi      # 0x1557f
xorl %eax, %eax
callq 0x4260
leaq 0xe508(%rip), %rdi      # 0x1559f
xorl %eax, %eax
callq 0x4140
cmpl $0x0, 0xc(%rsp)
je 0x70af
xorl %eax, %eax
movq %rax, 0x28(%rbx)
movq %rax, (%r12)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq