// File: ChaohuiYu[P]BPlusTree/BPlusTree.cpp
// Function: BPlusTree<int>::printTree()
void BPT<T>::printTree() {
    int level = 0;
    BPT_NODE* node;
    vector<BPT_NODE*> nodeStack {_root};
    vector<int> levelStack {0};

    while(!nodeStack.empty()) {
        node = nodeStack.back();
        nodeStack.pop_back();
        level = levelStack.back();
        levelStack.pop_back();

        FOR(i, 0, level) {
            cout << "  ";
        }
        node->printNode();

        if (!node->_isLeaf) {
            for (int i = node->_keyCount; i >= 0; i--) {
                if (node->_pointers[i] != NULL) {
                    nodeStack.push_back((BPT_NODE*)node->_pointers[i]);
                    levelStack.push_back(level+1);
                }
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl $0x0, -0xc(%rbp)
movq (%rax), %rax
movq %rax, -0x48(%rbp)
leaq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
movq $0x1, -0x38(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x106a0
movq -0xb0(%rbp), %rcx
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0x30(%rbp), %rdi
callq 0x106c0
jmp 0x1048b
leaq -0x49(%rbp), %rdi
callq 0x10740
movl $0x0, -0x8c(%rbp)
leaq -0x8c(%rbp), %rax
movq %rax, -0x88(%rbp)
movq $0x1, -0x80(%rbp)
leaq -0x8d(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0xca20
movq -0xb8(%rbp), %rcx
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rdx
leaq -0x78(%rbp), %rdi
callq 0x10760
jmp 0x104e4
leaq -0x8d(%rbp), %rdi
callq 0xbb40
leaq -0x30(%rbp), %rdi
callq 0x107e0
xorb $-0x1, %al
testb $0x1, %al
jne 0x10504
jmp 0x1066c
leaq -0x30(%rbp), %rdi
callq 0x10820
movq (%rax), %rax
movq %rax, -0x18(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x10860
leaq -0x78(%rbp), %rdi
callq 0xc8e0
movl (%rax), %eax
movl %eax, -0xc(%rbp)
leaq -0x78(%rbp), %rdi
callq 0xc920
movl $0x0, -0x94(%rbp)
movl -0x94(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x105c2
movq 0xfa78(%rip), %rdi      # 0x1ffc8
leaq 0x5ff5(%rip), %rsi      # 0x1654c
callq 0x3280
jmp 0x1055e
jmp 0x10560
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x1053e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x49(%rbp), %rdi
callq 0x10740
jmp 0x10690
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x8d(%rbp), %rdi
callq 0xbb40
jmp 0x10687
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x78(%rbp), %rdi
callq 0xaa50
jmp 0x10687
movq -0x18(%rbp), %rdi
callq 0x10890
jmp 0x105cd
movq -0x18(%rbp), %rax
testb $0x1, 0x8(%rax)
jne 0x10667
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x98(%rbp)
cmpl $0x0, -0x98(%rbp)
jl 0x10665
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x98(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x10652
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x98(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xa0(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x109e0
jmp 0x10633
movl -0xc(%rbp), %eax
incl %eax
movl %eax, -0xa4(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0xa4(%rbp), %rsi
callq 0x10a10
jmp 0x10650
jmp 0x10652
jmp 0x10654
movl -0x98(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x98(%rbp)
jmp 0x105e8
jmp 0x10667
jmp 0x104f0
leaq -0x78(%rbp), %rdi
callq 0xaa50
leaq -0x30(%rbp), %rdi
callq 0x10a40
addq $0xc0, %rsp
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x10a40
movq -0x58(%rbp), %rdi
callq 0x3410
nopl (%rax)