// File: /workspace/github_cpp_makefile_star2_O2/liujan[P]MPI_multi_thread_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;

	//all_samples.clear();

	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 0xf7c(%rip), %rsi       # 0x6166
leaq -0x2b0(%rbp), %rdi
pushq $0x8
popq %rdx
callq 0x2370
leaq -0x238(%rbp), %rdi
callq 0x2070
movl %eax, %r14d
testb %al, %al
je 0x532c
movq 0x4db9(%rip), %rdi      # 0x9fd0
leaq 0xf71(%rip), %rsi       # 0x618f
callq 0x21e0
movq %rax, %rdi
callq 0x2110
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 0x2050
leaq -0x2b0(%rbp), %r12
leaq -0x2a(%rbp), %rbx
leaq -0x60(%rbp), %r13
leaq -0x88(%rbp), %r14
movq %r12, %rdi
leaq -0x3c(%rbp), %rsi
callq 0x2140
movq -0x2b0(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x2, -0x290(%rbp,%rax)
jne 0x5354
xorps %xmm0, %xmm0
movaps %xmm0, -0x60(%rbp)
andq $0x0, -0x50(%rbp)
movl $0x269, %r15d           # imm = 0x269
subl $0x1, %r15d
jb 0x52cb
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2290
movq %r12, %rdi
movq %r14, %rsi
callq 0x2150
movq %r13, %rdi
movq %r14, %rsi
callq 0x5668
jmp 0x52a2
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2290
movq %r12, %rdi
leaq -0x30(%rbp), %rsi
callq 0x2140
movl -0x30(%rbp), %eax
movl %eax, -0x80(%rbp)
leaq -0x78(%rbp), %rdi
movq %r13, %rsi
callq 0x28c4
movq -0x38(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x57b4
leaq -0x78(%rbp), %rdi
callq 0x2726
movq %r12, %rdi
callq 0x20d0
cmpl $0xa, %eax
jne 0x531f
movq %r12, %rdi
callq 0x2260
movq %r13, %rdi
callq 0x2726
jmp 0x526b
movq 0x4c9d(%rip), %rdi      # 0x9fd0
leaq 0xe36(%rip), %rsi       # 0x6170
callq 0x21e0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x21c0
movq %rax, %rdi
callq 0x2110
jmp 0x538b
leaq -0x2b0(%rbp), %rdi
callq 0x2060
movq 0x4c69(%rip), %rdi      # 0x9fd0
leaq 0xe34(%rip), %rsi       # 0x61a2
callq 0x21e0
movq %rax, %rdi
callq 0x2110
leaq -0xa8(%rbp), %rdi
callq 0x2100
movb -0x29(%rbp), %r14b
leaq -0x2b0(%rbp), %rdi
callq 0x2080
movl %r14d, %eax
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x53c5
jmp 0x53c5
movq %rax, %rbx
jmp 0x53e4
jmp 0x53cc
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x2726
jmp 0x53cf
movq %rax, %rbx
jmp 0x53d8
jmp 0x53cc
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x2726
leaq -0xa8(%rbp), %rdi
callq 0x2100
leaq -0x2b0(%rbp), %rdi
callq 0x2080
movq %rbx, %rdi
callq 0x2340