// File: /workspace/github_cpp_makefile_star2_O2/Konano[P]UselessDatabase/Table.cpp
// Function: Table::createIndex(std::vector<unsigned int, std::allocator<unsigned int>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
uint Table::createIndex(vector<uint> col_id, std::string name) {
    //Calculate max per node

    int max_per_node = 25;

    index[index_num] = Index(this, name.c_str(), col_id, max_per_node);
    index[index_num].open();
    for (uint record_id = 0; record_id < record_num; record_id++) {
        BufType buf = bpm->getPage(main_file, record_id / record_onepg);
        if (exist(buf, record_id % record_onepg)) {
            BufType _buf = buf + (record_onepg - 1) / 8 + 1 + record_size * (record_id % record_onepg);
            Anys a;
            for (uint j = 0; j < col_id.size(); j++) {
                Any val;
                fetchWithOffset(_buf, col_ty[index[index_num].key[j]].ty, col_ty[index[index_num].key[j]].size(), val, genOffset(col_id[j]));
                a.push_back(val);
            }
            index[index_num].insertRecord(&a, record_id);
        }
    }
    return index_num++;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdx), %r15
leaq 0x38(%rsp), %r12
movq %r12, %rdi
callq 0x17f70
leaq 0x50(%rsp), %rdi
pushq $0x19
popq %r8
movq %rbx, %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x1534e
leaq 0x7a0(%rbx), %rax
movq %rax, 0x18(%rsp)
movl 0x798(%rbx), %eax
imulq $0x98, %rax, %rax
leaq (%rbx,%rax), %rdi
addq $0x7a0, %rdi            # imm = 0x7A0
leaq 0x50(%rsp), %r15
movq %r15, %rsi
callq 0x20e46
movq %r15, %rdi
callq 0x20bc6
leaq 0x38(%rsp), %rdi
callq 0x18566
movl 0x798(%rbx), %eax
imulq $0x98, %rax, %rax
leaq (%rbx,%rax), %rdi
addq $0x7a0, %rdi            # imm = 0x7A0
callq 0x155f8
leaq 0x58(%rbx), %rax
movq %rax, 0x28(%rsp)
xorl %r12d, %r12d
cmpl 0x9fa0(%rbx), %r12d
jae 0x1be30
movq 0x48(%rbx), %rdi
movl 0x9fa4(%rbx), %esi
movl %r12d, %eax
xorl %edx, %edx
divl 0x9fac(%rbx)
movl %eax, %edx
callq 0x5c8e
movq %rax, %rcx
movl 0x9fac(%rbx), %esi
movl %r12d, %eax
xorl %edx, %edx
divl %esi
movl %edx, %eax
shrl $0x3, %eax
movzbl (%rcx,%rax), %eax
movl %edx, %edi
andl $0x7, %edi
btl %edi, %eax
jae 0x1be28
movq %r12, 0x20(%rsp)
decl %esi
shrl $0x3, %esi
imull 0x9fa8(%rbx), %edx
addq %rsi, %rcx
leaq (%rdx,%rcx), %rax
incq %rax
movq %rax, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
andq $0x0, 0x60(%rsp)
xorl %ebp, %ebp
movl %ebp, %ebp
movq 0x8(%r14), %rax
subq (%r14), %rax
sarq $0x2, %rax
cmpq %rbp, %rax
jbe 0x1bdfe
andq $0x0, 0x8(%rsp)
movl 0x798(%rbx), %eax
imulq $0x98, %rax, %rax
movq 0x18(%rsp), %rcx
movq 0x30(%rcx,%rax), %rax
movl (%rax,%rbp,4), %eax
imulq $0x38, %rax, %rax
movq 0x28(%rsp), %rcx
leaq (%rcx,%rax), %rdi
movl 0x24(%rcx,%rax), %r12d
callq 0x17ffa
movl %eax, %r13d
movq (%r14), %rax
movl (%rax,%rbp,4), %esi
movq %rbx, %rdi
callq 0x1d132
movq %rbx, %rdi
leaq 0x30(%rsp), %rsi
movl %r12d, %edx
movl %r13d, %ecx
leaq 0x8(%rsp), %r8
movl %eax, %r9d
callq 0x1bf9a
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x1bdc3
movq (%rdi), %rax
callq *0x10(%rax)
jmp 0x1bdc5
xorl %eax, %eax
movq %rax, 0x10(%rsp)
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
callq 0x8ea0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1bde7
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x1bdf7
movq (%rdi), %rax
callq *0x8(%rax)
incl %ebp
jmp 0x1bd38
movl 0x798(%rbx), %eax
imulq $0x98, %rax, %rdi
addq 0x18(%rsp), %rdi
movq %r15, %rsi
movq 0x20(%rsp), %r12
movl %r12d, %edx
callq 0x16790
movq %r15, %rdi
callq 0x9268
incl %r12d
jmp 0x1bcb8
movl 0x798(%rbx), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x798(%rbx)
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x18566
jmp 0x1be97
movq %rax, %rbx
jmp 0x1be8d
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1be7d
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x1be7d
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x1be8d
movq (%rdi), %rax
callq *0x8(%rax)
leaq 0x50(%rsp), %rdi
callq 0x9268
movq %rbx, %rdi
callq 0x56f0
nop