// File: /workspace/github_cpp_makefile_star2_O3/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 0x1c59a
leaq 0x40(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r12, %rcx
movl $0x19, %r8d
callq 0x18c64
movl 0x798(%rbx), %eax
imulq $0x98, %rax, %rax
leaq (%rbx,%rax), %r15
addq $0x7a0, %r15            # imm = 0x7A0
movups 0x40(%rsp), %xmm0
movups 0x50(%rsp), %xmm1
movups 0x5c(%rsp), %xmm2
movups %xmm2, 0x1c(%r15)
movups %xmm1, 0x10(%r15)
movups %xmm0, (%r15)
movq 0x30(%r15), %rdi
movq 0x40(%r15), %rsi
movups 0x70(%rsp), %xmm0
movups %xmm0, 0x30(%r15)
movq 0x80(%rsp), %rax
movq %rax, 0x40(%r15)
xorps %xmm1, %xmm1
movups %xmm1, 0x70(%rsp)
movq $0x0, 0x80(%rsp)
testq %rdi, %rdi
je 0x2152f
subq %rdi, %rsi
callq 0x53a0
xorps %xmm1, %xmm1
movq 0x48(%r15), %rdi
movq 0x58(%r15), %rsi
movups 0x88(%rsp), %xmm0
movups %xmm0, 0x48(%r15)
movq 0x98(%rsp), %rax
movq %rax, 0x58(%r15)
movups %xmm1, 0x88(%rsp)
movq $0x0, 0x98(%rsp)
testq %rdi, %rdi
je 0x21571
subq %rdi, %rsi
callq 0x53a0
movq 0xb0(%rsp), %rax
movq %rax, 0x70(%r15)
movups 0xa0(%rsp), %xmm0
movups %xmm0, 0x60(%r15)
movq 0x78(%r15), %rdi
movq 0x88(%r15), %rsi
movups 0xb8(%rsp), %xmm0
movups %xmm0, 0x78(%r15)
movq 0xc8(%rsp), %rax
movq %rax, 0x88(%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0xb8(%rsp)
movq $0x0, 0xc8(%rsp)
testq %rdi, %rdi
je 0x21603
subq %rdi, %rsi
callq 0x53a0
movq 0xb8(%rsp), %rdi
movq 0xd0(%rsp), %rax
movq %rax, 0x90(%r15)
testq %rdi, %rdi
je 0x21612
movq 0xc8(%rsp), %rsi
subq %rdi, %rsi
callq 0x53a0
jmp 0x21612
movq 0xd0(%rsp), %rax
movq %rax, 0x90(%r15)
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x2162f
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x53a0
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x21649
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 0x2166c
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x53a0
movl 0x798(%rbx), %eax
imulq $0x98, %rax, %rdi
addq 0x8(%rsp), %rdi
callq 0x19088
cmpl $0x0, 0x9fa0(%rbx)
je 0x2184f
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 0x6722
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 0x2183f
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 0x21815
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 0x21786
leaq 0x1f247(%rip), %rdi     # 0x409a4
movslq (%rdi,%rbp,4), %rsi
addq %rdi, %rsi
jmpq *%rsi
movl $0x4, %r13d
jmp 0x2178c
movl $0x10, %r13d
jmp 0x2178c
movzbl 0x28(%r15,%rdx), %r13d
jmp 0x2178c
movl $0x8, %r13d
jmp 0x2178c
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl (%rax,%rcx,4), %esi
movq %rbx, %rdi
callq 0x22ed2
movq %rbx, %rdi
leaq 0x20(%rsp), %rsi
movl %ebp, %edx
movl %r13d, %ecx
movq %rsp, %r8
movl %eax, %r9d
callq 0x21a40
leaq 0x40(%rsp), %r13
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x217c5
movq (%rdi), %rax
callq *0x10(%rax)
jmp 0x217c7
xorl %eax, %eax
movq %rax, 0x10(%rsp)
movq %r13, %rdi
leaq 0x10(%rsp), %rsi
callq 0x9f9a
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x217e9
movq (%rdi), %rax
callq *0x8(%rax)
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x217f8
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 0x21725
movl 0x798(%rbx), %eax
imulq $0x98, %rax, %rdi
addq 0x8(%rsp), %rdi
movq %r13, %rsi
movq 0x18(%rsp), %r12
movl %r12d, %edx
callq 0x1a6ca
movq %r13, %rdi
callq 0xa37e
incl %r12d
cmpl 0x9fa0(%rbx), %r12d
jb 0x2169c
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 0x218c2
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x53a0
jmp 0x218c2
movq %rax, %rbx
jmp 0x218b8
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x218a9
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x218a9
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x218b8
movq (%rdi), %rax
callq *0x8(%rax)
leaq 0x40(%rsp), %rdi
callq 0xa37e
movq %rbx, %rdi
callq 0x56e0