// File: /workspace/github_cpp_makefile_star2_O1/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, %r13
movq %rsi, %rdi
callq 0x55d0
leaq 0x210(%rsp), %rdi
movq %r14, %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(%r13), %r14d
leaq 0x8(,%r14,8), %rdi
callq 0x5040
movq %rax, %rbx
movq %r14, (%rax)
movq %rax, %r12
addq $0x8, %r12
testq %r14, %r14
je 0x2a2e2
shlq $0x3, %r14
movq %r12, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x5240
leaq 0x7c(%r13), %rax
movq %rax, 0x78(%rsp)
movsbl %bpl, %eax
movl %eax, 0xc(%rsp)
leaq 0x38(%rsp), %rbp
movq %r13, 0x30(%rsp)
movq %rbx, (%rsp)
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 0x2a62a
leaq 0x90(%rsp), %rdi
leaq 0x58(%rsp), %rsi
movl $0x8, %edx
callq 0x5690
movl 0x54(%r13), %ebx
leaq (,%rbx,8), %rdx
movq %r12, %rdi
xorl %esi, %esi
callq 0x5240
testq %rbx, %rbx
je 0x2a53e
movq 0x78(%rsp), %rbx
xorl %r15d, %r15d
leaq 0x90(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movl 0xc(%rsp), %edx
callq 0x5730
movl (%rbx), %eax
cmpq $0x4, %rax
ja 0x2a4a4
leaq 0x17905(%rip), %rcx     # 0x41cb0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
callq 0x51f0
movq %rax, %r13
leal 0x1(%rax), %edi
callq 0x5040
movq %rax, %r14
movq %rax, %rdi
movq %rbp, %rsi
callq 0x5360
movl %r13d, %eax
movb $0x0, (%r14,%rax)
movl $0x10, %edi
callq 0x5390
movq %rax, %r13
leaq 0x2965a(%rip), %rax     # 0x53a50
movq %rax, (%r13)
movq %r14, 0x8(%r13)
movq (%r12,%r15,8), %rdi
testq %rdi, %rdi
je 0x2a40d
movq (%rdi), %rax
callq *0x8(%rax)
movq %r13, (%r12,%r15,8)
movq 0x30(%rsp), %r13
jmp 0x2a49f
movq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x5680
fstpt 0x84(%rsp)
movl $0x20, %edi
callq 0x5390
movq %rax, %r14
leaq 0x2965e(%rip), %rax     # 0x53aa0
movq %rax, (%r14)
fldt 0x84(%rsp)
fstpt 0x10(%r14)
movq (%r12,%r15,8), %rdi
testq %rdi, %rdi
je 0x2a45f
movq (%rdi), %rax
callq *0x8(%rax)
movq %r14, (%r12,%r15,8)
jmp 0x2a4a4
movq 0x10(%rsp), %rdi
callq 0x55f0
movl %eax, %ebp
movl $0x10, %edi
callq 0x5390
movq %rax, %r14
leaq 0x295f3(%rip), %rax     # 0x53a78
movq %rax, (%r14)
movl %ebp, 0x8(%r14)
movq (%r12,%r15,8), %rdi
testq %rdi, %rdi
je 0x2a49b
movq (%rdi), %rax
callq *0x8(%rax)
movq %r14, (%r12,%r15,8)
leaq 0x38(%rsp), %rbp
incq %r15
movl 0x54(%r13), %eax
addq $0x38, %rbx
cmpq %rax, %r15
jb 0x2a382
jmp 0x2a53e
leaq 0x48(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
addq %rsi, %rdx
movq %rbp, %rdi
callq 0xa88e
movq %rbp, %rdi
callq 0x2e3e0
movl %eax, %ebp
movl $0x10, %edi
callq 0x5390
movq %rax, %r14
leaq 0x2979e(%rip), %rax     # 0x53c98
movq %rax, (%r14)
movl %ebp, 0x8(%r14)
movq (%r12,%r15,8), %rdi
testq %rdi, %rdi
je 0x2a510
movq (%rdi), %rax
callq *0x8(%rax)
movq %r14, (%r12,%r15,8)
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
leaq 0x38(%rsp), %rbp
je 0x2a4a4
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x53a0
jmp 0x2a4a4
movq %r13, %rdi
movq %r12, %rsi
callq 0x22046
movl %eax, %r14d
testl %eax, %eax
movq (%rsp), %rbx
je 0x2a604
movq (%r12), %r13
testq %r13, %r13
je 0x2a5a7
movq %r13, %rdi
leaq 0x2913d(%rip), %rsi     # 0x536a8
leaq 0x2915e(%rip), %rdx     # 0x536d0
xorl %ecx, %ecx
callq 0x5430
testq %rax, %rax
je 0x2a5a7
movq %r13, %rdi
leaq 0x29120(%rip), %rsi     # 0x536a8
leaq 0x29141(%rip), %rdx     # 0x536d0
xorl %ecx, %ecx
callq 0x5430
movl 0x8(%rax), %esi
leaq 0x17724(%rip), %rdi     # 0x41cc4
xorl %eax, %eax
callq 0x5080
movq 0x10(%rbx), %r13
testq %r13, %r13
je 0x2a5ee
movq %r13, %rdi
leaq 0x290ee(%rip), %rsi     # 0x536a8
leaq 0x290f7(%rip), %rdx     # 0x536b8
xorl %ecx, %ecx
callq 0x5430
testq %rax, %rax
je 0x2a5ee
movq %r13, %rdi
leaq 0x290d1(%rip), %rsi     # 0x536a8
leaq 0x290da(%rip), %rdx     # 0x536b8
xorl %ecx, %ecx
callq 0x5430
movq 0x8(%rax), %rdi
callq 0x55d0
leaq 0x19d80(%rip), %rdi     # 0x44375
movl %r14d, %esi
xorl %eax, %eax
callq 0x5080
movq 0x30(%rsp), %r13
leaq 0x90(%rsp), %rdi
movq 0x299a5(%rip), %rsi     # 0x53fb8
callq 0x5540
leaq 0x108(%rsp), %rdi
callq 0x5170
jmp 0x2a301
movq (%rbx), %rax
leaq (,%rax,8), %rbx
testq %rax, %rax
je 0x2a656
movq %rbx, %r14
movq (%rsp), %rax
movq (%rax,%r14), %rdi
testq %rdi, %rdi
je 0x2a650
movq (%rdi), %rax
callq *0x8(%rax)
addq $-0x8, %r14
jne 0x2a63d
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 0x2a68f
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x53a0
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x2a6ab
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 0x2a6d0
jmp 0x2a6fe
jmp 0x2a6d0
movq %rax, %rbx
jmp 0x2a722
jmp 0x2a6fe
jmp 0x2a6fe
jmp 0x2a6fe
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x2a701
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x53a0
jmp 0x2a701
jmp 0x2a6fe
movq %rax, %rbx
movq 0x298b0(%rip), %rsi     # 0x53fb8
leaq 0x90(%rsp), %rdi
callq 0x5540
leaq 0x108(%rsp), %rdi
callq 0x5170
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x2a73e
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x53a0
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x2a75a
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x53a0
leaq 0x210(%rsp), %rdi
callq 0x5110
movq %rbx, %rdi
callq 0x56e0