// File: /workspace/github_cpp_makefile_star2_O1/liujan[P]multi_thread_randomforest/RandomForest.cpp
// Function: RandomForest::predict()
void RandomForest::predict(){
	if (this->test_samples.empty()){
		cout << "[Error] test sample is empty" << endl;
		return;
	}
	ofstream out("result.csv");
	if (!out.is_open()){
		cout << "[Error] failed to open file result.csv" << endl;
		return;
	}
	cout << "predicting ..." << endl;
	out << "Id,label" << "\n";

	for (int i = 0; i < numOfTest; i++){
		int max_value = -1000, index = 0;
		for (int j = 1; j < numOfTypes + 1; j++){
			if (r[i][j] > max_value){
				max_value = r[i][j];
				index = j;
			}
		}
		out << i << "," << index << "\n";
	}

	out.close();
	cout << "predicting completed" << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq 0x18(%rdi), %rax
cmpq 0x20(%rdi), %rax
je 0x52cd
movq %rdi, %rbx
leaq 0x1fde(%rip), %rsi      # 0x7178
leaq -0x228(%rbp), %rdi
movl $0x10, %edx
callq 0x2210
leaq -0x1b8(%rbp), %rdi
callq 0x2070
testb %al, %al
je 0x5320
movq 0x4e12(%rip), %r14      # 0x9fd8
leaq 0x1fb6(%rip), %rsi      # 0x7183
movl $0xe, %edx
movq %r14, %rdi
callq 0x2220
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq 0x4de0(%rip), %rdi      # 0x9fd8
callq 0x2040
movq %rax, %rdi
callq 0x2140
leaq 0x1f86(%rip), %rsi      # 0x7192
leaq -0x228(%rbp), %rdi
movl $0x8, %edx
callq 0x2220
leaq 0x1f77(%rip), %rsi      # 0x719b
leaq -0x228(%rbp), %rdi
movl $0x1, %edx
callq 0x2220
addq $0x34, %rbx
xorl %r14d, %r14d
leaq 0x1f58(%rip), %r13      # 0x719b
movl $0xfffffc18, %eax       # imm = 0xFFFFFC18
xorl %ecx, %ecx
xorl %r15d, %r15d
movl (%rbx,%rcx,4), %edx
incq %rcx
cmpl %eax, %edx
cmovgl %edx, %eax
cmovgl %ecx, %r15d
cmpq $0x1a, %rcx
jne 0x524d
leaq -0x228(%rbp), %rdi
movl %r14d, %esi
callq 0x22d0
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1f1a(%rip), %rsi      # 0x719d
callq 0x2220
movq %r12, %rdi
movl %r15d, %esi
callq 0x22d0
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x2220
incq %r14
addq $0x6c, %rbx
cmpq $0x617, %r14            # imm = 0x617
jne 0x5243
leaq -0x228(%rbp), %rdi
callq 0x2270
movl $0x14, %edx
leaq 0x1ed4(%rip), %rsi      # 0x719f
jmp 0x532c
movq 0x4d04(%rip), %rbx      # 0x9fd8
leaq 0x1e45(%rip), %rsi      # 0x7120
movl $0x1c, %edx
movq %rbx, %rdi
callq 0x2220
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2140
movl $0x26, %edx
leaq 0x1e30(%rip), %rsi      # 0x715c
movq 0x4ca5(%rip), %rbx      # 0x9fd8
movq %rbx, %rdi
callq 0x2220
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq 0x4c7f(%rip), %rdi      # 0x9fd8
callq 0x2040
movq %rax, %rdi
callq 0x2140
movq 0x4c63(%rip), %rax      # 0x9fd0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x220(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x228(%rbp,%rcx)
callq 0x2190
leaq -0x130(%rbp), %rdi
callq 0x20b0
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x53b0
movq %rax, %rbx
leaq -0x228(%rbp), %rdi
callq 0x2290
movq %rbx, %rdi
callq 0x22e0
nop