// File: /workspace/github_cpp_makefile_star2_O3/huntzhan[P]SAM-PNG/solution.cc
// Function: CreateDOTSource(std::vector<State*, std::allocator<State*>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void CreateDOTSource(const vector<State *> &nodes, const string &text) {

  // init node id.
  unordered_map<State *, string> node_id;
  for (int i = 0; i < nodes.size(); ++i) {
    node_id[nodes[i]] = "t" + to_string(i);
  }

  // head
  fout << "digraph G {" << endl;
  fout << "  rankdir=LR" << endl;
  fout << "  node[shape=\"box\"]" << endl;

  for (int i = 0; i < nodes.size(); ++i) {
    auto node = nodes[i];

    // transitions.
    vector<pair<char, State *>> ordered_trans(
        node->trans().begin(), node->trans().end()
        );
    sort(ordered_trans.begin(), ordered_trans.end());

    for (auto &tran : ordered_trans) {
      char c = tran.first;
      auto child = tran.second;

      fout << "  " << node_id[node] << " -> " << node_id[child]
           << " [label=\"" << c << "\"]"
           << endl;
    }

    // suffix link.
    if (node->link()) {
      fout << "  " << node_id[node] << " -> " << node_id[node->link()]
           << " [color=\"blue\"]"
           << endl;
    }

    // label.
    fout << "  " << node_id[node]
         << " [label=\"";
    if (i == 0) {
      fout << "empty";
    } else {

      auto longest = text.substr(
          node->first_endpos() - node->maxlen() + 1,
          node->maxlen());
      auto shortest = text.substr(
          node->first_endpos() - node->minlen() + 1,
          node->minlen());

      fout << longest << "\\n" << shortest;
    }
    fout << "\"]"
         << endl;
  }

  // tail
  fout << "}" << endl;
  fout.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rsi, 0xa8(%rsp)
leaq 0xe0(%rsp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
movq 0x8(%rdi), %rax
movq %rdi, 0x8(%rsp)
cmpq (%rdi), %rax
je 0x29bb
leaq 0x58(%rsp), %r15
leaq 0x20(%rsp), %r12
xorl %ebx, %ebx
leaq 0x48(%rsp), %r14
movl $0xd1b71759, %r13d      # imm = 0xD1B71759
movl $0x1, %ebp
cmpq $0xa, %rbx
jb 0x28c9
movl $0x4, %ebp
movl %ebx, %eax
cmpl $0x63, %eax
jbe 0x28c2
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0x28c7
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x28c9
movl %eax, %ecx
imulq %r13, %rcx
shrq $0x2d, %rcx
addl $0x4, %ebp
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0x2894
addl $-0x3, %ebp
jmp 0x28c9
addl $-0x2, %ebp
jmp 0x28c9
decl %ebp
movl %ebp, %esi
movq %r15, 0x48(%rsp)
movq %r14, %rdi
movl $0x2d, %edx
callq 0x2120
movq 0x48(%rsp), %rdi
movl %ebp, %esi
movl %ebx, %edx
callq 0x3a65
movl $0x1, %r8d
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0x2780(%rip), %rcx      # 0x507f
callq 0x2100
movq %r12, 0x10(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2927
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
jmp 0x292f
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq (,%rbx,8), %rsi
movq 0x8(%rsp), %rax
addq (%rax), %rsi
leaq 0xb0(%rsp), %rdi
callq 0x4006
movq %rax, %rdi
leaq 0x10(%rsp), %rsi
callq 0x2130
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x2988
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x20e0
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x299f
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x20e0
incq %rbx
movq 0x8(%rsp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
sarq $0x3, %rax
cmpq %rbx, %rax
ja 0x2882
leaq 0x59a6(%rip), %rbx      # 0x8368
leaq 0x2650(%rip), %rsi      # 0x5019
movl $0xb, %edx
movq %rbx, %rdi
callq 0x2110
movq 0x598b(%rip), %rax      # 0x8368
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x20c0
movsbl %al, %esi
leaq 0x5970(%rip), %rdi      # 0x8368
callq 0x2030
movq %rax, %rdi
callq 0x2090
leaq 0x595c(%rip), %rbx      # 0x8368
leaq 0x2612(%rip), %rsi      # 0x5025
movl $0xc, %edx
movq %rbx, %rdi
callq 0x2110
movq 0x5941(%rip), %rax      # 0x8368
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x20c0
movsbl %al, %esi
leaq 0x5926(%rip), %rdi      # 0x8368
callq 0x2030
movq %rax, %rdi
callq 0x2090
leaq 0x5912(%rip), %rbx      # 0x8368
leaq 0x25d5(%rip), %rsi      # 0x5032
movl $0x13, %edx
movq %rbx, %rdi
callq 0x2110
movq 0x58f7(%rip), %rax      # 0x8368
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x20c0
movsbl %al, %esi
leaq 0x58dc(%rip), %r15      # 0x8368
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2090
movq 0x8(%rsp), %rcx
movq (%rcx), %rax
cmpq %rax, 0x8(%rcx)
je 0x2f51
xorl %r12d, %r12d
leaq 0x48(%rsp), %r14
leaq 0xa0(%rsp), %r13
xorl %ebp, %ebp
movq (%rax,%rbp,8), %rax
movq %rax, (%rsp)
leaq 0x18(%rax), %rsi
movq %r12, 0x10(%rsp)
movq 0x20(%rax), %rcx
movq %rcx, 0x18(%rsp)
movq %r12, 0x20(%rsp)
movq 0x30(%rax), %rcx
movq %rcx, 0x28(%rsp)
movups 0x38(%rax), %xmm0
leaq 0x30(%rsp), %rax
movups %xmm0, (%rax)
movq %r12, 0x40(%rsp)
leaq 0x10(%rsp), %rdi
movq %rdi, 0x48(%rsp)
movq %r14, %rdx
callq 0x38f2
movq 0x20(%rsp), %rbx
movq (%rsp), %rax
leaq 0x18(%rax), %rsi
movq %r12, 0x48(%rsp)
movq 0x20(%rax), %rcx
movq %rcx, 0x50(%rsp)
movq %r12, 0x58(%rsp)
movq 0x30(%rax), %rcx
movq %rcx, 0x60(%rsp)
movups 0x38(%rax), %xmm0
leaq 0x68(%rsp), %rax
movups %xmm0, (%rax)
movq %r12, 0x78(%rsp)
movq %r14, 0xa0(%rsp)
movq %r14, %rdi
movq %r13, %rdx
callq 0x38f2
movq %rbp, 0x80(%rsp)
leaq 0x88(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %r13, %rcx
callq 0x3226
movq %r14, %rbp
movq %r14, %rdi
callq 0x3a40
leaq 0x10(%rsp), %rdi
callq 0x3a40
movq 0x88(%rsp), %rbx
movq 0x90(%rsp), %r14
cmpq %r14, %rbx
je 0x2cd3
movq %r14, %rax
subq %rbx, %rax
sarq $0x4, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x438f
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4442
movq 0x88(%rsp), %r14
movq 0x90(%rsp), %r13
cmpq %r13, %r14
je 0x2cd3
movb (%r14), %r12b
movq 0x8(%r14), %rax
movq %rax, 0x10(%rsp)
movl $0x2, %edx
movq %r15, %rdi
leaq 0x2442(%rip), %rsi      # 0x5046
callq 0x2110
leaq 0xb0(%rsp), %rdi
movq %rsp, %rsi
callq 0x4006
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %r15, %rdi
callq 0x2110
movq %rax, %rbx
movl $0x4, %edx
movq %rax, %rdi
leaq 0x240f(%rip), %rsi      # 0x5049
callq 0x2110
leaq 0xb0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x4006
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %rbx, %rdi
callq 0x2110
movq %rax, %rbx
movl $0x9, %edx
movq %rax, %rdi
leaq 0x23dc(%rip), %rsi      # 0x504e
callq 0x2110
movb %r12b, 0x48(%rsp)
movl $0x1, %edx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x2110
movq %rax, %rbx
movl $0x2, %edx
movq %rax, %rdi
leaq 0x23c7(%rip), %rsi      # 0x5065
callq 0x2110
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x20c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2090
addq $0x10, %r14
jmp 0x2be0
movq (%rsp), %rax
cmpq $0x0, 0x10(%rax)
movq 0xa8(%rsp), %r14
movl $0x0, %r12d
je 0x2da6
movl $0x2, %edx
movq %r15, %rdi
leaq 0x2347(%rip), %rsi      # 0x5046
callq 0x2110
leaq 0xb0(%rsp), %rdi
movq %rsp, %rsi
callq 0x4006
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %r15, %rdi
callq 0x2110
movq %rax, %rbx
movl $0x4, %edx
movq %rax, %rdi
leaq 0x2314(%rip), %rsi      # 0x5049
callq 0x2110
movq (%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
leaq 0xb0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x4888
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %rbx, %rdi
callq 0x2110
movq %rax, %rbx
movl $0xf, %edx
movq %rax, %rdi
leaq 0x22de(%rip), %rsi      # 0x5058
callq 0x2110
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x20c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2090
movl $0x2, %edx
movq %r15, %rdi
leaq 0x2291(%rip), %rsi      # 0x5046
callq 0x2110
leaq 0xb0(%rsp), %rdi
movq %rsp, %rsi
callq 0x4006
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %r15, %rdi
callq 0x2110
movl $0x9, %edx
movq %rax, %rdi
leaq 0x2266(%rip), %rsi      # 0x504e
callq 0x2110
cmpq $0x0, 0x80(%rsp)
je 0x2eac
movq (%rsp), %rax
movl 0x8(%rax), %edx
movslq (%rax), %rcx
subl %ecx, %edx
incl %edx
movslq %edx, %rdx
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x20f0
movq (%rsp), %rax
movl 0x8(%rax), %edx
movslq 0x4(%rax), %rcx
subl %ecx, %edx
incl %edx
movslq %edx, %rdx
movq %rbp, %rdi
movq %r14, %rsi
callq 0x20f0
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %r15, %rdi
callq 0x2110
movq %rax, %rbx
movl $0x2, %edx
movq %rax, %rdi
leaq 0x2213(%rip), %rsi      # 0x506e
callq 0x2110
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq %rbx, %rdi
callq 0x2110
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x2e8e
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x20e0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x2ec0
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x20e0
jmp 0x2ec0
movl $0x5, %edx
movq %r15, %rdi
leaq 0x21ad(%rip), %rsi      # 0x5068
callq 0x2110
movl $0x2, %edx
movq %r15, %rdi
leaq 0x2196(%rip), %rsi      # 0x5065
callq 0x2110
movq 0x548d(%rip), %rax      # 0x8368
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x20c0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2090
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
leaq 0xa0(%rsp), %r13
je 0x2f24
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x20e0
movq 0x80(%rsp), %rdx
incq %rdx
movq 0x8(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rdx, %rcx
movq %rbp, %r14
movq %rdx, %rbp
ja 0x2ac0
leaq 0x5410(%rip), %rbx      # 0x8368
leaq 0x2112(%rip), %rsi      # 0x5071
movl $0x1, %edx
movq %rbx, %rdi
callq 0x2110
movq 0x53f5(%rip), %rax      # 0x8368
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x20c0
movsbl %al, %esi
leaq 0x53da(%rip), %rdi      # 0x8368
callq 0x2030
movq %rax, %rdi
callq 0x2090
leaq 0x53c6(%rip), %rdi      # 0x8368
callq 0x2160
leaq 0xb0(%rsp), %rdi
callq 0x3ad2
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x3052
jmp 0x3074
jmp 0x2ff8
jmp 0x2ff8
movq %rax, %rbx
jmp 0x2fe9
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x3a40
leaq 0x10(%rsp), %rdi
callq 0x3a40
jmp 0x3094
movq %rax, %rbx
jmp 0x3094
movq %rax, %rbx
jmp 0x301f
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x301f
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x20e0
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x3094
movq 0x58(%rsp), %rsi
incq %rsi
jmp 0x308f
movq %rax, %rbx
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x3052
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x20e0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x3077
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x20e0
jmp 0x3077
jmp 0x3074
jmp 0x3074
movq %rax, %rbx
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x3094
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x20e0
leaq 0xb0(%rsp), %rdi
callq 0x3ad2
movq %rbx, %rdi
callq 0x21d0