// File: /workspace/github_cpp_makefile_star2_O1/zhjw1998[P]Merkle-Tree/src/merkle_tree.cpp
// Function: MerkleTree::MerkleTree(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&)
MerkleTree::MerkleTree(const std::vector<std::string>& leaves) {
    std::vector<Node*> blocks;
    for(auto leaf : leaves){
        blocks.push_back(new Node(leaf));
        blocks.back()->left = nullptr;
        blocks.back()->right = nullptr;
    }
    clock_t start, finish;
    double duration1, duration2;
    start = clock();
    
    createMerkleTree(blocks); // this->root
    finish = clock();
    duration1 = (double)(finish - start) / CLOCKS_PER_SEC;
    std::cout << std::setw(24) << duration1;
    // printMerkleTree();
    // std::cout << "tree created" << std::endl;

    start = clock();
    BuildTrieTree(leaves); // this->trieroot
    finish = clock();
    duration2 = (double)(finish - start) / CLOCKS_PER_SEC;
    std::cout << std::setw(24) << duration2;
    std::cout << std::setw(24) << duration2 / duration1;
    // LevelOrderTraverse();
    // std::cout << "trie tree created" << std::endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, (%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq (%rsi), %r15
movq %rsi, 0x50(%rsp)
movq 0x8(%rsi), %rax
movq %rax, 0x8(%rsp)
cmpq %rax, %r15
je 0x4bb2
leaq 0x88(%rsp), %r13
leaq 0x78(%rsp), %rbx
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0x30(%rsp), %rdi
callq 0x45d2
movl $0x30, %edi
callq 0x2160
movq %rax, %r14
movq %r13, %r12
movq %r13, 0x78(%rsp)
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
addq %rsi, %rdx
movq %rbx, %rbp
movq %rbx, %rdi
callq 0x45d2
movb $0x1, %r13b
movq %r14, %rdi
movq %rbp, %rsi
callq 0x6bb4
movq %r14, 0x70(%rsp)
xorl %r13d, %r13d
leaq 0x10(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x6314
movq 0x78(%rsp), %rdi
movq %r12, %r13
cmpq %r12, %rdi
je 0x4b70
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0x18(%rsp), %rax
movq -0x8(%rax), %rcx
xorl %edx, %edx
movq %rdx, 0x20(%rcx)
movq -0x8(%rax), %rax
movq %rdx, 0x28(%rax)
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x4ba3
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2170
addq $0x20, %r15
cmpq 0x8(%rsp), %r15
jne 0x4ae3
callq 0x20e0
movq %rax, %r14
leaq 0x58(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x5ef2
movq (%rsp), %rbx
leaq 0x58(%rsp), %rsi
movq %rbx, %rdi
callq 0x4d5a
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x4bf1
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
callq 0x20e0
subq %r14, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x23ff(%rip), %xmm0     # 0x7008
movq 0x63c8(%rip), %r14      # 0xafd8
movq (%r14), %rax
movq -0x18(%rax), %rax
movq $0x18, 0x10(%r14,%rax)
movq %r14, %rdi
movsd %xmm0, 0x8(%rsp)
callq 0x2200
callq 0x20e0
movq %rax, %r15
movq %rbx, %rdi
movq 0x50(%rsp), %rsi
callq 0x5076
callq 0x20e0
subq %r15, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x23ad(%rip), %xmm0     # 0x7008
movq (%r14), %rax
movq -0x18(%rax), %rax
movq $0x18, 0x10(%r14,%rax)
movq %r14, %rdi
movsd %xmm0, (%rsp)
callq 0x2200
movq (%r14), %rax
movq -0x18(%rax), %rax
movq $0x18, 0x10(%r14,%rax)
movsd (%rsp), %xmm0
divsd 0x8(%rsp), %xmm0
movq %r14, %rdi
callq 0x2200
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x4cb2
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x4d3a
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
jmp 0x4d35
jmp 0x4cdd
movq %rax, %r15
jmp 0x4d3a
movq %rax, %r15
jmp 0x4d1e
movq %rax, %r15
movb $0x1, %r13b
jmp 0x4d0c
movq %rax, %r15
movq 0x78(%rsp), %rdi
cmpq %r12, %rdi
je 0x4d0c
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x2170
testb %r13b, %r13b
je 0x4d1e
movl $0x30, %esi
movq %r14, %rdi
callq 0x2170
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x4d3a
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x4d51
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq %r15, %rdi
callq 0x2240
nop