// File: WinChua[P]MLDemo/DecisionTree.cpp
// Function: TreeNode::test(File&)
double TreeNode::test(File &test_file)
{
    std::cout << "the size of test set is " << test_file.records.size() << std::endl;
    float tp=0, tn=0, fp=0, fn=0;
    for(auto record : test_file.records) {
        if(record.label == test(record))
            if(record.label == 1)
                tp += 1;
            else
                tn += 1;
        else
            if(record.label == 1)
                fp += 1;
            else
                fn += 1;
    }
    std::cout << "the true_positive is " << tp / (tp+fp) << std::endl;
    std::cout << "the false_positive is " << tn / (tn + fn) << std::endl;
    std::cout << "the recall is " << tp / (tp + fn) << std::endl;
    return tp / (tp+tn);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x90(%rbp)
movq 0xff03(%rip), %rdi      # 0x12fd8
leaq 0x8f4b(%rip), %rsi      # 0xc027
callq 0x21f0
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
callq 0x3ad0
movq -0x88(%rbp), %rdi
movq %rax, %rsi
callq 0x2080
movq %rax, %rdi
movq 0xfeba(%rip), %rsi      # 0x12fc8
callq 0x2240
xorps %xmm0, %xmm0
movss %xmm0, -0x14(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x18(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x1c(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x20(%rbp)
movq -0x10(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x3f10
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
callq 0x3f40
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x3f70
testb $0x1, %al
jne 0x316f
jmp 0x324c
leaq -0x30(%rbp), %rdi
callq 0x3fb0
movq %rax, %rsi
leaq -0x70(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
callq 0x3fd0
movq -0x90(%rbp), %rdi
movq -0xa0(%rbp), %rsi
movl -0x70(%rbp), %eax
movl %eax, -0x98(%rbp)
callq 0x2fa0
movl %eax, -0x94(%rbp)
jmp 0x31af
movl -0x98(%rbp), %eax
movl -0x94(%rbp), %ecx
cmpl %ecx, %eax
jne 0x3207
cmpl $0x1, -0x70(%rbp)
jne 0x31f3
movss 0x8e4b(%rip), %xmm0     # 0xc018
addss -0x14(%rbp), %xmm0
movss %xmm0, -0x14(%rbp)
jmp 0x3205
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x4010
jmp 0x3323
movss 0x8e1d(%rip), %xmm0     # 0xc018
addss -0x18(%rbp), %xmm0
movss %xmm0, -0x18(%rbp)
jmp 0x3235
cmpl $0x1, -0x70(%rbp)
jne 0x3221
movss 0x8e03(%rip), %xmm0     # 0xc018
addss -0x1c(%rbp), %xmm0
movss %xmm0, -0x1c(%rbp)
jmp 0x3233
movss 0x8def(%rip), %xmm0     # 0xc018
addss -0x20(%rbp), %xmm0
movss %xmm0, -0x20(%rbp)
jmp 0x3235
leaq -0x70(%rbp), %rdi
callq 0x4010
leaq -0x30(%rbp), %rdi
callq 0x4030
jmp 0x3159
movq 0xfd85(%rip), %rdi      # 0x12fd8
leaq 0x8de6(%rip), %rsi      # 0xc040
callq 0x21f0
movq %rax, %rdi
movss -0x14(%rbp), %xmm0
movss -0x14(%rbp), %xmm1
addss -0x1c(%rbp), %xmm1
divss %xmm1, %xmm0
callq 0x2180
movq %rax, %rdi
movq 0xfd44(%rip), %rsi      # 0x12fc8
callq 0x2240
movq 0xfd48(%rip), %rdi      # 0x12fd8
leaq 0x8dbf(%rip), %rsi      # 0xc056
callq 0x21f0
movq %rax, %rdi
movss -0x18(%rbp), %xmm0
movss -0x18(%rbp), %xmm1
addss -0x20(%rbp), %xmm1
divss %xmm1, %xmm0
callq 0x2180
movq %rax, %rdi
movq 0xfd07(%rip), %rsi      # 0x12fc8
callq 0x2240
movq 0xfd0b(%rip), %rdi      # 0x12fd8
leaq 0x8d99(%rip), %rsi      # 0xc06d
callq 0x21f0
movq %rax, %rdi
movss -0x14(%rbp), %xmm0
movss -0x14(%rbp), %xmm1
addss -0x20(%rbp), %xmm1
divss %xmm1, %xmm0
callq 0x2180
movq %rax, %rdi
movq 0xfcca(%rip), %rsi      # 0x12fc8
callq 0x2240
movss -0x14(%rbp), %xmm0
movss -0x14(%rbp), %xmm1
addss -0x18(%rbp), %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
addq $0xa0, %rsp
popq %rbp
retq
movq -0x78(%rbp), %rdi
callq 0x2350
nopl (%rax)