// File: 8igMac[P]random-forest/src/decision_tree.cpp
// Function: dataSet::get_data_from_file(char*, int, int, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>)
void dataSet::get_data_from_file(char* fileName, int num_attr, int num_cls, vector<string> formatTb)
{
	ifstream ifs(fileName, ifstream::in);
	string buffer;
	string classBuffer;
	size_t pos;
	stringstream ss;
	data_inst inst(num_attr, num_cls);

	for (int index = 0 ; ifs >> buffer; index++)
	{
		// replace ',' with ' '
		while ((pos = buffer.find(',')) != string::npos)
			buffer[pos] = ' ';

		// use stringstream to get data
		ss << buffer;
		for (int i=0; i<num_attr; i++)
			ss >> inst.attr[i];
		ss >> classBuffer;

		// store data index
		inst.inst_num = index;

		// covert class string to enum
		for (int i=0; i<(int)formatTb.size(); i++)
			if (classBuffer.compare(formatTb.at(i)) == 0)
			{
				inst.cls = i;
				break;
			}

		dataSet.push_back(inst);
		ss.clear();
	}

	ifs.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x480, %rsp            # imm = 0x480
movq %r8, -0x450(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x448(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x228(%rbp), %rdi
movl $0x8, %edx
callq 0x2280
leaq -0x248(%rbp), %rdi
callq 0x21e0
leaq -0x268(%rbp), %rdi
callq 0x21e0
leaq -0x3f8(%rbp), %rdi
callq 0x2100
jmp 0x4f3a
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
leaq -0x430(%rbp), %rdi
callq 0x4e40
jmp 0x4f4e
movl $0x0, -0x434(%rbp)
leaq -0x228(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0x21c0
movq %rax, -0x458(%rbp)
jmp 0x4f74
movq -0x458(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x21b0
movb %al, -0x459(%rbp)
jmp 0x4f92
movb -0x459(%rbp), %al
testb $0x1, %al
jne 0x4fa1
jmp 0x519c
jmp 0x4fa3
leaq -0x248(%rbp), %rdi
movl $0x2c, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x21d0
movq %rax, -0x270(%rbp)
cmpq $-0x1, %rax
je 0x503e
movq -0x270(%rbp), %rsi
leaq -0x248(%rbp), %rdi
callq 0x2290
movq %rax, -0x468(%rbp)
jmp 0x4fe1
movq -0x468(%rbp), %rax
movb $0x20, (%rax)
jmp 0x4fa3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x400(%rbp)
movl %eax, -0x404(%rbp)
jmp 0x51fb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x400(%rbp)
movl %eax, -0x404(%rbp)
jmp 0x51ef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x400(%rbp)
movl %eax, -0x404(%rbp)
leaq -0x430(%rbp), %rdi
callq 0x3540
jmp 0x51ef
leaq -0x3e8(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0x2150
jmp 0x5053
movl $0x0, -0x438(%rbp)
movl -0x438(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x509f
leaq -0x428(%rbp), %rdi
movslq -0x438(%rbp), %rsi
callq 0x7d30
movq %rax, %rsi
leaq -0x3f8(%rbp), %rdi
callq 0x2040
jmp 0x508c
jmp 0x508e
movl -0x438(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x438(%rbp)
jmp 0x505d
leaq -0x3f8(%rbp), %rdi
leaq -0x268(%rbp), %rsi
callq 0x21c0
jmp 0x50b4
movl -0x434(%rbp), %eax
movl %eax, -0x430(%rbp)
movl $0x0, -0x43c(%rbp)
movq -0x450(%rbp), %rdi
movl -0x43c(%rbp), %eax
movl %eax, -0x46c(%rbp)
callq 0x3ac0
movq %rax, %rcx
movl -0x46c(%rbp), %eax
cmpl %ecx, %eax
jge 0x5155
movq -0x450(%rbp), %rdi
movslq -0x43c(%rbp), %rsi
callq 0x7d50
movq %rax, -0x478(%rbp)
jmp 0x510b
movq -0x478(%rbp), %rsi
leaq -0x268(%rbp), %rdi
callq 0x2030
movl %eax, -0x47c(%rbp)
jmp 0x5126
movl -0x47c(%rbp), %eax
cmpl $0x0, %eax
jne 0x513f
movl -0x43c(%rbp), %eax
movl %eax, -0x410(%rbp)
jmp 0x5155
jmp 0x5141
movl -0x43c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x43c(%rbp)
jmp 0x50ca
movq -0x448(%rbp), %rdi
leaq -0x430(%rbp), %rsi
callq 0x7d90
jmp 0x516a
movq -0x3f8(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x3f8(%rbp,%rax), %rdi
xorl %esi, %esi
callq 0x2240
jmp 0x5186
jmp 0x5188
movl -0x434(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x434(%rbp)
jmp 0x4f58
leaq -0x228(%rbp), %rdi
callq 0x2050
jmp 0x51aa
leaq -0x430(%rbp), %rdi
callq 0x3540
leaq -0x3f8(%rbp), %rdi
callq 0x2120
leaq -0x268(%rbp), %rdi
callq 0x20f0
leaq -0x248(%rbp), %rdi
callq 0x20f0
leaq -0x228(%rbp), %rdi
callq 0x2060
addq $0x480, %rsp            # imm = 0x480
popq %rbp
retq
leaq -0x3f8(%rbp), %rdi
callq 0x2120
leaq -0x268(%rbp), %rdi
callq 0x20f0
leaq -0x248(%rbp), %rdi
callq 0x20f0
leaq -0x228(%rbp), %rdi
callq 0x2060
movq -0x400(%rbp), %rdi
callq 0x2270
nopl (%rax,%rax)