// File: /workspace/github_cpp_makefile_star2_O1/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 0x3f2a
movq %rsi, %rbx
movq %rdi, %r14
addq $0x50, %r13
movq (%r13), %r13
testq %r13, %r13
je 0x3ffc
leaq 0x8(%r13), %r15
movq (%rbx), %rdi
addq $0x40, %rdi
movq %r15, %rsi
callq 0x33d2
testq %rax, %rax
je 0x3f6e
movq (%rbx), %rdi
addq $0x40, %rdi
movq %r15, %rsi
callq 0x345e
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 0x3f9c
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 0x3e9d
movq 0x40b7(%rip), %r15      # 0x7fd0
leaq 0x11d2(%rip), %rsi      # 0x50f2
movl $0x16, %edx
jmp 0x3faf
movq 0x409f(%rip), %rbx      # 0x7fd0
leaq 0x11da(%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
jmp 0x3fe3
movb (%r15), %al
leaq -0x30(%rbp), %rsi
movb %al, (%rsi)
movq 0x4052(%rip), %rdi      # 0x7fd0
movl $0x1, %edx
callq 0x21c0
movq %rax, %r15
leaq 0x1134(%rip), %rsi      # 0x50c6
movl $0x12, %edx
movq %rax, %rdi
jmp 0x3fb2
movq 0x402d(%rip), %r15      # 0x7fd0
leaq 0x112f(%rip), %rsi      # 0x50d9
movl $0x18, %edx
movq %r15, %rdi
callq 0x21c0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
testq %r13, %r13
je 0x3ffc
xorl %r14d, %r14d
andb $0x1, %r14b
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), %r12
testq %r12, %r12
sete %r14b
je 0x3fe6
movq 0x3fbd(%rip), %r15      # 0x7fd0
leaq 0x8(%r12), %r13
movq (%rbx), %rdi
addq $0x8, %rdi
movq %r13, %rsi
callq 0x3c58
testq %rax, %rax
je 0x404d
movq 0x10(%r12), %rdi
testq %rdi, %rdi
je 0x405e
leaq 0x3c03(%rip), %rsi      # 0x7c40
leaq 0x3c24(%rip), %rdx      # 0x7c68
xorl %ecx, %ecx
callq 0x21b0
jmp 0x4060
movl $0x17, %edx
movq %r15, %rdi
leaq 0x10ad(%rip), %rsi      # 0x5109
jmp 0x40d4
xorl %eax, %eax
movq %rax, -0x30(%rbp)
movq (%rbx), %rdi
addq $0x8, %rdi
movq %r13, %rsi
callq 0x3980
movq (%rax), %rdi
testq %rdi, %rdi
je 0x4092
leaq 0x3bbe(%rip), %rsi      # 0x7c40
leaq 0x3bdf(%rip), %rdx      # 0x7c68
xorl %ecx, %ecx
callq 0x21b0
jmp 0x4094
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 0x40c5
testq %rcx, %rcx
je 0x4128
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x3e6e
xorb $0x1, %al
movzbl %al, %eax
jmp 0x4105
movl $0x14, %edx
movq %r15, %rdi
leaq 0x104d(%rip), %rsi      # 0x5121
callq 0x21c0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
movl $0x1, %eax
cmpl $0x5, %eax
je 0x4112
testl %eax, %eax
jne 0x3fe6
movq (%r12), %r12
testq %r12, %r12
sete %r14b
jne 0x4013
jmp 0x3fe6
movl $0x5, %eax
jmp 0x4105