// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/./include/sparsetable.hpp
// Function: SparseTable::initialize(std::vector<unsigned int, std::allocator<unsigned int>> const&)
void initialize(vui_t const& elems) {

        this->len = elems.size();
        this->repr.clear();

        cerr<<"len: "<<this->len<<endl;

        const size_t ntables = log2(this->len) + 1;
        this->repr.resize(ntables);

        cerr<<"ntables: "<<ntables<<endl;

        this->repr[0].resize(this->len);
        for (size_t i = 0; i < this->len; ++i) {
            this->repr[0][i] = std::make_pair(elems[i], i);
        }

        for (size_t i = 1; i < ntables; ++i) {
            // bs is the 'block size'. i.e. Number of element in the
            // array this->repr[i]
            // cerr<<"starting i: "<<i<<endl;
            const uint_t pbs = 1<<(i-1);
            const uint_t bs = 1<<i;
            const size_t vsz = this->len - bs + 1;

            this->repr[i] = vpui_t();
            this->repr[i].resize(vsz);

            // cerr<<"i: "<<i<<", vsz: "<<vsz<<endl;

            vpui_t& curr = this->repr[i];
            vpui_t& prev = this->repr[i - 1];

            for (size_t j = 0; j < vsz; ++j) {
                // 'j' is the starting index of a block of size 'bs'
                if (prev[j].first > prev[j+pbs].first) {
                    curr[j] = prev[j];
                }
                else {
                    curr[j] = prev[j+pbs];
                }
                // cerr<<"curr["<<j<<"] = "<<curr[j].first<<endl;
            }
            // cerr<<"done with i: "<<i<<endl;
        }
        // cerr<<"initialize() completed"<<endl;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r15
movq 0x8(%rsi), %rax
subq (%rsi), %rax
movq %rdi, %rbx
shrq $0x2, %rax
movl %eax, 0x18(%rdi)
movq (%rdi), %rsi
callq 0xc92a
movq 0x10369(%rip), %r14     # 0x1bff0
leaq 0x977b(%rip), %rsi      # 0x15409
movl $0x5, %edx
movq %r14, %rdi
callq 0x5590
movl 0x18(%rbx), %esi
movq %r14, %rdi
callq 0x52f0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x5480
movsbl %al, %esi
movq %r14, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5300
movl 0x18(%rbx), %ecx
movl $0x1, %eax
cmpl $0x2, %ecx
jb 0xbcea
movl %ecx, %edx
shrl %edx
incl %eax
cmpl $0x3, %ecx
movl %edx, %ecx
ja 0xbcdf
movl %eax, %r14d
movq %rbx, %rdi
movq %r14, %rsi
callq 0xc8ee
movq 0x102f1(%rip), %r12     # 0x1bff0
leaq 0x9709(%rip), %rsi      # 0x1540f
movl $0x9, %edx
movq %r12, %rdi
callq 0x5590
movq %r12, %rdi
movq %r14, 0x8(%rsp)
movq %r14, %rsi
callq 0x52f0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x5480
movsbl %al, %esi
movq %r12, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5300
movq (%rbx), %rdi
movl 0x18(%rbx), %esi
callq 0xc5c6
movl 0x18(%rbx), %eax
testq %rax, %rax
je 0xbd7d
movq (%r15), %rcx
movq (%rbx), %rdx
movq (%rdx), %rdx
xorl %esi, %esi
movl (%rcx,%rsi,4), %edi
movl %edi, (%rdx,%rsi,8)
movl %esi, 0x4(%rdx,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0xbd6b
cmpl $0x2, 0x8(%rsp)
jb 0xbe70
movl $0x1, %r15d
leaq -0x1(%r15), %r13
movl $0x1, %r12d
movl %r13d, %ecx
shll %cl, %r12d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %r15d, %ecx
shll %cl, %ebp
movl 0x18(%rbx), %r14d
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
leaq (%r15,%r15,2), %rdi
shlq $0x3, %rdi
addq (%rbx), %rdi
leaq 0x10(%rsp), %rsi
callq 0xcb26
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xbde9
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x54c0
addl %r14d, %ebp
incl %ebp
leaq (,%r15,8), %rax
leaq (%rax,%rax,2), %r14
movq (%rbx), %rdi
addq %r14, %rdi
movq %rbp, %rsi
callq 0xc5c6
testq %rbp, %rbp
je 0xbe62
movq (%rbx), %rax
addq %rax, %r14
leaq (,%r13,2), %rcx
addq %r13, %rcx
movq (%rax,%rcx,8), %rax
movl %r12d, %ecx
leaq (%rax,%rcx,8), %rcx
movq (%r14), %rdx
shlq $0x3, %rbp
xorl %esi, %esi
leaq (%rax,%rsi), %rdi
movl (%rax,%rsi), %r8d
leaq (%rcx,%rsi), %r9
movl (%rcx,%rsi), %r10d
cmpl %r10d, %r8d
cmoval %r8d, %r10d
cmovaq %rdi, %r9
movl %r10d, (%rdx,%rsi)
movl 0x4(%r9), %edi
movl %edi, 0x4(%rdx,%rsi)
addq $0x8, %rsi
cmpq %rsi, %rbp
jne 0xbe32
incq %r15
cmpq 0x8(%rsp), %r15
jne 0xbd8e
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop