// File: 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
subq $0x280, %rsp            # imm = 0x280
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x230(%rbp)
addq $0x18, %rdi
callq 0x6090
testb $0x1, %al
jne 0xe0e9
jmp 0xe110
movq 0xaee8(%rip), %rdi      # 0x18fd8
leaq 0x200e(%rip), %rsi      # 0x10105
callq 0x21f0
movq %rax, %rdi
movq 0xaec2(%rip), %rsi      # 0x18fc8
callq 0x2230
jmp 0xe39a
leaq 0x2046(%rip), %rsi      # 0x1015d
leaq -0x208(%rbp), %rdi
movq %rdi, -0x240(%rbp)
movl $0x10, %edx
callq 0x2260
movq -0x240(%rbp), %rdi
callq 0x2170
movb %al, -0x231(%rbp)
jmp 0xe143
movb -0x231(%rbp), %al
testb $0x1, %al
jne 0xe1b2
jmp 0xe14f
movq 0xae82(%rip), %rdi      # 0x18fd8
leaq 0x1fe4(%rip), %rsi      # 0x10141
callq 0x21f0
movq %rax, -0x248(%rbp)
jmp 0xe16b
movq -0x248(%rbp), %rdi
movq 0xae4f(%rip), %rsi      # 0x18fc8
callq 0x2230
jmp 0xe180
movl $0x1, -0x218(%rbp)
jmp 0xe38e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x210(%rbp)
movl %eax, -0x214(%rbp)
leaq -0x208(%rbp), %rdi
callq 0x2310
jmp 0xe3a3
movq 0xae1f(%rip), %rdi      # 0x18fd8
leaq 0x1fa8(%rip), %rsi      # 0x10168
callq 0x21f0
movq %rax, -0x250(%rbp)
jmp 0xe1ce
movq -0x250(%rbp), %rdi
movq 0xadec(%rip), %rsi      # 0x18fc8
callq 0x2230
jmp 0xe1e3
leaq 0x1f8d(%rip), %rsi      # 0x10177
leaq -0x208(%rbp), %rdi
callq 0x21f0
movq %rax, -0x258(%rbp)
jmp 0xe1ff
movq -0x258(%rbp), %rdi
leaq 0x1f73(%rip), %rsi      # 0x10180
callq 0x21f0
jmp 0xe214
movl $0x0, -0x21c(%rbp)
cmpl $0x617, -0x21c(%rbp)    # imm = 0x617
jge 0xe345
movl $0xfffffc18, -0x220(%rbp) # imm = 0xFFFFFC18
movl $0x0, -0x224(%rbp)
movl $0x1, -0x228(%rbp)
cmpl $0x1b, -0x228(%rbp)
jge 0xe2c8
movq -0x230(%rbp), %rax
addq $0x30, %rax
movslq -0x21c(%rbp), %rcx
imulq $0x6c, %rcx, %rcx
addq %rcx, %rax
movslq -0x228(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x220(%rbp), %eax
jle 0xe2b5
movq -0x230(%rbp), %rax
addq $0x30, %rax
movslq -0x21c(%rbp), %rcx
imulq $0x6c, %rcx, %rcx
addq %rcx, %rax
movslq -0x228(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x220(%rbp)
movl -0x228(%rbp), %eax
movl %eax, -0x224(%rbp)
jmp 0xe2b7
movl -0x228(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x228(%rbp)
jmp 0xe24c
movl -0x21c(%rbp), %esi
leaq -0x208(%rbp), %rdi
callq 0x2360
movq %rax, -0x260(%rbp)
jmp 0xe2e3
movq -0x260(%rbp), %rdi
leaq 0x1e91(%rip), %rsi      # 0x10182
callq 0x21f0
movq %rax, -0x268(%rbp)
jmp 0xe2ff
movq -0x268(%rbp), %rdi
movl -0x224(%rbp), %esi
callq 0x2360
movq %rax, -0x270(%rbp)
jmp 0xe31a
movq -0x270(%rbp), %rdi
leaq 0x1e58(%rip), %rsi      # 0x10180
callq 0x21f0
jmp 0xe32f
jmp 0xe331
movl -0x21c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x21c(%rbp)
jmp 0xe21e
leaq -0x208(%rbp), %rdi
callq 0x22f0
jmp 0xe353
movq 0xac7e(%rip), %rdi      # 0x18fd8
leaq 0x1e23(%rip), %rsi      # 0x10184
callq 0x21f0
movq %rax, -0x278(%rbp)
jmp 0xe36f
movq -0x278(%rbp), %rdi
movq 0xac4b(%rip), %rsi      # 0x18fc8
callq 0x2230
jmp 0xe384
movl $0x0, -0x218(%rbp)
leaq -0x208(%rbp), %rdi
callq 0x2310
addq $0x280, %rsp            # imm = 0x280
popq %rbp
retq
movq -0x210(%rbp), %rdi
callq 0x2370
nop