// File: /workspace/github_cpp_makefile_star2_O3/liujan[P]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 = 0; j < numOfTypes+1; j++){
            if (result[i][j] > max_value){
                max_value = result[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 0x514b
movq %rdi, %rbx
leaq 0x215d(%rip), %rsi      # 0x7175
leaq -0x228(%rbp), %rdi
movl $0x10, %edx
callq 0x21d0
leaq -0x1b8(%rbp), %rdi
callq 0x2060
testb %al, %al
je 0x519e
movq 0x4f94(%rip), %r14      # 0x9fd8
leaq 0x2135(%rip), %rsi      # 0x7180
movl $0xe, %edx
movq %r14, %rdi
callq 0x21e0
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq 0x4f62(%rip), %rdi      # 0x9fd8
callq 0x2030
movq %rax, %rdi
callq 0x2120
leaq 0x2105(%rip), %rsi      # 0x718f
leaq -0x228(%rbp), %rdi
movl $0x8, %edx
callq 0x21e0
leaq 0x21c6(%rip), %rsi      # 0x7268
leaq -0x228(%rbp), %rdi
movl $0x1, %edx
callq 0x21e0
addq $0x48, %rbx
xorl %r14d, %r14d
leaq 0x21a7(%rip), %r13      # 0x7268
movl $0xfffffc18, %eax       # imm = 0xFFFFFC18
xorl %ecx, %ecx
xorl %r15d, %r15d
movl (%rbx,%rcx,4), %edx
cmpl %eax, %edx
cmovgl %edx, %eax
cmovgl %ecx, %r15d
incq %rcx
cmpq $0x1b, %rcx
jne 0x50cb
leaq -0x228(%rbp), %rdi
movl %r14d, %esi
callq 0x2280
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2097(%rip), %rsi      # 0x7198
callq 0x21e0
movq %r12, %rdi
movl %r15d, %esi
callq 0x2280
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x21e0
incq %r14
addq $0x6c, %rbx
cmpq $0x617, %r14            # imm = 0x617
jne 0x50c1
leaq -0x228(%rbp), %rdi
callq 0x2220
movl $0x14, %edx
leaq 0x2051(%rip), %rsi      # 0x719a
jmp 0x51aa
movq 0x4e86(%rip), %rbx      # 0x9fd8
leaq 0x1fc7(%rip), %rsi      # 0x7120
movl $0x1c, %edx
movq %rbx, %rdi
callq 0x21e0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2120
movl $0x26, %edx
leaq 0x1faf(%rip), %rsi      # 0x7159
movq 0x4e27(%rip), %rbx      # 0x9fd8
movq %rbx, %rdi
callq 0x21e0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq 0x4e01(%rip), %rdi      # 0x9fd8
callq 0x2030
movq %rax, %rdi
callq 0x2120
movq 0x4de5(%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 0x2170
leaq -0x130(%rbp), %rdi
callq 0x20a0
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x522e
movq %rax, %rbx
leaq -0x228(%rbp), %rdi
callq 0x2240
movq %rbx, %rdi
callq 0x2290
nop