// File: /workspace/github_cpp_makefile_star2_O3/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, %r15
movq %rdi, -0x58(%rbp)
leaq 0x1ece(%rip), %rsi      # 0x7166
leaq -0x2b0(%rbp), %rbx
movq %rbx, %rdi
movl $0x8, %edx
callq 0x2380
leaq -0x238(%rbp), %rdi
callq 0x2070
movl %eax, %r14d
testb %al, %al
je 0x546b
movq 0x4d06(%rip), %r15      # 0x9fd0
leaq 0x1ebe(%rip), %rsi      # 0x718f
movl $0x12, %edx
movq %r15, %rdi
callq 0x2240
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq 0x4cd4(%rip), %rdi      # 0x9fd0
callq 0x2040
movq %rax, %rdi
callq 0x2150
movb %r14b, -0x29(%rbp)
leaq -0x70(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq -0x2b0(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %edx
leaq -0x2b0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x2390
leaq -0x2b0(%rbp), %r12
leaq -0x2a(%rbp), %rbx
leaq -0x60(%rbp), %r15
leaq -0x50(%rbp), %r13
movq %r12, %rdi
leaq -0x84(%rbp), %rsi
callq 0x2130
movq -0x2b0(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x2, -0x290(%rbp,%rax)
jne 0x54c2
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
movl $0x269, %r14d           # imm = 0x269
movq %r12, %rdi
movq %rbx, %rsi
callq 0x22a0
movq %r12, %rdi
movq %r15, %rsi
callq 0x2140
movq -0x48(%rbp), %rsi
cmpq -0x40(%rbp), %rsi
je 0x53ce
movsd -0x60(%rbp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, -0x48(%rbp)
jmp 0x53d9
movq %r13, %rdi
movq %r15, %rdx
callq 0x5960
decl %r14d
jne 0x539b
movq %r12, %rdi
movq %rbx, %rsi
callq 0x22a0
movq %r12, %rdi
leaq -0x30(%rbp), %rsi
callq 0x2130
movl -0x30(%rbp), %eax
movl %eax, -0xa8(%rbp)
leaq -0xa0(%rbp), %rdi
movq %r13, %rsi
callq 0x2a0c
movq -0x58(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x5a86
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0x5438
movq -0x90(%rbp), %rsi
subq %rdi, %rsi
callq 0x2200
movq %r12, %rdi
callq 0x20e0
cmpl $0xa, %eax
jne 0x544d
movq %r12, %rdi
callq 0x2270
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x535e
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x2200
jmp 0x535e
movq 0x4b5e(%rip), %rdi      # 0x9fd0
leaq 0x1cf7(%rip), %rsi      # 0x7170
movl $0x1e, %edx
callq 0x2240
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq 0x4b3f(%rip), %rdi      # 0x9fd0
callq 0x2240
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
jmp 0x5531
leaq -0x2b0(%rbp), %rdi
callq 0x2060
movq 0x4afb(%rip), %rbx      # 0x9fd0
leaq 0x1cc6(%rip), %rsi      # 0x71a2
movl $0x19, %edx
movq %rbx, %rdi
callq 0x2240
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq 0x4ac9(%rip), %rdi      # 0x9fd0
callq 0x2040
movq %rax, %rdi
callq 0x2150
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
movb -0x29(%rbp), %r14b
je 0x5531
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x2200
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 0x557d
jmp 0x557d
movq %rax, %rbx
jmp 0x55b5
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0x5587
movq -0x90(%rbp), %rsi
subq %rdi, %rsi
callq 0x2200
jmp 0x5587
jmp 0x5584
movq %rax, %rbx
jmp 0x559c
jmp 0x5584
movq %rax, %rbx
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x559c
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x2200
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x55b5
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x2200
leaq -0x2b0(%rbp), %rdi
callq 0x2080
movq %rbx, %rdi
callq 0x2350
nop