// File: /workspace/github_cpp_makefile_star2_O2/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, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x55f0
leaq 0x210(%rsp), %rdi
pushq $0x8
popq %rdx
movq %r14, %rsi
callq 0x5720
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
leaq 0x40(%rsp), %rdx
movq %rdx, -0x10(%rdx)
andq $0x0, -0x8(%rdx)
movb %cl, (%rax)
movb %cl, (%rdx)
movl 0x54(%rbx), %r14d
leaq 0x8(,%r14,8), %rdi
callq 0x5040
movq %rax, %r15
movq %r14, (%rax)
leaq 0x8(%rax), %r12
testq %r14, %r14
je 0x22c0f
shlq $0x3, %r14
movq %r12, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x5270
movq %r15, %rax
addq $0x10, %rax
movq %rax, 0x18(%rsp)
leaq 0x7c(%rbx), %rax
movq %rax, 0x28(%rsp)
movsbl %bpl, %r14d
movq %r15, 0x20(%rsp)
movq %r12, 0x10(%rsp)
leaq 0x210(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x50f0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x22de8
leaq 0x90(%rsp), %rdi
leaq 0x50(%rsp), %rsi
pushq $0x8
popq %rdx
callq 0x56b0
movl 0x54(%rbx), %r12d
movq %r12, %rdx
shlq $0x3, %rdx
movq 0x10(%rsp), %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x5270
movq 0x28(%rsp), %r13
xorl %ebp, %ebp
movl %r12d, %eax
cmpq %rax, %rbp
jae 0x22d62
leaq 0x90(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movl %r14d, %edx
callq 0x5740
movl (%r13), %eax
cmpq $0x4, %rax
ja 0x22d4e
leaq 0x1557e(%rip), %rcx     # 0x38240
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x30(%rsp), %rdi
callq 0x27148
movq %rax, (%rsp)
movq %r15, %rdi
movq %rsp, %rsi
callq 0x20fa2
jmp 0x22d4e
movq 0x30(%rsp), %rdi
xorl %esi, %esi
callq 0x5808
fstpt (%rsp)
movq %r15, %rdi
movq %rsp, %rsi
callq 0x21006
jmp 0x22d4e
movq 0x30(%rsp), %rdi
callq 0x5600
movl %eax, (%rsp)
movq %r15, %rdi
movq %rsp, %rsi
callq 0x20f70
jmp 0x22d4e
leaq 0x70(%rsp), %r12
movq %r12, %rdi
leaq 0x30(%rsp), %rsi
callq 0x5530
movq %r12, %rdi
callq 0x2717f
movl %eax, (%rsp)
movq %r15, %rdi
movq %rsp, %rsi
callq 0x20fd4
leaq 0x70(%rsp), %rdi
callq 0x5200
incq %rbp
movl 0x54(%rbx), %r12d
addq $0x8, %r15
addq $0x38, %r13
jmp 0x22c8c
movq %rbx, %rdi
movq 0x10(%rsp), %r12
movq %r12, %rsi
callq 0x1c046
movl %eax, %r15d
testl %eax, %eax
je 0x22dd1
movq %r12, %rdi
callq 0x9410
testq %rax, %rax
je 0x22d9e
movq %r12, %rdi
callq 0x9410
movl (%rax), %esi
leaq 0x154bd(%rip), %rdi     # 0x38254
xorl %eax, %eax
callq 0x5070
movq 0x18(%rsp), %r13
movq %r13, %rdi
callq 0x9398
testq %rax, %rax
je 0x22dc0
movq %r13, %rdi
callq 0x9398
movq (%rax), %rdi
callq 0x55f0
leaq 0x17b82(%rip), %rdi     # 0x3a949
movl %r15d, %esi
xorl %eax, %eax
callq 0x5070
leaq 0x90(%rsp), %rdi
callq 0x5220
movq 0x20(%rsp), %r15
jmp 0x22c32
movq (%r15), %rax
leaq (,%rax,8), %rbx
testq %rax, %rax
je 0x22e10
movq %rbx, %r14
movq (%r15,%r14), %rdi
testq %rdi, %rdi
je 0x22e0a
movq (%rdi), %rax
callq *0x8(%rax)
addq $-0x8, %r14
jne 0x22dfb
addq $0x8, %rbx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x57c0
leaq 0x210(%rsp), %rdi
callq 0x5100
leaq 0x30(%rsp), %rdi
callq 0x5200
leaq 0x50(%rsp), %rdi
callq 0x5200
leaq 0x210(%rsp), %rdi
callq 0x5120
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x22e65
jmp 0x22e81
jmp 0x22e65
movq %rax, %rbx
jmp 0x22e91
jmp 0x22e81
jmp 0x22e81
jmp 0x22e81
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x5200
jmp 0x22e84
jmp 0x22e81
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x5220
leaq 0x30(%rsp), %rdi
callq 0x5200
leaq 0x50(%rsp), %rdi
callq 0x5200
leaq 0x210(%rsp), %rdi
callq 0x5120
movq %rbx, %rdi
callq 0x56f0