// File: 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
subq $0x280, %rsp            # imm = 0x280
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x230(%rbp)
addq $0x18, %rdi
callq 0x6030
testb $0x1, %al
jne 0xdea9
jmp 0xded0
movq 0xb128(%rip), %rdi      # 0x18fd8
leaq 0x224e(%rip), %rsi      # 0x10105
callq 0x21c0
movq %rax, %rdi
movq 0xb102(%rip), %rsi      # 0x18fc8
callq 0x2200
jmp 0xe15a
leaq 0x2283(%rip), %rsi      # 0x1015a
leaq -0x208(%rbp), %rdi
movq %rdi, -0x240(%rbp)
movl $0x10, %edx
callq 0x2230
movq -0x240(%rbp), %rdi
callq 0x2150
movb %al, -0x231(%rbp)
jmp 0xdf03
movb -0x231(%rbp), %al
testb $0x1, %al
jne 0xdf72
jmp 0xdf0f
movq 0xb0c2(%rip), %rdi      # 0x18fd8
leaq 0x2221(%rip), %rsi      # 0x1013e
callq 0x21c0
movq %rax, -0x248(%rbp)
jmp 0xdf2b
movq -0x248(%rbp), %rdi
movq 0xb08f(%rip), %rsi      # 0x18fc8
callq 0x2200
jmp 0xdf40
movl $0x1, -0x218(%rbp)
jmp 0xe14e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x210(%rbp)
movl %eax, -0x214(%rbp)
leaq -0x208(%rbp), %rdi
callq 0x22d0
jmp 0xe163
movq 0xb05f(%rip), %rdi      # 0x18fd8
leaq 0x21e5(%rip), %rsi      # 0x10165
callq 0x21c0
movq %rax, -0x250(%rbp)
jmp 0xdf8e
movq -0x250(%rbp), %rdi
movq 0xb02c(%rip), %rsi      # 0x18fc8
callq 0x2200
jmp 0xdfa3
leaq 0x21ca(%rip), %rsi      # 0x10174
leaq -0x208(%rbp), %rdi
callq 0x21c0
movq %rax, -0x258(%rbp)
jmp 0xdfbf
movq -0x258(%rbp), %rdi
leaq 0x2283(%rip), %rsi      # 0x10250
callq 0x21c0
jmp 0xdfd4
movl $0x0, -0x21c(%rbp)
cmpl $0x617, -0x21c(%rbp)    # imm = 0x617
jge 0xe105
movl $0xfffffc18, -0x220(%rbp) # imm = 0xFFFFFC18
movl $0x0, -0x224(%rbp)
movl $0x0, -0x228(%rbp)
cmpl $0x1b, -0x228(%rbp)
jge 0xe088
movq -0x230(%rbp), %rax
addq $0x48, %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 0xe075
movq -0x230(%rbp), %rax
addq $0x48, %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 0xe077
movl -0x228(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x228(%rbp)
jmp 0xe00c
movl -0x21c(%rbp), %esi
leaq -0x208(%rbp), %rdi
callq 0x2320
movq %rax, -0x260(%rbp)
jmp 0xe0a3
movq -0x260(%rbp), %rdi
leaq 0x20cc(%rip), %rsi      # 0x1017d
callq 0x21c0
movq %rax, -0x268(%rbp)
jmp 0xe0bf
movq -0x268(%rbp), %rdi
movl -0x224(%rbp), %esi
callq 0x2320
movq %rax, -0x270(%rbp)
jmp 0xe0da
movq -0x270(%rbp), %rdi
leaq 0x2168(%rip), %rsi      # 0x10250
callq 0x21c0
jmp 0xe0ef
jmp 0xe0f1
movl -0x21c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x21c(%rbp)
jmp 0xdfde
leaq -0x208(%rbp), %rdi
callq 0x22b0
jmp 0xe113
movq 0xaebe(%rip), %rdi      # 0x18fd8
leaq 0x205e(%rip), %rsi      # 0x1017f
callq 0x21c0
movq %rax, -0x278(%rbp)
jmp 0xe12f
movq -0x278(%rbp), %rdi
movq 0xae8b(%rip), %rsi      # 0x18fc8
callq 0x2200
jmp 0xe144
movl $0x0, -0x218(%rbp)
leaq -0x208(%rbp), %rdi
callq 0x22d0
addq $0x280, %rsp            # imm = 0x280
popq %rbp
retq
movq -0x210(%rbp), %rdi
callq 0x2330
nop