// File: zhjw1998[P]Merkle-Tree/src/main.cpp
// Function: TimeCal(int)
void TimeCal(int nodenum){
    std::cout << std::setw(24) << nodenum;
    clock_t start, finish;
    double duration1, duration2;
    std::vector<std::string> leaves;
    for(int i = 0; i < nodenum; i++)
        leaves.push_back(hash_sha256(std::to_string(i)));

    MerkleTree* hashTree = new MerkleTree(leaves);

    start = clock();
    for(int i = 0; i < nodenum / 100; i++){
        hashTree->containsNode(hash_sha256(std::to_string(i * 100)));
    }
    finish = clock();
    duration1 = (double)(finish - start) / CLOCKS_PER_SEC;
    std::cout << std::setw(24) << (10000 * duration1) / nodenum;

    start = clock();
    for(int i = 0; i < nodenum / 100; i++){
        hashTree->Find(hash_sha256(std::to_string(i * 100)));
    }
    finish = clock();
    duration2 = (double)(finish - start) / CLOCKS_PER_SEC;
    std::cout << std::setw(24) << (10000 * duration2) / nodenum;

    std::cout << std::setw(24) << duration1 / duration2 << std::endl;
    //析构整个树
    delete hashTree;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movl %edi, -0x4(%rbp)
movl $0x18, %edi
callq 0x3ca0
movl %eax, -0x8(%rbp)
movl -0x8(%rbp), %esi
movq 0x15a73(%rip), %rdi     # 0x17fd8
callq 0x2270
movq %rax, %rdi
movl -0x4(%rbp), %esi
callq 0x2330
leaq -0x40(%rbp), %rdi
callq 0x3cc0
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x263a
movl -0x44(%rbp), %esi
leaq -0x88(%rbp), %rdi
callq 0x3d60
jmp 0x25a2
leaq -0x68(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x3d10
jmp 0x25b4
leaq -0x40(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x3ce0
jmp 0x25c3
leaq -0x68(%rbp), %rdi
callq 0x20f0
leaq -0x88(%rbp), %rdi
callq 0x20f0
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x2585
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x2a4f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x2629
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x20f0
leaq -0x88(%rbp), %rdi
callq 0x20f0
jmp 0x2a4f
movl $0x10, %edi
callq 0x21c0
movq %rax, -0x140(%rbp)
jmp 0x264d
movq -0x140(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x87a0
jmp 0x265f
movq -0x140(%rbp), %rax
movq %rax, -0xa0(%rbp)
callq 0x2110
movq %rax, -0x10(%rbp)
movl $0x0, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
movl %eax, -0x144(%rbp)
movl -0x4(%rbp), %eax
movl $0x64, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x144(%rbp), %eax
cmpl %ecx, %eax
jge 0x278d
movq -0xa0(%rbp), %rax
movq %rax, -0x150(%rbp)
movl -0xa4(%rbp), %eax
imull $0x64, %eax, %esi
leaq -0xe8(%rbp), %rdi
callq 0x3d60
jmp 0x26cc
leaq -0xc8(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x3d10
jmp 0x26e1
movq -0x150(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x9250
jmp 0x26f6
leaq -0xc8(%rbp), %rdi
callq 0x20f0
leaq -0xe8(%rbp), %rdi
callq 0x20f0
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x2680
movq -0x140(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
movl $0x10, %esi
callq 0x21e0
jmp 0x2a4f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x277c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x20f0
leaq -0xe8(%rbp), %rdi
callq 0x20f0
jmp 0x2a4f
callq 0x2110
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
cvtsi2sd %rax, %xmm0
movsd 0xd85a(%rip), %xmm1     # 0x10008
divsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
movl $0x18, %edi
callq 0x3ca0
movl %eax, -0x154(%rbp)
jmp 0x27c9
movl -0x154(%rbp), %eax
movl %eax, -0xec(%rbp)
movl -0xec(%rbp), %esi
movq 0x157f6(%rip), %rdi     # 0x17fd8
callq 0x2270
movq %rax, -0x160(%rbp)
jmp 0x27f0
movq -0x160(%rbp), %rdi
movsd -0x20(%rbp), %xmm0
movsd 0xd80c(%rip), %xmm1     # 0x10010
mulsd %xmm1, %xmm0
cvtsi2sdl -0x4(%rbp), %xmm1
divsd %xmm1, %xmm0
callq 0x2380
jmp 0x2818
callq 0x2110
movq %rax, -0x10(%rbp)
movl $0x0, -0xf0(%rbp)
movl -0xf0(%rbp), %eax
movl %eax, -0x164(%rbp)
movl -0x4(%rbp), %eax
movl $0x64, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x164(%rbp), %eax
cmpl %ecx, %eax
jge 0x2910
movq -0xa0(%rbp), %rax
movq %rax, -0x170(%rbp)
movl -0xf0(%rbp), %eax
imull $0x64, %eax, %esi
leaq -0x130(%rbp), %rdi
callq 0x3d60
jmp 0x2877
leaq -0x110(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x3d10
jmp 0x288c
movq -0x170(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x9e20
jmp 0x28a1
leaq -0x110(%rbp), %rdi
callq 0x20f0
leaq -0x130(%rbp), %rdi
callq 0x20f0
movl -0xf0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf0(%rbp)
jmp 0x282b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x28ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x20f0
leaq -0x130(%rbp), %rdi
callq 0x20f0
jmp 0x2a4f
callq 0x2110
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
cvtsi2sd %rax, %xmm0
movsd 0xd6d7(%rip), %xmm1     # 0x10008
divsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movl $0x18, %edi
callq 0x3ca0
movl %eax, -0x174(%rbp)
jmp 0x294c
movl -0x174(%rbp), %eax
movl %eax, -0x134(%rbp)
movl -0x134(%rbp), %esi
movq 0x15673(%rip), %rdi     # 0x17fd8
callq 0x2270
movq %rax, -0x180(%rbp)
jmp 0x2973
movq -0x180(%rbp), %rdi
movsd -0x28(%rbp), %xmm0
movsd 0xd689(%rip), %xmm1     # 0x10010
mulsd %xmm1, %xmm0
cvtsi2sdl -0x4(%rbp), %xmm1
divsd %xmm1, %xmm0
callq 0x2380
jmp 0x299b
movl $0x18, %edi
callq 0x3ca0
movl %eax, -0x184(%rbp)
jmp 0x29ad
movl -0x184(%rbp), %eax
movl %eax, -0x138(%rbp)
movl -0x138(%rbp), %esi
movq 0x15612(%rip), %rdi     # 0x17fd8
callq 0x2270
movq %rax, -0x190(%rbp)
jmp 0x29d4
movq -0x190(%rbp), %rdi
movsd -0x20(%rbp), %xmm0
movsd -0x28(%rbp), %xmm1
divsd %xmm1, %xmm0
callq 0x2380
movq %rax, -0x198(%rbp)
jmp 0x29f7
movq -0x198(%rbp), %rdi
movq 0x155c3(%rip), %rsi     # 0x17fc8
callq 0x2200
jmp 0x2a0c
movq -0xa0(%rbp), %rax
movq %rax, -0x1a0(%rbp)
cmpq $0x0, %rax
je 0x2a3d
movq -0x1a0(%rbp), %rdi
callq 0x8fe0
movq -0x1a0(%rbp), %rdi
movl $0x10, %esi
callq 0x21e0
leaq -0x40(%rbp), %rdi
callq 0x3e80
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
leaq -0x40(%rbp), %rdi
callq 0x3e80
movq -0x90(%rbp), %rdi
callq 0x2340
nopw %cs:(%rax,%rax)