// File: /workspace/github_cpp_makefile_star2_O2/liujan[P]randomforest/RandomForest.cpp
// Function: RandomForest::readTrainSample(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
bool RandomForest::readTrainSample(string file){
    ifstream train("train.csv");
    if (!train.is_open()){
        cout << "[Error] : Failed to open file " << file << endl;
        return false;
    }
    cout << "reading sample ..." << endl;
    
    string s;
    getline(train, s); //过滤掉第一行标签
    
    double value;
    char dot;
    int id;
    int label;
    while (true) {
        train >> id;
        if (train.eof())
            break;
        
        vector<double> features;
        for (int i = 0; i < numOfFeatures; i++){
            train >> dot;
            train >> value;
            features.push_back(value);
        }
        train >> dot;
        train >> label;
        all_samples.push_back(make_pair(label, features));
        
        if (train.peek() == '\n')
            train.get();
    }
    
    train.close();
    cout << "reading sample successful" << endl;
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
movq %rsi, %rbx
movq %rdi, -0x38(%rbp)
leaq 0x106b(%rip), %rsi      # 0x61af
leaq -0x2b0(%rbp), %rdi
pushq $0x8
popq %rdx
callq 0x22b0
leaq -0x238(%rbp), %rdi
callq 0x2060
movl %eax, %r14d
testb %al, %al
je 0x5286
movq 0x4e67(%rip), %rdi      # 0x9fd8
leaq 0x1060(%rip), %rsi      # 0x61d8
callq 0x21a0
movq %rax, %rdi
callq 0x20f0
movb %r14b, -0x29(%rbp)
leaq -0x98(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x2b0(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x2040
leaq -0x2b0(%rbp), %r12
leaq -0x2a(%rbp), %rbx
leaq -0x60(%rbp), %r13
leaq -0x88(%rbp), %r14
movq %r12, %rdi
leaq -0x3c(%rbp), %rsi
callq 0x2120
movq -0x2b0(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x2, -0x290(%rbp,%rax)
jne 0x52ae
xorps %xmm0, %xmm0
movaps %xmm0, -0x60(%rbp)
andq $0x0, -0x50(%rbp)
movl $0x269, %r15d           # imm = 0x269
subl $0x1, %r15d
jb 0x5225
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2210
movq %r12, %rdi
movq %r14, %rsi
callq 0x2130
movq %r13, %rdi
movq %r14, %rsi
callq 0x55f0
jmp 0x51fc
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2210
movq %r12, %rdi
leaq -0x30(%rbp), %rsi
callq 0x2120
movl -0x30(%rbp), %eax
movl %eax, -0x80(%rbp)
leaq -0x78(%rbp), %rdi
movq %r13, %rsi
callq 0x2804
movq -0x38(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x577a
leaq -0x78(%rbp), %rdi
callq 0x2666
movq %r12, %rdi
callq 0x20b0
cmpl $0xa, %eax
jne 0x5279
movq %r12, %rdi
callq 0x2200
movq %r13, %rdi
callq 0x2666
jmp 0x51c5
movq 0x4d4b(%rip), %rdi      # 0x9fd8
leaq 0xf25(%rip), %rsi       # 0x61b9
callq 0x21a0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2190
movq %rax, %rdi
callq 0x20f0
jmp 0x52e5
leaq -0x2b0(%rbp), %rdi
callq 0x2050
movq 0x4d17(%rip), %rdi      # 0x9fd8
leaq 0xf23(%rip), %rsi       # 0x61eb
callq 0x21a0
movq %rax, %rdi
callq 0x20f0
leaq -0xa8(%rbp), %rdi
callq 0x20e0
movb -0x29(%rbp), %r14b
leaq -0x2b0(%rbp), %rdi
callq 0x2070
movl %r14d, %eax
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x531f
jmp 0x531f
movq %rax, %rbx
jmp 0x533e
jmp 0x5326
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x2666
jmp 0x5329
movq %rax, %rbx
jmp 0x5332
jmp 0x5326
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x2666
leaq -0xa8(%rbp), %rdi
callq 0x20e0
leaq -0x2b0(%rbp), %rdi
callq 0x2070
movq %rbx, %rdi
callq 0x2290