// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movslq %esi, %r14
movq 0x8(%rdi), %rax
subq (%rdi), %rax
sarq $0x2, %rax
cmpq %r14, %rax
jae 0x1dca
movl %esi, %ebp
movq %rdi, %rbx
xorl %ecx, %ecx
cmpl $0x2, %esi
jl 0x1c04
xorl %ecx, %ecx
movl %ebp, %edx
movl %ebp, %eax
shrl %eax
incl %ecx
cmpl $0x3, %edx
movl %eax, %edx
ja 0x1bf9
movl $0x1, %eax
shll %cl, %eax
cmpl %ebp, %eax
jne 0x1de9
leaq 0x8(%rsp), %rdi
leaq 0x50(%rsp), %r15
movq %r14, %rsi
movq %r15, %rdx
callq 0x23b2
movb $0x0, (%r15)
leaq 0x20(%rsp), %rdi
leaq 0x50(%rsp), %rdx
leaq 0x7(%rsp), %rcx
movq %r14, %rsi
callq 0x250a
movq (%rbx), %rdx
movq 0x8(%rbx), %rsi
movq %rsi, 0x48(%rsp)
subq %rdx, %rsi
shrq $0x2, %rsi
movq 0x8(%rsp), %rdi
testl %esi, %esi
jle 0x1cf9
cvtsi2sd %ebp, %xmm0
cvtsi2sdl 0x18(%rbx), %xmm1
divsd %xmm1, %xmm0
movabsq $-0x8000000000000000, %r8 # imm = 0x8000000000000000
movq 0x20(%rbx), %r9
movq 0x20(%rsp), %r10
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
xorl %r11d, %r11d
leaq 0x3f(%r8), %r14
xorl %r15d, %r15d
movl %r11d, %ecx
shrl $0x6, %ecx
movq (%r9,%rcx,8), %rcx
btq %r11, %rcx
jae 0x1cf1
xorps %xmm1, %xmm1
cvtsi2sd %r15d, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %ecx
movslq %ecx, %rcx
leal 0x3f(%rcx), %r12d
testl %ecx, %ecx
cmovnsl %ecx, %r12d
sarl $0x6, %r12d
movslq %r12d, %r12
movq %rcx, %r13
andq %r14, %r13
xorl %eax, %eax
cmpq %r8, %r13
setbe %al
movl $0x1, %r13d
shlq %cl, %r13
leaq (%r10,%r12,8), %r12
orq %r13, -0x8(%r12,%rax,8)
incl %r15d
movl (%rdx,%r11,4), %eax
movl %eax, (%rdi,%rcx,4)
incq %r11
cmpq %r11, %rsi
jne 0x1c93
movq 0x10(%rbx), %rcx
movq %rdi, (%rbx)
movups 0x10(%rsp), %xmm0
movups %xmm0, 0x8(%rbx)
movq %rdx, 0x8(%rsp)
movq 0x48(%rsp), %rax
movq %rax, 0x10(%rsp)
movq %rcx, 0x18(%rsp)
movq 0x40(%rbx), %rax
movq %rax, 0x70(%rsp)
movups 0x20(%rbx), %xmm0
movups 0x30(%rbx), %xmm1
movaps %xmm1, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x40(%rbx)
movaps 0x20(%rsp), %xmm0
movaps 0x30(%rsp), %xmm1
movups %xmm1, 0x30(%rbx)
movups %xmm0, 0x20(%rbx)
movq 0x70(%rsp), %rax
movq %rax, 0x40(%rsp)
movaps 0x50(%rsp), %xmm0
movaps 0x60(%rsp), %xmm1
movaps %xmm1, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movq %rbx, %rdi
movl %ebp, %esi
callq 0x243e
movq 0x8(%rbx), %rax
subq (%rbx), %rax
sarq $0x2, %rax
addq %rax, 0x3333(%rip)      # 0x50c0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x1da4
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x1dbb
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x13aa(%rip), %rdi      # 0x317b
leaq 0x1291(%rip), %rsi      # 0x3069
leaq 0x13b9(%rip), %rcx      # 0x3198
movl $0x8a, %edx
callq 0x1090
leaq 0x13be(%rip), %rdi      # 0x31ae
leaq 0x1272(%rip), %rsi      # 0x3069
leaq 0x139a(%rip), %rcx      # 0x3198
movl $0x8b, %edx
callq 0x1090
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x1e22
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
movq %rbx, %rdi
callq 0x1120