// File: 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
subq $0x310, %rsp            # imm = 0x310
movq %rsi, -0x2c8(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x2c0(%rbp)
leaq 0x1ff8(%rip), %rsi      # 0x10194
leaq -0x220(%rbp), %rdi
movq %rdi, -0x2b8(%rbp)
movl $0x8, %edx
callq 0x2360
movq -0x2b8(%rbp), %rdi
callq 0x22f0
movb %al, -0x2a9(%rbp)
jmp 0xe1c8
movb -0x2a9(%rbp), %al
testb $0x1, %al
jne 0xe24b
jmp 0xe1d4
movq 0xadfd(%rip), %rdi      # 0x18fd8
leaq 0x1fbc(%rip), %rsi      # 0x1019e
callq 0x21c0
movq %rax, -0x2d0(%rbp)
jmp 0xe1f0
movq -0x2c8(%rbp), %rsi
movq -0x2d0(%rbp), %rdi
callq 0x21b0
movq %rax, -0x2d8(%rbp)
jmp 0xe20c
movq -0x2d8(%rbp), %rdi
movq 0xadae(%rip), %rsi      # 0x18fc8
callq 0x2200
jmp 0xe221
movb $0x0, -0x1(%rbp)
movl $0x1, -0x230(%rbp)
jmp 0xe4dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0xe4f6
movq 0xad86(%rip), %rdi      # 0x18fd8
leaq 0x1f64(%rip), %rsi      # 0x101bd
callq 0x21c0
movq %rax, -0x2e0(%rbp)
jmp 0xe267
movq -0x2e0(%rbp), %rdi
movq 0xad53(%rip), %rsi      # 0x18fc8
callq 0x2200
jmp 0xe27c
leaq -0x250(%rbp), %rdi
movq %rdi, -0x2e8(%rbp)
callq 0x22a0
movq -0x2e8(%rbp), %rsi
leaq -0x220(%rbp), %rdi
callq 0x2050
jmp 0xe2a4
jmp 0xe2a6
jmp 0xe2a8
leaq -0x220(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x2100
jmp 0xe2bd
movq -0x220(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x220(%rbp,%rax), %rdi
callq 0x2370
movb %al, -0x2e9(%rbp)
jmp 0xe2dd
movb -0x2e9(%rbp), %al
testb $0x1, %al
jne 0xe2e9
jmp 0xe305
jmp 0xe473
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0xe4ce
leaq -0x280(%rbp), %rdi
callq 0xe980
movl $0x0, -0x284(%rbp)
cmpl $0x269, -0x284(%rbp)    # imm = 0x269
jge 0xe390
leaq -0x220(%rbp), %rdi
leaq -0x259(%rbp), %rsi
callq 0x2290
jmp 0xe33c
leaq -0x220(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x2180
jmp 0xe351
leaq -0x280(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0xe9a0
jmp 0xe366
jmp 0xe368
movl -0x284(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x284(%rbp)
jmp 0xe31b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0xe465
leaq -0x220(%rbp), %rdi
leaq -0x259(%rbp), %rsi
callq 0x2290
jmp 0xe3a5
leaq -0x220(%rbp), %rdi
leaq -0x264(%rbp), %rsi
callq 0x2100
jmp 0xe3ba
movq -0x2c0(%rbp), %rax
movq %rax, -0x2f8(%rbp)
leaq -0x2a8(%rbp), %rdi
leaq -0x264(%rbp), %rsi
leaq -0x280(%rbp), %rdx
callq 0xea40
jmp 0xe3e4
movq -0x2f8(%rbp), %rdi
leaq -0x2a8(%rbp), %rsi
callq 0xea10
jmp 0xe3f9
leaq -0x2a8(%rbp), %rdi
callq 0x2b50
leaq -0x220(%rbp), %rdi
callq 0x20b0
movl %eax, -0x2fc(%rbp)
jmp 0xe419
movl -0x2fc(%rbp), %eax
cmpl $0xa, %eax
jne 0xe454
leaq -0x220(%rbp), %rdi
callq 0x2270
jmp 0xe432
jmp 0xe454
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x2a8(%rbp), %rdi
callq 0x2b50
jmp 0xe465
leaq -0x280(%rbp), %rdi
callq 0x2b70
jmp 0xe2a6
leaq -0x280(%rbp), %rdi
callq 0x2b70
jmp 0xe4ce
leaq -0x220(%rbp), %rdi
callq 0x2060
jmp 0xe481
movq 0xab50(%rip), %rdi      # 0x18fd8
leaq 0x1d41(%rip), %rsi      # 0x101d0
callq 0x21c0
movq %rax, -0x308(%rbp)
jmp 0xe49d
movq -0x308(%rbp), %rdi
movq 0xab1d(%rip), %rsi      # 0x18fc8
callq 0x2200
jmp 0xe4b2
movb $0x1, -0x1(%rbp)
movl $0x1, -0x230(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x2110
jmp 0xe4dc
leaq -0x250(%rbp), %rdi
callq 0x2110
jmp 0xe4f6
leaq -0x220(%rbp), %rdi
callq 0x2070
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x310, %rsp            # imm = 0x310
popq %rbp
retq
leaq -0x220(%rbp), %rdi
callq 0x2070
movq -0x228(%rbp), %rdi
callq 0x2330
nop