// File: /workspace/github_cpp_makefile_star2_O3/Konano[P]UselessDatabase/main.cpp
// Function: import_data(Table*, char const*, char)
void import_data(Table* table, const char* filename, char separator) {
    printf("%s\n",filename);
    ifstream inFile(filename, ios::in);
    string line;
    string field;
    int cnt = 0;
    Any* data = new Any[table->col_num];
    while (getline(inFile, line)) {
        istringstream sin(line); 
        memset(data, 0, table->col_num * sizeof(Any));
        for (uint i = 0; i < table->col_num; i++) {
            getline(sin, field, separator);  
            switch (table->col_ty[i].ty) {
            case INT:
                data[i] = atoi(field.c_str());
                break;
            case CHAR:
            case VARCHAR:
                data[i] = copyStr(field.c_str());
                break;
            case DATE:
                data[i] = date_to_uint(field);
                break;
            case DECIMAL:
                data[i] = strtold(field.c_str(), NULL);
                break;
            }
        }
        //table->index[table->p_key_index].Debug();
        int x = table->insertRecord(data);
        if (x != 0){
            if(data[0].anyCast<int>() != nullptr)
            printf("id:%d\n",*data[0].anyCast<int>());
            if(data[1].anyCast<char*>() != nullptr)
            printf("%s\n",*data[1].anyCast<char*>());
            printf("fail %d\n",x);
        }
        //table->index[table->p_key_index].Debug();
        cnt++;
    }
    delete []data;
    inFile.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x418, %rsp            # imm = 0x418
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r15
movq %rsi, %rdi
callq 0x55d0
leaq 0x210(%rsp), %rdi
movq %rbx, %rsi
movl $0x8, %edx
callq 0x5710
leaq 0x68(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x20(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
movl 0x54(%r15), %ebx
leaq 0x8(,%rbx,8), %rdi
callq 0x5040
movq %rbx, (%rax)
movq %rax, (%rsp)
movq %rax, %r13
addq $0x8, %r13
testq %rbx, %rbx
je 0x29c1b
shlq $0x3, %rbx
movq %r13, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x5240
leaq 0x7c(%r15), %rax
movq %rax, 0x78(%rsp)
movsbl %bpl, %eax
movl %eax, 0xc(%rsp)
leaq 0x38(%rsp), %rbp
movq %r15, 0x30(%rsp)
movq (%rsp), %rbx
movq 0x210(%rsp), %rax
movq -0x18(%rax), %rdi
leaq 0x210(%rsp), %r14
addq %r14, %rdi
movl $0xa, %esi
callq 0x5370
movsbl %al, %edx
movq %r14, %rdi
leaq 0x58(%rsp), %rsi
callq 0x5730
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x29f2d
leaq 0x90(%rsp), %rdi
leaq 0x58(%rsp), %rsi
movl $0x8, %edx
callq 0x5690
movl 0x54(%r15), %ebx
leaq (,%rbx,8), %rdx
movq %r13, %rdi
xorl %esi, %esi
callq 0x5240
testq %rbx, %rbx
je 0x29e7b
movq 0x78(%rsp), %r14
xorl %r12d, %r12d
leaq 0x90(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movl 0xc(%rsp), %edx
callq 0x5730
movl (%r14), %eax
cmpq $0x4, %rax
ja 0x29de0
leaq 0x16ffb(%rip), %rcx     # 0x40ce0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
callq 0x51f0
movq %rax, %rbx
leal 0x1(%rax), %edi
callq 0x5040
movq %rax, %r15
movq %rax, %rdi
movq %rbp, %rsi
callq 0x5360
movl %ebx, %eax
movb $0x0, (%r15,%rax)
movl $0x10, %edi
callq 0x5390
movq %rax, %rbx
leaq 0x28d21(%rip), %rax     # 0x52a50
movq %rax, (%rbx)
movq %r15, 0x8(%rbx)
movq (%r13,%r12,8), %rdi
testq %rdi, %rdi
je 0x29d46
movq (%rdi), %rax
callq *0x8(%rax)
movq %rbx, (%r13,%r12,8)
movq 0x30(%rsp), %r15
jmp 0x29ddb
movq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x5680
fstpt 0x84(%rsp)
movl $0x20, %edi
callq 0x5390
movq %rax, %rbx
leaq 0x28d24(%rip), %rax     # 0x52aa0
movq %rax, (%rbx)
fldt 0x84(%rsp)
fstpt 0x10(%rbx)
movq (%r13,%r12,8), %rdi
testq %rdi, %rdi
je 0x29d99
movq (%rdi), %rax
callq *0x8(%rax)
movq %rbx, (%r13,%r12,8)
jmp 0x29de0
movq 0x10(%rsp), %rdi
callq 0x55f0
movl %eax, %ebp
movl $0x10, %edi
callq 0x5390
movq %rax, %rbx
leaq 0x28cb8(%rip), %rax     # 0x52a78
movq %rax, (%rbx)
movl %ebp, 0x8(%rbx)
movq (%r13,%r12,8), %rdi
testq %rdi, %rdi
je 0x29dd6
movq (%rdi), %rax
callq *0x8(%rax)
movq %rbx, (%r13,%r12,8)
leaq 0x38(%rsp), %rbp
incq %r12
movl 0x54(%r15), %eax
addq $0x38, %r14
cmpq %rax, %r12
jb 0x29cbb
jmp 0x29e7b
leaq 0x48(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
addq %rsi, %rdx
movq %rbp, %rdi
callq 0xa5ec
movq %rbp, %rdi
callq 0x2dc87
movl %eax, %ebp
movl $0x10, %edi
callq 0x5390
movq %rax, %rbx
leaq 0x28e62(%rip), %rax     # 0x52c98
movq %rax, (%rbx)
movl %ebp, 0x8(%rbx)
movq (%r13,%r12,8), %rdi
testq %rdi, %rdi
je 0x29e4c
movq (%rdi), %rax
callq *0x8(%rax)
movq %rbx, (%r13,%r12,8)
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
leaq 0x38(%rsp), %rbp
je 0x29de0
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x53a0
jmp 0x29de0
movq %r15, %rdi
movq %r13, %rsi
callq 0x21b5a
movl %eax, %r15d
testl %eax, %eax
movq (%rsp), %rbx
je 0x29f02
movq (%r13), %rdi
testq %rdi, %rdi
je 0x29ec5
leaq 0x2883f(%rip), %rsi     # 0x526e0
leaq 0x28860(%rip), %rdx     # 0x52708
xorl %ecx, %ecx
callq 0x5430
testq %rax, %rax
je 0x29ec5
movl 0x8(%rax), %esi
leaq 0x16e36(%rip), %rdi     # 0x40cf4
xorl %eax, %eax
callq 0x5080
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x29ef1
leaq 0x2880b(%rip), %rsi     # 0x526e0
leaq 0x28814(%rip), %rdx     # 0x526f0
xorl %ecx, %ecx
callq 0x5430
testq %rax, %rax
je 0x29ef1
movq 0x8(%rax), %rdi
callq 0x55d0
leaq 0x194b9(%rip), %rdi     # 0x433b1
movl %r15d, %esi
xorl %eax, %eax
callq 0x5080
leaq 0x90(%rsp), %rdi
movq 0x290a7(%rip), %rsi     # 0x52fb8
callq 0x5540
leaq 0x108(%rsp), %rdi
callq 0x5170
movq 0x30(%rsp), %r15
jmp 0x29c3a
movq (%rbx), %rax
leaq (,%rax,8), %rbx
testq %rax, %rax
je 0x29f59
movq %rbx, %r14
movq (%rsp), %rax
movq (%rax,%r14), %rdi
testq %rdi, %rdi
je 0x29f53
movq (%rdi), %rax
callq *0x8(%rax)
addq $-0x8, %r14
jne 0x29f40
addq $0x8, %rbx
movq (%rsp), %rdi
movq %rbx, %rsi
callq 0x57b0
leaq 0x210(%rsp), %rdi
callq 0x5100
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x29f92
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x53a0
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x29fae
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x53a0
leaq 0x210(%rsp), %rdi
callq 0x5110
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x29fd3
jmp 0x2a001
jmp 0x29fd3
movq %rax, %rbx
jmp 0x2a025
jmp 0x2a001
jmp 0x2a001
jmp 0x2a001
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x2a004
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x53a0
jmp 0x2a004
jmp 0x2a001
movq %rax, %rbx
movq 0x28fad(%rip), %rsi     # 0x52fb8
leaq 0x90(%rsp), %rdi
callq 0x5540
leaq 0x108(%rsp), %rdi
callq 0x5170
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x2a041
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x53a0
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x2a05d
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x53a0
leaq 0x210(%rsp), %rdi
callq 0x5110
movq %rbx, %rdi
callq 0x56e0