// File: liujan[P]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;
	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 0x1dbd(%rip), %rsi      # 0x10199
leaq -0x220(%rbp), %rdi
movq %rdi, -0x2b8(%rbp)
movl $0x8, %edx
callq 0x23c0
movq -0x2b8(%rbp), %rdi
callq 0x2330
movb %al, -0x2a9(%rbp)
jmp 0xe408
movb -0x2a9(%rbp), %al
testb $0x1, %al
jne 0xe48b
jmp 0xe414
movq 0xabbd(%rip), %rdi      # 0x18fd8
leaq 0x1d81(%rip), %rsi      # 0x101a3
callq 0x21f0
movq %rax, -0x2d0(%rbp)
jmp 0xe430
movq -0x2c8(%rbp), %rsi
movq -0x2d0(%rbp), %rdi
callq 0x21d0
movq %rax, -0x2d8(%rbp)
jmp 0xe44c
movq -0x2d8(%rbp), %rdi
movq 0xab6e(%rip), %rsi      # 0x18fc8
callq 0x2230
jmp 0xe461
movb $0x0, -0x1(%rbp)
movl $0x1, -0x230(%rbp)
jmp 0xe71c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0xe736
movq 0xab46(%rip), %rdi      # 0x18fd8
leaq 0x1d29(%rip), %rsi      # 0x101c2
callq 0x21f0
movq %rax, -0x2e0(%rbp)
jmp 0xe4a7
movq -0x2e0(%rbp), %rdi
movq 0xab13(%rip), %rsi      # 0x18fc8
callq 0x2230
jmp 0xe4bc
leaq -0x250(%rbp), %rdi
movq %rdi, -0x2e8(%rbp)
callq 0x22e0
movq -0x2e8(%rbp), %rsi
leaq -0x220(%rbp), %rdi
callq 0x2060
jmp 0xe4e4
jmp 0xe4e6
jmp 0xe4e8
leaq -0x220(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x2110
jmp 0xe4fd
movq -0x220(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x220(%rbp,%rax), %rdi
callq 0x23d0
movb %al, -0x2e9(%rbp)
jmp 0xe51d
movb -0x2e9(%rbp), %al
testb $0x1, %al
jne 0xe529
jmp 0xe545
jmp 0xe6b3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0xe70e
leaq -0x280(%rbp), %rdi
callq 0xeb10
movl $0x0, -0x284(%rbp)
cmpl $0x269, -0x284(%rbp)    # imm = 0x269
jge 0xe5d0
leaq -0x220(%rbp), %rdi
leaq -0x259(%rbp), %rsi
callq 0x22d0
jmp 0xe57c
leaq -0x220(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x21a0
jmp 0xe591
leaq -0x280(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0xeb30
jmp 0xe5a6
jmp 0xe5a8
movl -0x284(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x284(%rbp)
jmp 0xe55b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0xe6a5
leaq -0x220(%rbp), %rdi
leaq -0x259(%rbp), %rsi
callq 0x22d0
jmp 0xe5e5
leaq -0x220(%rbp), %rdi
leaq -0x264(%rbp), %rsi
callq 0x2110
jmp 0xe5fa
movq -0x2c0(%rbp), %rax
movq %rax, -0x2f8(%rbp)
leaq -0x2a8(%rbp), %rdi
leaq -0x264(%rbp), %rsi
leaq -0x280(%rbp), %rdx
callq 0xebd0
jmp 0xe624
movq -0x2f8(%rbp), %rdi
leaq -0x2a8(%rbp), %rsi
callq 0xeba0
jmp 0xe639
leaq -0x2a8(%rbp), %rdi
callq 0x2bb0
leaq -0x220(%rbp), %rdi
callq 0x20c0
movl %eax, -0x2fc(%rbp)
jmp 0xe659
movl -0x2fc(%rbp), %eax
cmpl $0xa, %eax
jne 0xe694
leaq -0x220(%rbp), %rdi
callq 0x22a0
jmp 0xe672
jmp 0xe694
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x2a8(%rbp), %rdi
callq 0x2bb0
jmp 0xe6a5
leaq -0x280(%rbp), %rdi
callq 0x2bd0
jmp 0xe4e6
leaq -0x280(%rbp), %rdi
callq 0x2bd0
jmp 0xe70e
leaq -0x220(%rbp), %rdi
callq 0x2070
jmp 0xe6c1
movq 0xa910(%rip), %rdi      # 0x18fd8
leaq 0x1b06(%rip), %rsi      # 0x101d5
callq 0x21f0
movq %rax, -0x308(%rbp)
jmp 0xe6dd
movq -0x308(%rbp), %rdi
movq 0xa8dd(%rip), %rsi      # 0x18fc8
callq 0x2230
jmp 0xe6f2
movb $0x1, -0x1(%rbp)
movl $0x1, -0x230(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x2120
jmp 0xe71c
leaq -0x250(%rbp), %rdi
callq 0x2120
jmp 0xe736
leaq -0x220(%rbp), %rdi
callq 0x2080
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x310, %rsp            # imm = 0x310
popq %rbp
retq
leaq -0x220(%rbp), %rdi
callq 0x2080
movq -0x228(%rbp), %rdi
callq 0x2370
nop