// File: zhjw1998[P]Merkle-Tree/src/main.cpp
// Function: BasicTest()
void BasicTest(){
    // 构造
    std::vector<std::string> leaves;
    InitLeaves(leaves);
    std::cout << "-------Create tree-------" << std::endl;
    MerkleTree* hashTree = new MerkleTree(leaves);

    // 打印树
    // std::cout << "-------Print tree-------" << std::endl;
    // hashTree->printMerkleTree();

    // 查找节点
    std::cout << "-------Search node-------" << std::endl;
    std::vector<std::string> vs = {hash_sha256("op_) 4654asd21"), \
        hash_sha256("12893 d970123+_qweawdf"), hash_sha256("12893")};
    for(auto s : vs){
        std::cout<< s << ": ";
        if(hashTree->containsNode(s)) std::cout<< "true" << std::endl;
        else std::cout << "false" << std::endl;
    }

    hashTree->printMerkleTree();
    // 插入
    std::cout << "-------Insert node-------" << std::endl;
    std::string ins = hash_sha256("dkkdk384654asd21");
    std::cout << "insert hash: " << ins << std::endl;
    hashTree->insertNode(ins);
    hashTree->printMerkleTree();

    // 删除
    std::cout << "-------Delete node-------" << std::endl;
    std::string del = hash_sha256("!@(@#)E&");
    std::cout << "delete hash: " << del << std::endl;
    hashTree->deleteNode(del);
    hashTree->printMerkleTree();

    //析构整个树
    std::cout << "-------Delete tree-------" << std::endl;
    delete hashTree;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x300, %rsp            # imm = 0x300
leaq -0x18(%rbp), %rdi
movq %rdi, -0x208(%rbp)
callq 0x3cc0
movq -0x208(%rbp), %rdi
callq 0x2c00
jmp 0x33b9
movq 0x14c18(%rip), %rdi     # 0x17fd8
leaq 0xcd59(%rip), %rsi      # 0x10120
callq 0x21b0
movq %rax, -0x210(%rbp)
jmp 0x33d5
movq -0x210(%rbp), %rdi
movq 0x14be5(%rip), %rsi     # 0x17fc8
callq 0x2200
jmp 0x33ea
movl $0x10, %edi
callq 0x21c0
movq %rax, -0x218(%rbp)
jmp 0x33fd
movq -0x218(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x87a0
jmp 0x340f
movq -0x218(%rbp), %rax
movq %rax, -0x30(%rbp)
movq 0x14bb7(%rip), %rdi     # 0x17fd8
leaq 0xcd12(%rip), %rsi      # 0x1013a
callq 0x21b0
movq %rax, -0x220(%rbp)
jmp 0x3436
movq -0x220(%rbp), %rdi
movq 0x14b84(%rip), %rsi     # 0x17fc8
callq 0x2200
jmp 0x344b
movb $0x1, -0x132(%rbp)
leaq -0xb8(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq -0xe1(%rbp), %rdi
movq %rdi, -0x228(%rbp)
callq 0x2350
movq -0x228(%rbp), %rdx
leaq 0xcc79(%rip), %rsi      # 0x100fa
leaq -0xe0(%rbp), %rdi
callq 0x3ee0
jmp 0x348f
leaq -0xb8(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x3d10
jmp 0x34a4
leaq -0x98(%rbp), %rax
movq %rax, -0x238(%rbp)
movq %rax, -0xc0(%rbp)
leaq -0x109(%rbp), %rdi
movq %rdi, -0x230(%rbp)
callq 0x2350
movq -0x230(%rbp), %rdx
leaq 0xcc2f(%rip), %rsi      # 0x10109
leaq -0x108(%rbp), %rdi
callq 0x3ee0
jmp 0x34e8
movq -0x238(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x3d10
jmp 0x34fd
leaq -0x78(%rbp), %rax
movq %rax, -0x248(%rbp)
movq %rax, -0xc0(%rbp)
leaq -0x131(%rbp), %rdi
movq %rdi, -0x240(%rbp)
callq 0x2350
movq -0x240(%rbp), %rdx
leaq 0xcc24(%rip), %rsi      # 0x10154
leaq -0x130(%rbp), %rdi
callq 0x3ee0
jmp 0x353e
movq -0x248(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x3d10
jmp 0x3553
movb $0x0, -0x132(%rbp)
leaq -0xb8(%rbp), %rax
movq %rax, -0x58(%rbp)
movq $0x3, -0x50(%rbp)
leaq -0x133(%rbp), %rdi
movq %rdi, -0x250(%rbp)
callq 0x3f90
movq -0x250(%rbp), %rcx
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
leaq -0x48(%rbp), %rdi
callq 0x3fb0
jmp 0x359a
leaq -0x133(%rbp), %rdi
callq 0x4030
leaq -0xb8(%rbp), %rax
movq %rax, -0x260(%rbp)
addq $0x60, %rax
movq %rax, -0x258(%rbp)
movq -0x258(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x268(%rbp)
callq 0x20f0
movq -0x260(%rbp), %rcx
movq -0x268(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x258(%rbp)
jne 0x35bf
leaq -0x130(%rbp), %rdi
callq 0x20f0
leaq -0x131(%rbp), %rdi
callq 0x2220
leaq -0x108(%rbp), %rdi
callq 0x20f0
leaq -0x109(%rbp), %rdi
callq 0x2220
leaq -0xe0(%rbp), %rdi
callq 0x20f0
leaq -0xe1(%rbp), %rdi
callq 0x2220
leaq -0x48(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x140(%rbp), %rdi
callq 0x4050
movq %rax, -0x148(%rbp)
movq -0x140(%rbp), %rdi
callq 0x4080
movq %rax, -0x150(%rbp)
leaq -0x148(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x40b0
testb $0x1, %al
jne 0x3685
jmp 0x394a
leaq -0x148(%rbp), %rdi
callq 0x40f0
movq %rax, %rsi
leaq -0x170(%rbp), %rdi
callq 0x2090
jmp 0x36a2
movq 0x1492f(%rip), %rdi     # 0x17fd8
leaq -0x170(%rbp), %rsi
callq 0x2190
movq %rax, -0x270(%rbp)
jmp 0x36be
movq -0x270(%rbp), %rdi
leaq 0xcaf7(%rip), %rsi      # 0x101c3
callq 0x21b0
jmp 0x36d3
movq -0x30(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x9250
movb %al, -0x271(%rbp)
jmp 0x36eb
movb -0x271(%rbp), %al
testb $0x1, %al
jne 0x36fa
jmp 0x38fa
movq 0x148d7(%rip), %rdi     # 0x17fd8
leaq 0xca52(%rip), %rsi      # 0x1015a
callq 0x21b0
movq %rax, -0x280(%rbp)
jmp 0x3716
movq -0x280(%rbp), %rdi
movq 0x148a4(%rip), %rsi     # 0x17fc8
callq 0x2200
jmp 0x372b
jmp 0x392d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3c78
movq -0x218(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x10, %esi
callq 0x21e0
jmp 0x3c78
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3863
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3857
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x384b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x383f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3833
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3827
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x133(%rbp), %rdi
callq 0x4030
leaq -0xb8(%rbp), %rax
movq %rax, -0x290(%rbp)
addq $0x60, %rax
movq %rax, -0x288(%rbp)
movq -0x288(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x298(%rbp)
callq 0x20f0
movq -0x290(%rbp), %rcx
movq -0x298(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x288(%rbp)
jne 0x37f4
jmp 0x3827
leaq -0x130(%rbp), %rdi
callq 0x20f0
leaq -0x131(%rbp), %rdi
callq 0x2220
leaq -0x108(%rbp), %rdi
callq 0x20f0
leaq -0x109(%rbp), %rdi
callq 0x2220
leaq -0xe0(%rbp), %rdi
callq 0x20f0
leaq -0xe1(%rbp), %rdi
callq 0x2220
testb $0x1, -0x132(%rbp)
jne 0x387a
jmp 0x38c7
movq -0xc0(%rbp), %rax
leaq -0xb8(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0x2a0(%rbp)
je 0x38c5
movq -0x2a0(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x2a8(%rbp)
callq 0x20f0
movq -0x2a8(%rbp), %rax
leaq -0xb8(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0x2a0(%rbp)
jne 0x3894
jmp 0x38c7
jmp 0x3c78
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3c6f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x20f0
jmp 0x3c6f
movq 0x146d7(%rip), %rdi     # 0x17fd8
leaq 0xc857(%rip), %rsi      # 0x1015f
callq 0x21b0
movq %rax, -0x2b0(%rbp)
jmp 0x3916
movq -0x2b0(%rbp), %rdi
movq 0x146a4(%rip), %rsi     # 0x17fc8
callq 0x2200
jmp 0x392b
jmp 0x392d
leaq -0x170(%rbp), %rdi
callq 0x20f0
leaq -0x148(%rbp), %rdi
callq 0x4110
jmp 0x3669
movq -0x30(%rbp), %rdi
callq 0x9170
jmp 0x3955
movq 0x1467c(%rip), %rdi     # 0x17fd8
leaq 0xc802(%rip), %rsi      # 0x10165
callq 0x21b0
movq %rax, -0x2b8(%rbp)
jmp 0x3971
movq -0x2b8(%rbp), %rdi
movq 0x14649(%rip), %rsi     # 0x17fc8
callq 0x2200
jmp 0x3986
leaq -0x1b1(%rbp), %rdi
movq %rdi, -0x2c0(%rbp)
callq 0x2350
movq -0x2c0(%rbp), %rdx
leaq 0xc7d8(%rip), %rsi      # 0x1017f
leaq -0x1b0(%rbp), %rdi
callq 0x3ee0
jmp 0x39b5
leaq -0x190(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x3d10
jmp 0x39ca
leaq -0x1b0(%rbp), %rdi
callq 0x20f0
leaq -0x1b1(%rbp), %rdi
callq 0x2220
movq 0x145ef(%rip), %rdi     # 0x17fd8
leaq 0xc7a0(%rip), %rsi      # 0x10190
callq 0x21b0
movq %rax, -0x2c8(%rbp)
jmp 0x39fe
movq -0x2c8(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x2190
movq %rax, -0x2d0(%rbp)
jmp 0x3a1a
movq -0x2d0(%rbp), %rdi
movq 0x145a0(%rip), %rsi     # 0x17fc8
callq 0x2200
jmp 0x3a2f
movq -0x30(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x95a0
jmp 0x3a41
movq -0x30(%rbp), %rdi
callq 0x9170
jmp 0x3a4c
movq 0x14585(%rip), %rdi     # 0x17fd8
leaq 0xc744(%rip), %rsi      # 0x1019e
callq 0x21b0
movq %rax, -0x2d8(%rbp)
jmp 0x3a68
movq -0x2d8(%rbp), %rdi
movq 0x14552(%rip), %rsi     # 0x17fc8
callq 0x2200
jmp 0x3a7d
leaq -0x1f9(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0x2350
movq -0x2e0(%rbp), %rdx
leaq 0xc606(%rip), %rsi      # 0x100a4
leaq -0x1f8(%rbp), %rdi
callq 0x3ee0
jmp 0x3aac
leaq -0x1d8(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x3d10
jmp 0x3ac1
leaq -0x1f8(%rbp), %rdi
callq 0x20f0
leaq -0x1f9(%rbp), %rdi
callq 0x2220
movq 0x144f8(%rip), %rdi     # 0x17fd8
leaq 0xc6d1(%rip), %rsi      # 0x101b8
callq 0x21b0
movq %rax, -0x2e8(%rbp)
jmp 0x3af5
movq -0x2e8(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x2190
movq %rax, -0x2f0(%rbp)
jmp 0x3b11
movq -0x2f0(%rbp), %rdi
movq 0x144a9(%rip), %rsi     # 0x17fc8
callq 0x2200
jmp 0x3b26
movq -0x30(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x99e0
jmp 0x3b38
movq -0x30(%rbp), %rdi
callq 0x9170
jmp 0x3b43
movq 0x1448e(%rip), %rdi     # 0x17fd8
leaq 0xc675(%rip), %rsi      # 0x101c6
callq 0x21b0
movq %rax, -0x2f8(%rbp)
jmp 0x3b5f
movq -0x2f8(%rbp), %rdi
movq 0x1445b(%rip), %rsi     # 0x17fc8
callq 0x2200
jmp 0x3b74
movq -0x30(%rbp), %rax
movq %rax, -0x300(%rbp)
cmpq $0x0, %rax
je 0x3ba2
movq -0x300(%rbp), %rdi
callq 0x8fe0
movq -0x300(%rbp), %rdi
movl $0x10, %esi
callq 0x21e0
leaq -0x1d8(%rbp), %rdi
callq 0x20f0
leaq -0x190(%rbp), %rdi
callq 0x20f0
leaq -0x48(%rbp), %rdi
callq 0x3e80
leaq -0x18(%rbp), %rdi
callq 0x3e80
addq $0x300, %rsp            # imm = 0x300
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3bfb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x20f0
leaq -0x1b1(%rbp), %rdi
callq 0x2220
jmp 0x3c6f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3c63
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3c3d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0x20f0
leaq -0x1f9(%rbp), %rdi
callq 0x2220
jmp 0x3c63
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x20f0
leaq -0x190(%rbp), %rdi
callq 0x20f0
leaq -0x48(%rbp), %rdi
callq 0x3e80
leaq -0x18(%rbp), %rdi
callq 0x3e80
movq -0x20(%rbp), %rdi
callq 0x2340
nopw (%rax,%rax)