// File: WinChua[P]MLDemo/DecisionTree.cpp
// Function: TreeNode::show_tree()
void TreeNode::show_tree()
{
    std::vector<TreeNode *> current_level = {this};
    while(!current_level.empty())
    {
        std::cout << std::endl;
        std::vector<TreeNode *> next_level;
        for(auto it : current_level)
        {
            std::cout << it->attr << ":" << it->gain <<":" << it->label << " ";
//            if(it->lchild == nullptr && it->rchild == nullptr) {
//                std::cout << "the size of the leaf is " << it->record_index.size() << std::endl;
//            }
            if(it->lchild != nullptr)
            {
                next_level.push_back(it->lchild);
            }
            if(it->rchild != nullptr)
            {
                next_level.push_back(it->rchild);
            }
        }
        swap(current_level, next_level);
        next_level.clear();
    }
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
movq $0x1, -0x28(%rbp)
leaq -0x39(%rbp), %rdi
movq %rdi, -0x90(%rbp)
callq 0x4050
movq -0x90(%rbp), %rcx
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq -0x20(%rbp), %rdi
callq 0x4070
jmp 0x3381
leaq -0x39(%rbp), %rdi
callq 0x40f0
leaq -0x20(%rbp), %rdi
callq 0x4110
xorb $-0x1, %al
testb $0x1, %al
jne 0x339e
jmp 0x357f
movq 0xfc33(%rip), %rdi      # 0x12fd8
movq 0xfc1c(%rip), %rsi      # 0x12fc8
callq 0x2240
jmp 0x33b3
leaq -0x68(%rbp), %rdi
callq 0x4150
leaq -0x20(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
callq 0x4170
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rdi
callq 0x41a0
movq %rax, -0x80(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x41d0
testb $0x1, %al
jne 0x33f4
jmp 0x355b
leaq -0x78(%rbp), %rdi
callq 0x4210
movq (%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rsi
addq $0x20, %rsi
movq 0xfbbf(%rip), %rdi      # 0x12fd8
callq 0x21e0
movq %rax, -0x98(%rbp)
jmp 0x3427
movq -0x98(%rbp), %rdi
leaq 0x8d3f(%rip), %rsi      # 0xc174
callq 0x21f0
movq %rax, -0xa0(%rbp)
jmp 0x3443
movq -0xa0(%rbp), %rdi
movq -0x88(%rbp), %rax
movsd 0x40(%rax), %xmm0
callq 0x23a0
movq %rax, -0xa8(%rbp)
jmp 0x3464
movq -0xa8(%rbp), %rdi
leaq 0x8d02(%rip), %rsi      # 0xc174
callq 0x21f0
movq %rax, -0xb0(%rbp)
jmp 0x3480
movq -0xb0(%rbp), %rdi
movq -0x88(%rbp), %rax
movl 0x78(%rax), %esi
callq 0x2340
movq %rax, -0xb8(%rbp)
jmp 0x349f
movq -0xb8(%rbp), %rdi
leaq 0x8c56(%rip), %rsi      # 0xc103
callq 0x21f0
jmp 0x34b4
movq -0x88(%rbp), %rax
cmpq $0x0, 0x80(%rax)
je 0x351f
movq -0x88(%rbp), %rsi
subq $-0x80, %rsi
leaq -0x68(%rbp), %rdi
callq 0x4230
jmp 0x34db
jmp 0x351f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x39(%rbp), %rdi
callq 0x40f0
jmp 0x359a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x3591
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x4310
jmp 0x3591
movq -0x88(%rbp), %rax
cmpq $0x0, 0x88(%rax)
je 0x354b
movq -0x88(%rbp), %rsi
addq $0x88, %rsi
leaq -0x68(%rbp), %rdi
callq 0x4230
jmp 0x3549
jmp 0x354b
jmp 0x354d
leaq -0x78(%rbp), %rdi
callq 0x42a0
jmp 0x33de
leaq -0x20(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x42c0
leaq -0x68(%rbp), %rdi
callq 0x42f0
leaq -0x68(%rbp), %rdi
callq 0x4310
jmp 0x338a
leaq -0x20(%rbp), %rdi
callq 0x4310
addq $0xc0, %rsp
popq %rbp
retq
leaq -0x20(%rbp), %rdi
callq 0x4310
movq -0x48(%rbp), %rdi
callq 0x2350
nopw %cs:(%rax,%rax)