// File: /workspace/github_cpp_makefile_star2_O1/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 $0xd8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdx), %r15
leaq 0x28(%rsp), %r12
movq %r12, %rdi
callq 0x1cc60
leaq 0x40(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r12, %rcx
movl $0x19, %r8d
callq 0x19440
movl 0x798(%rbx), %eax
imulq $0x98, %rax, %r13
leaq 0x70(%rsp), %rsi
movups -0x30(%rsi), %xmm0
movups -0x20(%rsi), %xmm1
movups -0x14(%rsi), %xmm2
leaq 0x7d0(%rbx,%r13), %rdi
movups %xmm2, -0x14(%rdi)
movups %xmm1, -0x20(%rdi)
movups %xmm0, -0x30(%rdi)
callq 0x28da4
leaq (%rbx,%r13), %r15
addq $0x7e8, %r15            # imm = 0x7E8
leaq 0x88(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x28da4
movq 0x28(%r12), %rax
movq %rax, 0x28(%r15)
movups 0x18(%r12), %xmm0
movups %xmm0, 0x18(%r15)
leaq 0x818(%rbx,%r13), %r15
leaq 0xb8(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x28de4
movq 0x18(%r12), %rax
movq %rax, 0x18(%r15)
movq (%r12), %rdi
testq %rdi, %rdi
je 0x21b04
movq 0xc8(%rsp), %rsi
subq %rdi, %rsi
callq 0x53a0
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x21b21
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x53a0
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x21b3b
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x53a0
leaq 0x7a0(%rbx), %rax
movq %rax, 0x8(%rsp)
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x21b5e
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x53a0
movl 0x798(%rbx), %eax
imulq $0x98, %rax, %rdi
addq 0x8(%rsp), %rdi
callq 0x19846
cmpl $0x0, 0x9fa0(%rbx)
je 0x21d43
leaq 0x58(%rbx), %r15
xorl %r12d, %r12d
leaq 0x40(%rsp), %r13
movq 0x48(%rbx), %rdi
movl 0x9fa4(%rbx), %esi
movl %r12d, %eax
xorl %edx, %edx
divl 0x9fac(%rbx)
movl %eax, %edx
callq 0x6768
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 0x21d33
movq %r12, 0x18(%rsp)
decl %esi
shrl $0x3, %esi
imull 0x9fa8(%rbx), %edx
addq %rsi, %rcx
leaq (%rdx,%rcx), %rax
incq %rax
movq %rax, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
movq (%r14), %rax
cmpq %rax, 0x8(%r14)
je 0x21d09
movl $0x1, %r12d
xorl %ecx, %ecx
movq $0x0, (%rsp)
movl 0x798(%rbx), %edx
imulq $0x98, %rdx, %rdx
movq 0x8(%rsp), %rsi
movq 0x30(%rsi,%rdx), %rdx
movl (%rdx,%rcx,4), %edx
imulq $0x38, %rdx, %rdx
movl 0x24(%r15,%rdx), %ebp
cmpq $0x4, %rbp
ja 0x21c7a
leaq 0x1fd65(%rip), %rdi     # 0x419b4
movslq (%rdi,%rbp,4), %rsi
addq %rdi, %rsi
jmpq *%rsi
movl $0x4, %r13d
jmp 0x21c80
movl $0x10, %r13d
jmp 0x21c80
addq %r15, %rdx
movzbl 0x28(%rdx), %r13d
jmp 0x21c80
movl $0x8, %r13d
jmp 0x21c80
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl (%rax,%rcx,4), %esi
movq %rbx, %rdi
callq 0x23482
movq %rbx, %rdi
leaq 0x20(%rsp), %rsi
movl %ebp, %edx
movl %r13d, %ecx
movq %rsp, %r8
movl %eax, %r9d
callq 0x21f2c
leaq 0x40(%rsp), %r13
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x21cb9
movq (%rdi), %rax
callq *0x10(%rax)
jmp 0x21cbb
xorl %eax, %eax
movq %rax, 0x10(%rsp)
movq %r13, %rdi
leaq 0x10(%rsp), %rsi
callq 0xa1bc
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x21cdd
movq (%rdi), %rax
callq *0x8(%rax)
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x21cec
movq (%rdi), %rax
callq *0x8(%rax)
movl %r12d, %ecx
movq (%r14), %rax
movq 0x8(%r14), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
incl %r12d
cmpq %rcx, %rdx
ja 0x21c17
movl 0x798(%rbx), %eax
imulq $0x98, %rax, %rdi
addq 0x8(%rsp), %rdi
movq %r13, %rsi
movq 0x18(%rsp), %r12
movl %r12d, %edx
callq 0x1ae86
movq %r13, %rdi
callq 0xa564
incl %r12d
cmpl 0x9fa0(%rbx), %r12d
jb 0x21b8e
movl 0x798(%rbx), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x798(%rbx)
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x21db6
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x53a0
jmp 0x21db6
movq %rax, %rbx
jmp 0x21dac
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x21d9d
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x21d9d
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x21dac
movq (%rdi), %rax
callq *0x8(%rax)
leaq 0x40(%rsp), %rdi
callq 0xa564
movq %rbx, %rdi
callq 0x56e0