// File: jaxonwang[P]suffixtree/main.cc
// Function: SuffixTreeBase::_same_tree(InternalNode* const&, InternalNode* const&)
bool static _same_tree(const internal_node_ptr &root1,
                         const internal_node_ptr &root2) {
    if (root1->adj_edges.size() != root2->adj_edges.size()) {
      std::cout << "size different" << std::endl;
      return false;
    }
    for (auto &c : root1->adj_edges) {
      if (root2->adj_edges.count(c.first) == 0) {
        std::cout << c.first << " not in the second" << std::endl;
        return false;
      }
      auto &edge1 = c.second;
      auto &edge2 = root2->adj_edges[c.first];
      if (edge1->start_position() != edge2->start_position()) {
        std::cout << "Different start position" << std::endl;
        return false;
      }
      if (edge1->end_position() != edge2->end_position()) {
        std::cout << "Different end position" << std::endl;
        return false;
      }
    }
    for (auto &c : root1->children) {
      if (root2->children.count(c.first) == 0) {
        std::cout << "children size different" << std::endl;
        return false;
      }
      auto child1 = dynamic_cast<internal_node_ptr>(c.second);
      auto child2 = dynamic_cast<internal_node_ptr>(root2->children[c.first]);
      // if child is leaf then the cooresponding child should be leaf
      if ((!child1 && child2) || (child1 && !child2)) {
        std::cout << "different child type" << std::endl;
        return false;
      }
      if (!child1)
        continue;
      if (!_same_tree(child1, child2))
        return false;
    }
    return true;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
addq $0x40, %rdi
callq 0x98b0
movq %rax, -0x80(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
addq $0x40, %rdi
callq 0x98b0
movq %rax, %rcx
movq -0x80(%rbp), %rax
cmpq %rcx, %rax
je 0x953e
movq 0x7aae(%rip), %rdi      # 0x10fc8
leaq 0xbc7(%rip), %rsi       # 0xa0e8
callq 0x2180
movq %rax, %rdi
movq 0x7a78(%rip), %rsi      # 0x10fa8
callq 0x21a0
movb $0x0, -0x1(%rbp)
jmp 0x9898
movq -0x10(%rbp), %rax
movq (%rax), %rax
addq $0x40, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x98d0
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0x9900
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x9930
testb $0x1, %al
jne 0x957d
jmp 0x96dc
leaq -0x28(%rbp), %rdi
callq 0x9960
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
addq $0x40, %rdi
movq -0x38(%rbp), %rsi
callq 0x5db0
cmpq $0x0, %rax
jne 0x95de
movq -0x38(%rbp), %rax
movq 0x7a19(%rip), %rdi      # 0x10fc8
movsbl (%rax), %esi
callq 0x21e0
movq %rax, %rdi
leaq 0xadb(%rip), %rsi       # 0xa09c
callq 0x2180
movq %rax, %rdi
movq 0x79d8(%rip), %rsi      # 0x10fa8
callq 0x21a0
movb $0x0, -0x1(%rbp)
jmp 0x9898
movq -0x38(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
addq $0x40, %rdi
movq -0x38(%rbp), %rsi
callq 0x5de0
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
callq 0x5a50
movq %rax, %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movq %rax, -0x88(%rbp)
movq -0x48(%rbp), %rdi
callq 0x5a50
movq %rax, %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movq %rax, %rcx
movq -0x88(%rbp), %rax
cmpq %rcx, %rax
je 0x9667
movq 0x7985(%rip), %rdi      # 0x10fc8
leaq 0xa65(%rip), %rsi       # 0xa0af
callq 0x2180
movq %rax, %rdi
movq 0x794f(%rip), %rsi      # 0x10fa8
callq 0x21a0
movb $0x0, -0x1(%rbp)
jmp 0x9898
movq -0x40(%rbp), %rdi
callq 0x5a50
movq %rax, %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movq %rax, -0x90(%rbp)
movq -0x48(%rbp), %rdi
callq 0x5a50
movq %rax, %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movq %rax, %rcx
movq -0x90(%rbp), %rax
cmpq %rcx, %rax
je 0x96cc
movq 0x7920(%rip), %rdi      # 0x10fc8
leaq 0xa19(%rip), %rsi       # 0xa0c8
callq 0x2180
movq %rax, %rdi
movq 0x78ea(%rip), %rsi      # 0x10fa8
callq 0x21a0
movb $0x0, -0x1(%rbp)
jmp 0x9898
jmp 0x96ce
leaq -0x28(%rbp), %rdi
callq 0x9990
jmp 0x9567
movq -0x10(%rbp), %rax
movq (%rax), %rax
addq $0x8, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
callq 0x99c0
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rdi
callq 0x99f0
movq %rax, -0x60(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x9a20
testb $0x1, %al
jne 0x971b
jmp 0x9894
leaq -0x58(%rbp), %rdi
callq 0x9a50
movq %rax, -0x68(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
addq $0x8, %rdi
movq -0x68(%rbp), %rsi
callq 0x8f80
cmpq $0x0, %rax
jne 0x976d
movq 0x787f(%rip), %rdi      # 0x10fc8
leaq 0x98f(%rip), %rsi       # 0xa0df
callq 0x2180
movq %rax, %rdi
movq 0x7849(%rip), %rsi      # 0x10fa8
callq 0x21a0
movb $0x0, -0x1(%rbp)
jmp 0x9898
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x98(%rbp)
cmpq $0x0, %rax
je 0x97a9
movq -0x98(%rbp), %rdi
leaq 0x7448(%rip), %rsi      # 0x10bd8
leaq 0x7469(%rip), %rdx      # 0x10c00
xorl %eax, %eax
movl %eax, %ecx
callq 0x21d0
movq %rax, -0xa0(%rbp)
jmp 0x97b4
xorl %eax, %eax
movq %rax, -0xa0(%rbp)
jmp 0x97b4
movq -0xa0(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
addq $0x8, %rdi
movq -0x68(%rbp), %rsi
callq 0x7300
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
cmpq $0x0, %rax
je 0x980a
movq -0xa8(%rbp), %rdi
leaq 0x73e7(%rip), %rsi      # 0x10bd8
leaq 0x7408(%rip), %rdx      # 0x10c00
xorl %eax, %eax
movl %eax, %ecx
callq 0x21d0
movq %rax, -0xb0(%rbp)
jmp 0x9815
xorl %eax, %eax
movq %rax, -0xb0(%rbp)
jmp 0x9815
movq -0xb0(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x982e
cmpq $0x0, -0x78(%rbp)
jne 0x983c
cmpq $0x0, -0x70(%rbp)
je 0x9864
cmpq $0x0, -0x78(%rbp)
jne 0x9864
movq 0x7785(%rip), %rdi      # 0x10fc8
leaq 0x8ad(%rip), %rsi       # 0xa0f7
callq 0x2180
movq %rax, %rdi
movq 0x774f(%rip), %rsi      # 0x10fa8
callq 0x21a0
movb $0x0, -0x1(%rbp)
jmp 0x9898
cmpq $0x0, -0x70(%rbp)
jne 0x986d
jmp 0x9886
leaq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x94d0
testb $0x1, %al
jne 0x9884
movb $0x0, -0x1(%rbp)
jmp 0x9898
jmp 0x9886
leaq -0x58(%rbp), %rdi
callq 0x9a80
jmp 0x9705
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)