// File: reddragon[P]packed-memory-array/impl2.cpp
// Function: PMA::resize(int)
void
    resize(int capacity) {
        assert(capacity > this->impl.size());
        assert(1 << log2(capacity) == capacity);

        vi_t tmpi(capacity);
        vector<bool> tmpp(capacity);
        double d = (double)capacity / this->nelems;
        int ctr = 0;
        for (int i = 0; i < (int)this->impl.size(); ++i) {
            if (this->present[i]) {
                int idx = d*(ctr++);
                tmpp[idx] = true;
                tmpi[idx] = this->impl[i];
            }
        }
        this->impl.swap(tmpi);
        this->present.swap(tmpp);
        this->init_vars(capacity);
        nmoves += this->impl.size();
        // dprintf("After resize: ");
        // this->print();
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
movslq -0xc(%rbp), %rax
movq %rax, -0xb0(%rbp)
callq 0x1a90
movq %rax, %rcx
movq -0xb0(%rbp), %rax
cmpq %rcx, %rax
jbe 0x1f2e
jmp 0x1f4d
leaq 0x5246(%rip), %rdi      # 0x717b
leaq 0x512d(%rip), %rsi      # 0x7069
movl $0x8a, %edx
leaq 0x5250(%rip), %rcx      # 0x7198
callq 0x1090
movl -0xc(%rbp), %edi
callq 0x1290
movl %eax, %ecx
movl $0x1, %eax
shll %cl, %eax
cmpl -0xc(%rbp), %eax
jne 0x1f65
jmp 0x1f84
leaq 0x5242(%rip), %rdi      # 0x71ae
leaq 0x50f6(%rip), %rsi      # 0x7069
movl $0x8b, %edx
leaq 0x5219(%rip), %rcx      # 0x7198
callq 0x1090
movslq -0xc(%rbp), %rax
movq %rax, -0xc8(%rbp)
leaq -0x29(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0x3d00
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rdx
leaq -0x28(%rbp), %rdi
callq 0x3d20
jmp 0x1fb8
leaq -0x29(%rbp), %rdi
callq 0x3d90
movslq -0xc(%rbp), %rax
movq %rax, -0xd8(%rbp)
leaq -0x69(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
callq 0x3db0
movq -0xd8(%rbp), %rsi
movq -0xd0(%rbp), %rdx
leaq -0x68(%rbp), %rdi
callq 0x3dd0
jmp 0x1ff5
leaq -0x69(%rbp), %rdi
callq 0x3e10
movq -0xb8(%rbp), %rax
cvtsi2sdl -0xc(%rbp), %xmm0
cvtsi2sdl 0x18(%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x78(%rbp)
movl $0x0, -0x7c(%rbp)
movl $0x0, -0x80(%rbp)
movq -0xb8(%rbp), %rdi
movl -0x80(%rbp), %eax
movl %eax, -0xdc(%rbp)
callq 0x1a90
movq %rax, %rcx
movl -0xdc(%rbp), %eax
cmpl %ecx, %eax
jge 0x219c
movq -0xb8(%rbp), %rdi
addq $0x20, %rdi
movslq -0x80(%rbp), %rsi
callq 0x1b70
movq %rdx, -0xf0(%rbp)
movq %rax, -0xe8(%rbp)
jmp 0x2070
movq -0xf0(%rbp), %rax
movq -0xe8(%rbp), %rcx
movq %rcx, -0x90(%rbp)
movq %rax, -0x88(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x1bd0
testb $0x1, %al
jne 0x20a1
jmp 0x218c
movsd -0x78(%rbp), %xmm0
movl -0x7c(%rbp), %eax
movl %eax, %ecx
incl %ecx
movl %ecx, -0x7c(%rbp)
cvtsi2sd %eax, %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x94(%rbp)
movslq -0x94(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0x1b70
movq %rdx, -0x100(%rbp)
movq %rax, -0xf8(%rbp)
jmp 0x20e2
movq -0x100(%rbp), %rax
movq -0xf8(%rbp), %rcx
movq %rcx, -0xa8(%rbp)
movq %rax, -0xa0(%rbp)
leaq -0xa8(%rbp), %rdi
movl $0x1, %esi
callq 0x2970
movq -0xb8(%rbp), %rdi
movslq -0x80(%rbp), %rsi
callq 0x2530
movl (%rax), %eax
movl %eax, -0x104(%rbp)
movslq -0x94(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x2530
movl -0x104(%rbp), %ecx
movl %ecx, (%rax)
jmp 0x218c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x29(%rbp), %rdi
callq 0x3d90
jmp 0x220f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x69(%rbp), %rdi
callq 0x3e10
jmp 0x2206
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x3fb0
jmp 0x2206
jmp 0x218e
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x2026
movq -0xb8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x3e30
movq -0xb8(%rbp), %rdi
addq $0x20, %rdi
leaq -0x68(%rbp), %rsi
callq 0x3e90
movq -0xb8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x3ef0
jmp 0x21d1
movq -0xb8(%rbp), %rdi
callq 0x1a90
addq 0x8eec(%rip), %rax      # 0xb0d0
movq %rax, 0x8ee5(%rip)      # 0xb0d0
leaq -0x68(%rbp), %rdi
callq 0x3fb0
leaq -0x28(%rbp), %rdi
callq 0x1920
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
leaq -0x28(%rbp), %rdi
callq 0x1920
movq -0x38(%rbp), %rdi
callq 0x1140
nopl (%rax,%rax)