// File: 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
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 0x758f(%rip), %rsi      # 0x1d14b
leaq -0x220(%rbp), %rdi
movq %rdi, -0x2b8(%rbp)
movl $0x8, %edx
callq 0x9cb0
movq -0x2b8(%rbp), %rdi
callq 0x9ae0
movb %al, -0x2a9(%rbp)
jmp 0x15be8
movb -0x2a9(%rbp), %al
testb $0x1, %al
jne 0x15c6b
jmp 0x15bf4
movq 0x133d5(%rip), %rdi     # 0x28fd0
leaq 0x7553(%rip), %rsi      # 0x1d155
callq 0x9660
movq %rax, -0x2d0(%rbp)
jmp 0x15c10
movq -0x2c8(%rbp), %rsi
movq -0x2d0(%rbp), %rdi
callq 0x95d0
movq %rax, -0x2d8(%rbp)
jmp 0x15c2c
movq -0x2d8(%rbp), %rdi
movq 0x1336e(%rip), %rsi     # 0x28fa8
callq 0x96b0
jmp 0x15c41
movb $0x0, -0x1(%rbp)
movl $0x1, -0x230(%rbp)
jmp 0x15efc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x15f16
movq 0x1335e(%rip), %rdi     # 0x28fd0
leaq 0x74fb(%rip), %rsi      # 0x1d174
callq 0x9660
movq %rax, -0x2e0(%rbp)
jmp 0x15c87
movq -0x2e0(%rbp), %rdi
movq 0x13313(%rip), %rsi     # 0x28fa8
callq 0x96b0
jmp 0x15c9c
leaq -0x250(%rbp), %rdi
movq %rdi, -0x2e8(%rbp)
callq 0x9960
movq -0x2e8(%rbp), %rsi
leaq -0x220(%rbp), %rdi
callq 0x90f0
jmp 0x15cc4
jmp 0x15cc6
jmp 0x15cc8
leaq -0x220(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x93a0
jmp 0x15cdd
movq -0x220(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x220(%rbp,%rax), %rdi
callq 0x9cc0
movb %al, -0x2e9(%rbp)
jmp 0x15cfd
movb -0x2e9(%rbp), %al
testb $0x1, %al
jne 0x15d09
jmp 0x15d25
jmp 0x15e93
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x15eee
leaq -0x280(%rbp), %rdi
callq 0x16340
movl $0x0, -0x284(%rbp)
cmpl $0x269, -0x284(%rbp)    # imm = 0x269
jge 0x15db0
leaq -0x220(%rbp), %rdi
leaq -0x259(%rbp), %rsi
callq 0x98f0
jmp 0x15d5c
leaq -0x220(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x9530
jmp 0x15d71
leaq -0x280(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x16360
jmp 0x15d86
jmp 0x15d88
movl -0x284(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x284(%rbp)
jmp 0x15d3b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x15e85
leaq -0x220(%rbp), %rdi
leaq -0x259(%rbp), %rsi
callq 0x98f0
jmp 0x15dc5
leaq -0x220(%rbp), %rdi
leaq -0x264(%rbp), %rsi
callq 0x93a0
jmp 0x15dda
movq -0x2c0(%rbp), %rax
movq %rax, -0x2f8(%rbp)
leaq -0x2a8(%rbp), %rdi
leaq -0x264(%rbp), %rsi
leaq -0x280(%rbp), %rdx
callq 0x16400
jmp 0x15e04
movq -0x2f8(%rbp), %rdi
leaq -0x2a8(%rbp), %rsi
callq 0x163d0
jmp 0x15e19
leaq -0x2a8(%rbp), %rdi
callq 0xa560
leaq -0x220(%rbp), %rdi
callq 0x9220
movl %eax, -0x2fc(%rbp)
jmp 0x15e39
movl -0x2fc(%rbp), %eax
cmpl $0xa, %eax
jne 0x15e74
leaq -0x220(%rbp), %rdi
callq 0x9800
jmp 0x15e52
jmp 0x15e74
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x2a8(%rbp), %rdi
callq 0xa560
jmp 0x15e85
leaq -0x280(%rbp), %rdi
callq 0xa580
jmp 0x15cc6
leaq -0x280(%rbp), %rdi
callq 0xa580
jmp 0x15eee
leaq -0x220(%rbp), %rdi
callq 0x9120
jmp 0x15ea1
movq 0x13128(%rip), %rdi     # 0x28fd0
leaq 0x72d8(%rip), %rsi      # 0x1d187
callq 0x9660
movq %rax, -0x308(%rbp)
jmp 0x15ebd
movq -0x308(%rbp), %rdi
movq 0x130dd(%rip), %rsi     # 0x28fa8
callq 0x96b0
jmp 0x15ed2
movb $0x1, -0x1(%rbp)
movl $0x1, -0x230(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x93b0
jmp 0x15efc
leaq -0x250(%rbp), %rdi
callq 0x93b0
jmp 0x15f16
leaq -0x220(%rbp), %rdi
callq 0x9170
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x310, %rsp            # imm = 0x310
popq %rbp
retq
leaq -0x220(%rbp), %rdi
callq 0x9170
movq -0x228(%rbp), %rdi
callq 0x9c10
nop