// File: ctSkennerton[P]fxtract/util/map.c
// Function: map_resize
void
map_resize(MAP mp, int limit)
{
    int		i, j, dups = 0, oldmask = mp->mask;
    KEYVAL      *vdata;
    const void	*kp;

    if (--limit < MINMASK) limit = MINMASK;
    if (limit < mp->count * 5/4) limit = mp->count * 5/4;
    while (mp->mask > limit) mp->mask >>= 1;
    while (mp->mask < limit) mp->mask = (mp->mask << 1) | 1;
    vdata = calloc(mp->mask + 1, sizeof(KEYVAL));

        // PASS 1: insert where there are no collisions,
    for (i = 0; i <= oldmask; ++i) {

        if ((kp = mp->vdata[i].key)) {
            if (vdata[j = FNHASH(mp, kp)].key) {
                mp->vdata[dups++] = mp->vdata[i];
            } else {
                vdata[j] = mp->vdata[i];
            }
        }
    }

        // PASS 2: insert the rest
    for (i = 0; i < dups; ++i) {
        kp = mp->vdata[i].key;
        j = FNHASH(mp, kp);
        do j = (j + 1) & mp->mask; while (vdata[j].key);
        vdata[j] = mp->vdata[i];
    }

    free(mp->vdata);
    mp->vdata = vdata;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x1c(%rbp)
movl -0xc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xc(%rbp)
cmpl $0x7, %eax
jge 0x4b45
movl $0x7, -0xc(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x34(%rbp)
movq -0x8(%rbp), %rax
imull $0x5, 0x18(%rax), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x34(%rbp), %eax
cmpl %ecx, %eax
jge 0x4b77
movq -0x8(%rbp), %rax
imull $0x5, 0x18(%rax), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %eax, -0xc(%rbp)
jmp 0x4b79
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %eax
cmpl -0xc(%rbp), %eax
jle 0x4b93
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %ecx
sarl %ecx
movl %ecx, 0x1c(%rax)
jmp 0x4b79
jmp 0x4b95
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %eax
cmpl -0xc(%rbp), %eax
jge 0x4bb6
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %ecx
shll %ecx
orl $0x1, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1c(%rax)
jmp 0x4b95
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %eax
addl $0x1, %eax
movslq %eax, %rdi
movl $0x10, %esi
callq 0x31a0
movq %rax, -0x28(%rbp)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x4ccf
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x10(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
je 0x4cbf
movq -0x28(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x30(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
movb $0x0, %al
callq *%rcx
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq -0x8(%rbp), %rdx
movslq 0x1c(%rdx), %rdx
andq %rdx, %rcx
movl %ecx, -0x14(%rbp)
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0x4c8d
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x18(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x18(%rbp)
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
movslq -0x10(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
jmp 0x4cbd
movq -0x28(%rbp), %rax
movslq -0x14(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
movslq -0x10(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
jmp 0x4cbf
jmp 0x4cc1
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x4bd8
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x4d85
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x10(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x30(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
movb $0x0, %al
callq *%rcx
movq -0x8(%rbp), %rcx
movslq 0x1c(%rcx), %rcx
andq %rcx, %rax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movq -0x8(%rbp), %rcx
andl 0x1c(%rcx), %eax
movl %eax, -0x14(%rbp)
movq -0x28(%rbp), %rax
movslq -0x14(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
jne 0x4d22
movq -0x28(%rbp), %rax
movslq -0x14(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
movslq -0x10(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x4cd6
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x3320
movq -0x28(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x28(%rax)
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)