// File: /workspace/github_cpp_makefile_star2_O1/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, 0xa0(%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 0x29c3
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 0x28d1
movl $0x4, %ebp
movl %ebx, %eax
cmpl $0x63, %eax
jbe 0x28ca
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0x28cf
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x28d1
movl %eax, %ecx
imulq %r13, %rcx
shrq $0x2d, %rcx
addl $0x4, %ebp
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0x289c
addl $-0x3, %ebp
jmp 0x28d1
addl $-0x2, %ebp
jmp 0x28d1
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 0x3a6f
movl $0x1, %r8d
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0x2778(%rip), %rcx      # 0x507f
callq 0x2100
movq %r12, 0x10(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x292f
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
jmp 0x2937
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 0x4020
movq %rax, %rdi
leaq 0x10(%rsp), %rsi
callq 0x2130
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x2990
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x20e0
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x29a7
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 0x288a
leaq 0x599e(%rip), %rbx      # 0x8368
leaq 0x2648(%rip), %rsi      # 0x5019
movl $0xb, %edx
movq %rbx, %rdi
callq 0x2110
movq 0x5983(%rip), %rax      # 0x8368
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x20c0
movsbl %al, %esi
leaq 0x5968(%rip), %rdi      # 0x8368
callq 0x2030
movq %rax, %rdi
callq 0x2090
leaq 0x5954(%rip), %rbx      # 0x8368
leaq 0x260a(%rip), %rsi      # 0x5025
movl $0xc, %edx
movq %rbx, %rdi
callq 0x2110
movq 0x5939(%rip), %rax      # 0x8368
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x20c0
movsbl %al, %esi
leaq 0x591e(%rip), %rdi      # 0x8368
callq 0x2030
movq %rax, %rdi
callq 0x2090
leaq 0x590a(%rip), %rbx      # 0x8368
leaq 0x25cd(%rip), %rsi      # 0x5032
movl $0x13, %edx
movq %rbx, %rdi
callq 0x2110
movq 0x58ef(%rip), %rax      # 0x8368
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x20c0
movsbl %al, %esi
leaq 0x58d4(%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 0x2f4c
xorl %r14d, %r14d
leaq 0x48(%rsp), %r12
leaq 0x98(%rsp), %r13
xorl %ebp, %ebp
movq (%rax,%rbp,8), %rax
movq %rax, (%rsp)
leaq 0x18(%rax), %rsi
movq %r14, 0x10(%rsp)
movq 0x20(%rax), %rcx
movq %rcx, 0x18(%rsp)
movq %r14, 0x20(%rsp)
movq 0x30(%rax), %rcx
movq %rcx, 0x28(%rsp)
movups 0x38(%rax), %xmm0
leaq 0x30(%rsp), %rax
movups %xmm0, (%rax)
movq %r14, 0x40(%rsp)
leaq 0x10(%rsp), %rdi
movq %rdi, 0x48(%rsp)
movq %r12, %rdx
callq 0x38fc
movq 0x20(%rsp), %rbx
movq (%rsp), %rax
leaq 0x18(%rax), %rsi
movq %r14, 0x48(%rsp)
movq 0x20(%rax), %rcx
movq %rcx, 0x50(%rsp)
movq %r14, 0x58(%rsp)
movq 0x30(%rax), %rcx
movq %rcx, 0x60(%rsp)
movups 0x38(%rax), %xmm0
leaq 0x68(%rsp), %rax
movups %xmm0, (%rax)
movq %r14, 0x78(%rsp)
movq %r12, 0x98(%rsp)
movq %r12, %rdi
movq %r13, %rdx
callq 0x38fc
leaq 0x80(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %r13, %rcx
callq 0x31f2
movq %r12, %rdi
callq 0x3a4a
leaq 0x10(%rsp), %rdi
callq 0x3a4a
movq 0x80(%rsp), %rbx
movq 0x88(%rsp), %r14
cmpq %r14, %rbx
je 0x2bc9
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 0x43cd
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4480
movq %rbp, 0xa8(%rsp)
movq %r12, %rbp
movq 0x80(%rsp), %r14
movq 0x88(%rsp), %r12
cmpq %r12, %r14
je 0x2cd7
movb (%r14), %r13b
movq 0x8(%r14), %rax
movq %rax, 0x10(%rsp)
movl $0x2, %edx
movq %r15, %rdi
leaq 0x243e(%rip), %rsi      # 0x5046
callq 0x2110
leaq 0xb0(%rsp), %rdi
movq %rsp, %rsi
callq 0x4020
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %r15, %rdi
callq 0x2110
movq %rax, %rbx
movl $0x4, %edx
movq %rax, %rdi
leaq 0x240b(%rip), %rsi      # 0x5049
callq 0x2110
leaq 0xb0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x4020
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %rbx, %rdi
callq 0x2110
movq %rax, %rbx
movl $0x9, %edx
movq %rax, %rdi
leaq 0x23d8(%rip), %rsi      # 0x504e
callq 0x2110
movb %r13b, 0x48(%rsp)
movl $0x1, %edx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x2110
movq %rax, %rbx
movl $0x2, %edx
movq %rax, %rdi
leaq 0x23c3(%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 0x2be4
movq (%rsp), %rax
cmpq $0x0, 0x10(%rax)
movq 0xa0(%rsp), %r14
movq %rbp, %r12
leaq 0x98(%rsp), %r13
movq 0xa8(%rsp), %rbp
je 0x2db7
movl $0x2, %edx
movq %r15, %rdi
leaq 0x2336(%rip), %rsi      # 0x5046
callq 0x2110
leaq 0xb0(%rsp), %rdi
movq %rsp, %rsi
callq 0x4020
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %r15, %rdi
callq 0x2110
movq %rax, %rbx
movl $0x4, %edx
movq %rax, %rdi
leaq 0x2303(%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 0x48c6
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %rbx, %rdi
callq 0x2110
movq %rax, %rbx
movl $0xf, %edx
movq %rax, %rdi
leaq 0x22cd(%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 0x2280(%rip), %rsi      # 0x5046
callq 0x2110
leaq 0xb0(%rsp), %rdi
movq %rsp, %rsi
callq 0x4020
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %r15, %rdi
callq 0x2110
movl $0x9, %edx
movq %rax, %rdi
leaq 0x2255(%rip), %rsi      # 0x504e
callq 0x2110
testq %rbp, %rbp
je 0x2eb7
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 %r12, %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 0x2208(%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 0x2e99
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x20e0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x2ecb
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x20e0
jmp 0x2ecb
movl $0x5, %edx
movq %r15, %rdi
leaq 0x21a2(%rip), %rsi      # 0x5068
callq 0x2110
movl $0x2, %edx
movq %r15, %rdi
leaq 0x218b(%rip), %rsi      # 0x5065
callq 0x2110
movq 0x5482(%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 0x80(%rsp), %rdi
testq %rdi, %rdi
movl $0x0, %r14d
je 0x2f2d
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x20e0
incq %rbp
movq 0x8(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rbp, %rcx
ja 0x2ac8
leaq 0x5415(%rip), %rbx      # 0x8368
leaq 0x2117(%rip), %rsi      # 0x5071
movl $0x1, %edx
movq %rbx, %rdi
callq 0x2110
movq 0x53fa(%rip), %rax      # 0x8368
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x20c0
movsbl %al, %esi
leaq 0x53df(%rip), %rdi      # 0x8368
callq 0x2030
movq %rax, %rdi
callq 0x2090
leaq 0x53cb(%rip), %rdi      # 0x8368
callq 0x2160
leaq 0xb0(%rsp), %rdi
callq 0x3adc
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x306c
movq %rax, %rbx
jmp 0x304a
jmp 0x2ff0
jmp 0x2ff0
movq %rax, %rbx
jmp 0x2fe1
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x3a4a
leaq 0x10(%rsp), %rdi
callq 0x3a4a
jmp 0x308c
movq %rax, %rbx
jmp 0x308c
movq %rax, %rbx
jmp 0x3017
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x3017
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x20e0
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x308c
movq 0x58(%rsp), %rsi
incq %rsi
jmp 0x3087
movq %rax, %rbx
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x304a
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x20e0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x306f
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x20e0
jmp 0x306f
jmp 0x306c
jmp 0x306c
movq %rax, %rbx
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x308c
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x20e0
leaq 0xb0(%rsp), %rdi
callq 0x3adc
movq %rbx, %rdi
callq 0x21d0