// File: /workspace/github_c_makefile_star2_O2/USArmyResearchLab[P]ARL_OpenSHMEM/src/xmalloc.c
// Function: ifree
static void
ifree( struct __xmem_struct* xm, void *ptr)
{
    struct pginfo *info;
    size_t idx;

    /* This is legal */
    if (ptr == NULL)
	return;

    idx = ptr2idx(ptr);

    if (idx < xm->malloc_pageshift) {
	wrtwarning("junk pointer, too low to make sense.\n");
	return;
    }

    if (idx > xm->last_idx) {
	wrtwarning("junk pointer, too high to make sense.\n");
	return;
    }

    info = xm->page_dir[idx];

    if (info < MALLOC_MAGIC)
        free_pages(xm, ptr, idx, info);
    else
	free_bytes(xm, ptr, idx, info);

    return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r12
movq %rdi, %r10
pushq $0x1
popq %r14
movq %rdi, (%rsp)
testq %r12, %r12
je 0x270d
movq 0x8(%r10), %rcx
movq %r12, %rax
shrq %cl, %rax
movq 0x20(%r10), %rsi
movq %rax, %rbp
subq %rsi, %rbp
cmpq %rcx, %rbp
jb 0x26ad
cmpq 0x28(%r10), %rbp
ja 0x26b6
movq 0x30(%r10), %rdx
movq (%rdx,%rbp,8), %r13
cmpq $0x3, %r13
jbe 0x26bf
movzwl 0x10(%r13), %eax
decq %rax
testq %r12, %rax
jne 0x26d4
andq 0x10(%r10), %r12
movzwl 0x12(%r13), %eax
movl %eax, %ecx
shrq %cl, %r12
movq %r12, %r15
shrq $0x5, %r15
movl 0x18(%r13,%r15,4), %esi
movl %r12d, %ecx
andb $0x1f, %cl
movq %r14, %rbx
shlq %cl, %r14
btl %r12d, %esi
jb 0x26dd
cmpb $0x1, 0x3e73(%rip)      # 0x6494
jne 0x2641
leaq 0x1e00(%rip), %rdi      # 0x442a
callq 0x2555
movq (%rsp), %r10
movl 0x18(%r13,%r15,4), %esi
movq 0x30(%r10), %rdx
movzwl 0x12(%r13), %eax
orl %esi, %r14d
movl %r14d, 0x18(%r13,%r15,4)
movl 0x14(%r13), %esi
movl %esi, %ecx
incl %ecx
movw %cx, 0x14(%r13)
leaq (%rdx,%rax,8), %rax
testw %si, %si
je 0x26e6
cmpw 0x16(%r13), %cx
jne 0x270d
movq %rbx, %r14
movq %rax, %rcx
movq (%rax), %rax
cmpq %r13, %rax
jne 0x2671
movq (%r13), %rax
movq %rax, (%rcx)
movq 0x30(%r10), %rax
movq $0x2, (%rax,%rbp,8)
movq 0x8(%r13), %r12
cmpq %r13, %r12
je 0x2597
movq %r13, %rdi
callq 0x1040
movq (%rsp), %r10
jmp 0x2597
leaq 0x1c93(%rip), %rdi      # 0x4347
jmp 0x2732
leaq 0x1cb0(%rip), %rdi      # 0x436d
jmp 0x2732
cmpq $0x2, %r13
je 0x271c
cmpq $0x1, %r13
jne 0x272b
leaq 0x1cc2(%rip), %rdi      # 0x4394
jmp 0x2732
leaq 0x1d1b(%rip), %rdi      # 0x43f6
jmp 0x2732
leaq 0x1d2e(%rip), %rdi      # 0x4412
jmp 0x2732
movq (%rax), %rdx
movq %rax, %rcx
movq %rdx, %rax
testq %rdx, %rdx
je 0x2706
movq (%rax), %rdx
testq %rdx, %rdx
je 0x2706
movq 0x8(%rdx), %rsi
cmpq 0x8(%r13), %rsi
jb 0x26e9
movq %rax, (%r13)
movq %r13, (%rcx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r12, 0x10(%r10)
je 0x2745
leaq 0x1c9a(%rip), %rdi      # 0x43c3
jmp 0x2732
leaq 0x1c79(%rip), %rdi      # 0x43ab
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2555
movq $0x1, (%rdx,%rbp,8)
shlq $0x3, %rax
shlq $0x3, %rsi
subq %rsi, %rax
movq 0x30(%r10), %rdx
addq %rax, %rdx
cmpq $0x3, (%rdx,%r14,8)
jne 0x2773
movq $0x1, (%rdx,%r14,8)
incq %r14
jmp 0x2758
shlq %cl, %r14
cmpb $0x1, 0x3d17(%rip)      # 0x6494
jne 0x2793
movq %r12, %rdi
movl $0xd0, %esi
movq %r14, %rdx
callq 0x1130
movq (%rsp), %r10
cmpl $0x0, 0x6c(%r10)
je 0x27ac
pushq $0x8
popq %rdx
movq %r12, %rdi
movq %r14, %rsi
callq 0x11f0
movq (%rsp), %r10
leaq (%r12,%r14), %r15
movq 0x78(%r10), %rax
testq %rax, %rax
jne 0x27c9
pushq $0x28
popq %rdi
callq 0x11b0
movq (%rsp), %r10
movq %rax, 0x78(%r10)
movq %r12, 0x10(%rax)
movq %r15, 0x18(%rax)
movq %r14, 0x20(%rax)
movq 0x40(%r10), %rsi
testq %rsi, %rsi
je 0x2810
movq %rsi, %rcx
movq 0x18(%rsi), %rdx
cmpq %r12, %rdx
jae 0x27f2
movq (%rcx), %rsi
testq %rsi, %rsi
jne 0x27de
movq 0x10(%rcx), %rsi
cmpq %r15, %rsi
jbe 0x2822
movq %rcx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq %rax, 0x8(%rcx)
movq 0x8(%rax), %rcx
jmp 0x2842
leaq 0x40(%r10), %rcx
andq $0x0, (%rax)
movq %rcx, 0x8(%rax)
movq %rax, 0x40(%r10)
jmp 0x2845
cmpq %r12, %rdx
je 0x288d
cmpq %r15, %rsi
je 0x28ce
cmpq $0x0, (%rcx)
jne 0x296d
andq $0x0, (%rax)
movq %rcx, 0x8(%rax)
movq %rax, (%rcx)
andq $0x0, 0x78(%r10)
cmpq $0x0, (%rax)
jne 0x270d
xorl %edi, %edi
movq %rax, %rcx
movq 0x18(%r10), %rdx
cmpq %rdx, %r14
jbe 0x2951
movq 0x18(%rcx), %rax
cmpq 0x70(%r10), %rax
jne 0x2951
movq 0x80(%r10), %rsi
movq 0x90(%r10), %r9
cmpq %rsi, %r9
jae 0x28e9
pushq $-0x1
popq %r8
jmp 0x28f8
addq %r14, %rdx
movq %rdx, 0x18(%rcx)
addq 0x20(%rcx), %r14
movq %r14, 0x20(%rcx)
movq (%rcx), %rdi
testq %rdi, %rdi
je 0x28e2
cmpq 0x10(%rdi), %rdx
jne 0x28da
movq 0x18(%rdi), %rax
movq %rax, 0x18(%rcx)
addq 0x20(%rdi), %r14
movq %r14, 0x20(%rcx)
movq (%rdi), %rax
movq %rax, (%rcx)
testq %rax, %rax
je 0x2859
movq %rcx, 0x8(%rax)
jmp 0x295a
addq 0x20(%rcx), %r14
movq %r14, 0x20(%rcx)
movq %r12, 0x10(%rcx)
movq %rcx, %rax
jmp 0x284a
xorl %edi, %edi
jmp 0x2859
cmpq 0x88(%r10), %r9
pushq $-0x1
popq %r8
cmovbeq %r9, %r8
cmpq %r8, %rax
jne 0x2951
movq 0x10(%rcx), %rax
addq %rdx, %rax
movq %rax, 0x18(%rcx)
movq %rdx, 0x20(%rcx)
cmpq %rax, %rsi
ja 0x2921
cmpq %rax, 0x88(%r10)
jb 0x2921
movq %rax, 0x90(%r10)
movq %rax, 0x70(%r10)
movb 0x8(%r10), %cl
shrq %cl, %rax
subq 0x20(%r10), %rax
movq 0x28(%r10), %rcx
movq %rax, %rdx
cmpq %rcx, %rdx
ja 0x294a
movq 0x30(%r10), %rsi
andq $0x0, (%rsi,%rdx,8)
incq %rdx
jmp 0x2937
decq %rax
movq %rax, 0x28(%r10)
testq %rdi, %rdi
je 0x270d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1040
leaq 0x1a6a(%rip), %rdi      # 0x43de
callq 0x2531