// File: /workspace/github_c_makefile_star2_O3/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 $0x18, %rsp
movl %r8d, 0x4(%rsp)
movl %ecx, (%rsp)
movq %rdx, 0x10(%rsp)
movq %rsi, %rbx
movq %rdi, 0x8(%rsp)
xorl %r13d, %r13d
movb $0x1, %r12b
leaq 0xd747(%rip), %rbp      # 0x14540
xorl %r15d, %r15d
movzbl 0x28(%rbx,%r13), %r14d
cmpl $0xe1, %r14d
jne 0x6e16
incq %r13
cmpq $0x8, %r13
jne 0x6dfc
jmp 0x6e5c
callq 0x4650
movq (%rax), %rax
movl %r14d, %ecx
movzwl (%rax,%rcx,2), %eax
btl $0xe, %eax
movl %r14d, %ecx
movl $0x20, %eax
cmovael %eax, %ecx
xorl %r12d, %r12d
movq %rbp, %rdi
movl %r13d, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x4260
leaq 0x1(%r13), %rax
movl $0x1, %r15d
cmpq $0x7, %r13
movq %rax, %r13
jne 0x6dfc
jmp 0x6e65
movb $0x1, %r14b
testb $0x1, %r12b
jne 0x6eb6
movq 0x8(%rsp), %rdi
callq 0x71cb
leaq 0x30(%rbx), %rsi
leaq 0xd6e6(%rip), %rdi      # 0x14560
movq 0x10(%rsp), %rdx
movl (%rsp), %ecx
xorl %eax, %eax
callq 0x4260
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movl 0x10(%rbx), %ecx
leaq 0xd6e5(%rip), %rdi      # 0x1457f
xorl %eax, %eax
callq 0x4260
leaq 0xd6f7(%rip), %rdi      # 0x1459f
xorl %eax, %eax
callq 0x4140
testl %r15d, %r15d
sete %r14b
leaq 0x30(%rbx), %r13
movq (%rbx), %r12
addq %r13, %r12
xorl %ebp, %ebp
movzbl (%r12,%rbp), %r15d
cmpl $0xe1, %r15d
jne 0x6edb
incq %rbp
cmpq $0x8, %rbp
jne 0x6ec2
jmp 0x6f1e
callq 0x4650
movq (%rax), %rax
movl %r15d, %ecx
movzwl (%rax,%rcx,2), %eax
btl $0xe, %eax
movl %r15d, %ecx
movl $0x20, %eax
cmovael %eax, %ecx
xorl %r14d, %r14d
leaq 0xd6b6(%rip), %rdi      # 0x145b9
movl %ebp, %esi
movl %r15d, %edx
xorl %eax, %eax
callq 0x4260
leaq 0x1(%rbp), %rax
cmpq $0x7, %rbp
movq %rax, %rbp
jne 0x6ec2
jmp 0x6f24
testb $0x1, %r14b
jne 0x6f6d
movq 0x8(%rsp), %rdi
callq 0x71cb
leaq 0xd6a3(%rip), %rdi      # 0x145d8
movq %r13, %rsi
movq 0x10(%rsp), %rdx
movl (%rsp), %ecx
xorl %eax, %eax
callq 0x4260
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movl 0x10(%rbx), %ecx
leaq 0xd627(%rip), %rdi      # 0x1457f
xorl %eax, %eax
callq 0x4260
leaq 0xd639(%rip), %rdi      # 0x1459f
xorl %eax, %eax
callq 0x4140
cmpl $0x0, 0x4(%rsp)
je 0x6f7e
xorl %eax, %eax
movq %rax, 0x28(%rbx)
movq %rax, (%r12)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq