// File: /workspace/github_cpp_makefile_star2_O3/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 0x3ed9
movq %rsi, %rbx
movq %rdi, %r14
addq $0x50, %r13
movq (%r13), %r13
testq %r13, %r13
je 0x3f30
leaq 0x8(%r13), %r15
movq (%rbx), %rdi
addq $0x40, %rdi
movq %r15, %rsi
callq 0x33b2
testq %rax, %rax
je 0x4003
movq (%rbx), %rdi
addq $0x40, %rdi
movq %r15, %rsi
callq 0x3416
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 0x4034
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 0x3e4f
movq 0x4105(%rip), %rbx      # 0x7fd0
leaq 0x1220(%rip), %rsi      # 0x50f2
movl $0x16, %edx
jmp 0x3eec
movq 0x40f0(%rip), %rbx      # 0x7fd0
leaq 0x122b(%rip), %rsi      # 0x5112
movl $0xe, %edx
movq %rbx, %rdi
callq 0x21c0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rax
movq 0x18(%rax), %r15
movb $0x1, %r14b
testq %r15, %r15
je 0x3f1e
leaq 0x3d22(%rip), %r12      # 0x7c68
leaq 0x8(%r15), %r13
movq (%rbx), %rdi
addq $0x8, %rdi
movq %r13, %rsi
callq 0x3bf2
testq %rax, %rax
je 0x404c
movq 0x10(%r15), %rdi
testq %rdi, %rdi
je 0x3f7e
leaq 0x3cce(%rip), %rsi      # 0x7c40
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x21b0
jmp 0x3f80
xorl %eax, %eax
movq %rax, -0x30(%rbp)
movq (%rbx), %rdi
addq $0x8, %rdi
movq %r13, %rsi
callq 0x394e
movq (%rax), %rdi
testq %rdi, %rdi
je 0x3fe3
leaq 0x3c9e(%rip), %rsi      # 0x7c40
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x21b0
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rcx
testq %rcx, %rcx
sete %dl
testq %rax, %rax
setne %al
xorb %dl, %al
je 0x4064
testq %rcx, %rcx
je 0x3ff2
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x3e20
testb %al, %al
jne 0x3ff2
jmp 0x3f1b
movq $0x0, -0x38(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x4064
movq (%r15), %r15
testq %r15, %r15
jne 0x3f46
jmp 0x3f1e
movb (%r15), %al
leaq -0x30(%rbp), %rsi
movb %al, (%rsi)
movq 0x3fbd(%rip), %rdi      # 0x7fd0
movl $0x1, %edx
callq 0x21c0
movq %rax, %rbx
leaq 0x109f(%rip), %rsi      # 0x50c6
movl $0x12, %edx
movq %rax, %rdi
jmp 0x3eef
movq 0x3f95(%rip), %rbx      # 0x7fd0
leaq 0x1097(%rip), %rsi      # 0x50d9
movl $0x18, %edx
jmp 0x3eec
movq 0x3f7d(%rip), %rbx      # 0x7fd0
leaq 0x10af(%rip), %rsi      # 0x5109
movl $0x17, %edx
jmp 0x3eec
movq 0x3f65(%rip), %rbx      # 0x7fd0
leaq 0x10af(%rip), %rsi      # 0x5121
movl $0x14, %edx
jmp 0x3eec