// File: /workspace/github_cpp_makefile_star2_O1/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 0x1dda
movl %esi, %ebp
movq %rdi, %rbx
xorl %ecx, %ecx
cmpl $0x2, %esi
jl 0x1bd6
xorl %ecx, %ecx
movl %ebp, %edx
movl %ebp, %eax
shrl %eax
incl %ecx
cmpl $0x3, %edx
movl %eax, %edx
ja 0x1bcb
movl $0x1, %eax
shll %cl, %eax
cmpl %ebp, %eax
jne 0x1df9
leaq 0x8(%rsp), %rdi
leaq 0x50(%rsp), %r15
movq %r14, %rsi
movq %r15, %rdx
callq 0x23b6
movb $0x0, (%r15)
leaq 0x20(%rsp), %rdi
leaq 0x50(%rsp), %rdx
leaq 0x7(%rsp), %rcx
movq %r14, %rsi
callq 0x250e
movq (%rbx), %rdx
movq 0x8(%rbx), %rsi
movq %rsi, 0x48(%rsp)
subq %rdx, %rsi
shrq $0x2, %rsi
testl %esi, %esi
jle 0x1ccb
cvtsi2sd %ebp, %xmm0
cvtsi2sdl 0x18(%rbx), %xmm1
divsd %xmm1, %xmm0
movabsq $-0x8000000000000000, %rdi # imm = 0x8000000000000000
movq 0x20(%rbx), %r8
movq 0x20(%rsp), %r9
movq 0x8(%rsp), %r10
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
xorl %r11d, %r11d
leaq 0x3f(%rdi), %r14
xorl %r15d, %r15d
movq %r11, %rcx
shrq $0x6, %rcx
movq (%r8,%rcx,8), %rcx
btq %r11, %rcx
jae 0x1cc3
xorps %xmm1, %xmm1
cvtsi2sd %r15d, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %ecx
movslq %ecx, %rcx
leaq 0x3f(%rcx), %r12
testq %rcx, %rcx
cmovnsq %rcx, %r12
sarq $0x6, %r12
movq %rcx, %r13
andq %r14, %r13
xorl %eax, %eax
cmpq %rdi, %r13
setbe %al
movl $0x1, %r13d
shlq %cl, %r13
leaq (%r9,%r12,8), %r12
orq %r13, -0x8(%r12,%rax,8)
incl %r15d
movl (%rdx,%r11,4), %eax
movl %eax, (%r10,%rcx,4)
incq %r11
cmpq %r11, %rsi
jne 0x1c65
movq 0x10(%rbx), %rcx
movq 0x8(%rsp), %rsi
movq %rsi, (%rbx)
movq 0x10(%rsp), %rsi
movq %rsi, 0x8(%rbx)
movq 0x18(%rsp), %rsi
movq %rsi, 0x10(%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)
xorl %r14d, %r14d
movq %r14, 0x20(%rbx)
movl %r14d, 0x28(%rbx)
movq %r14, 0x30(%rbx)
movl %r14d, 0x38(%rbx)
movq %r14, 0x40(%rbx)
movq 0x40(%rsp), %rax
movq %rax, 0x40(%rbx)
movaps 0x30(%rsp), %xmm0
movups %xmm0, 0x30(%rbx)
movaps 0x20(%rsp), %xmm0
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 0x2440
movq 0x8(%rbx), %rax
subq (%rbx), %rax
sarq $0x2, %rax
addq %rax, 0x333c(%rip)      # 0x50c0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x1db4
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
movq %r14, 0x20(%rsp)
movl %r14d, 0x28(%rsp)
movq %r14, 0x30(%rsp)
movl %r14d, 0x38(%rsp)
movq %r14, 0x40(%rsp)
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x1dcb
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 0x139a(%rip), %rdi      # 0x317b
leaq 0x1281(%rip), %rsi      # 0x3069
leaq 0x13a9(%rip), %rcx      # 0x3198
movl $0x8a, %edx
callq 0x1090
leaq 0x13ae(%rip), %rdi      # 0x31ae
leaq 0x1262(%rip), %rsi      # 0x3069
leaq 0x138a(%rip), %rcx      # 0x3198
movl $0x8b, %edx
callq 0x1090
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x1e32
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
movq %rbx, %rdi
callq 0x1120