// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq (%rdi), %r13
movq 0x58(%r13), %rax
movq (%rsi), %rcx
cmpq 0x58(%rcx), %rax
jne 0x3e53
movq %rsi, %rbx
movq %rdi, %r14
addq $0x50, %r13
movq (%r13), %r13
testq %r13, %r13
je 0x3e66
leaq 0x8(%r13), %r15
movq (%rbx), %rdi
addq $0x40, %rdi
movq %r15, %rsi
callq 0x3200
testq %rax, %rax
je 0x3f21
movq (%rbx), %rdi
addq $0x40, %rdi
movq %r15, %rsi
callq 0x32a4
movq %rax, %r15
movq 0x10(%r13), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movq %rax, %r12
movq (%r15), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
cmpq %rax, %r12
jne 0x3f3d
movq 0x10(%r13), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movq %rax, %r12
movq (%r15), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
cmpq %rax, %r12
je 0x3dcb
movq 0x3181(%rip), %rdi      # 0x6fc8
leaq 0x27a(%rip), %rsi       # 0x40c8
jmp 0x3f6f
movq 0x316e(%rip), %rdi      # 0x6fc8
leaq 0x287(%rip), %rsi       # 0x40e8
jmp 0x3f6f
movq (%r14), %r15
addq $0x18, %r15
leaq 0x2dcc(%rip), %r12      # 0x6c40
leaq 0x2ded(%rip), %r13      # 0x6c68
movq (%r15), %r15
testq %r15, %r15
je 0x3f4d
leaq 0x8(%r15), %r14
movq (%rbx), %rdi
addq $0x8, %rdi
movq %r14, %rsi
callq 0x3bd2
testq %rax, %rax
je 0x3f51
movq 0x10(%r15), %rdi
testq %rdi, %rdi
je 0x3ebb
movq %r12, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0x2180
jmp 0x3ebd
xorl %eax, %eax
movq %rax, -0x30(%rbp)
movq (%rbx), %rdi
addq $0x8, %rdi
movq %r14, %rsi
callq 0x3820
movq (%rax), %rdi
testq %rdi, %rdi
je 0x3ee7
movq %r12, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0x2180
jmp 0x3ee9
xorl %eax, %eax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rcx
testq %rcx, %rcx
sete %dl
testq %rax, %rax
setne %al
xorb %dl, %al
je 0x3f61
testq %rcx, %rcx
je 0x3e7b
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x3d9c
testb %al, %al
jne 0x3e7b
jmp 0x3f7c
movsbl (%r15), %esi
movq 0x309c(%rip), %rdi      # 0x6fc8
callq 0x2190
leaq 0x164(%rip), %rsi       # 0x409c
movq %rax, %rdi
jmp 0x3f6f
movq 0x3084(%rip), %rdi      # 0x6fc8
leaq 0x164(%rip), %rsi       # 0x40af
jmp 0x3f6f
movb $0x1, %al
jmp 0x3f7e
movq 0x3070(%rip), %rdi      # 0x6fc8
leaq 0x180(%rip), %rsi       # 0x40df
jmp 0x3f6f
movq 0x3060(%rip), %rdi      # 0x6fc8
leaq 0x188(%rip), %rsi       # 0x40f7
callq 0x2160
movq %rax, %rdi
callq 0x20a0
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq