// File: /workspace/github_cpp_makefile_star2_O2/ghallak[P]regex-to-dfa/src/DFA.cpp
// Function: DFA::CreateDotFile(std::basic_string_view<char, std::char_traits<char>>) const
void DFA::CreateDotFile(std::string_view filename) const {
  std::ofstream out(filename.data());
  out << "digraph finite_state_machine {" << '\n'
      << "  rankdir=LR;" << '\n'
      << "  size=\"8,5\"" << '\n'
      << "  node [shape = circle]; q0" << '\n';

  std::unordered_map<const State*, std::size_t> state_id;
  for (std::size_t i = 0; i < states.size(); ++i) {
    auto p = states[i].get();
    for (const auto& trans : p->Transitions()) {
      state_id.try_emplace(p, state_id.size());
      state_id.try_emplace(trans.state, state_id.size());
      auto start_state = "q" + std::to_string(state_id[p]);
      auto end_state = "q" + std::to_string(state_id[trans.state]);
      auto edge_label = trans.character;

      if (trans.state->IsAcceptState()) {
        out << "node [shape = doublecircle];" << '\n';
      } else {
        out << "node [shape = circle];" << '\n';
      }
      out << "  " << start_state << " -> " << end_state << " [ label = \""
          << edge_label << "\" ];" << '\n';
    }
  }
  out << "}" << '\n';
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2c8, %rsp            # imm = 0x2C8
movq %rdi, -0x40(%rbp)
leaq -0x2e8(%rbp), %rbx
pushq $0x10
popq %rax
movq %rbx, %rdi
movq %rdx, %rsi
movl %eax, %edx
callq 0x2120
leaq 0x35dc(%rip), %rsi      # 0x6004
movq %rbx, %rdi
callq 0x20f0
pushq $0xa
popq %rsi
movq %rax, %rdi
callq 0x2150
leaq 0x35e1(%rip), %rsi      # 0x6023
movq %rax, %rdi
callq 0x20f0
pushq $0xa
popq %rsi
movq %rax, %rdi
callq 0x2150
leaq 0x35d5(%rip), %rsi      # 0x6031
movq %rax, %rdi
callq 0x20f0
pushq $0xa
popq %rsi
movq %rax, %rdi
callq 0x2150
leaq 0x35c8(%rip), %rsi      # 0x603e
movq %rax, %rdi
callq 0x20f0
pushq $0xa
popq %rsi
movq %rax, %rdi
callq 0x2150
leaq -0x98(%rbp), %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)
xorl %edx, %edx
leaq -0xc8(%rbp), %rbx
leaq 0x359c(%rip), %r15      # 0x605a
movq -0x40(%rbp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rcx, %rdx
jae 0x2c83
movq %rdx, -0x48(%rbp)
movq (%rax,%rdx,8), %rax
movq %rax, -0x38(%rbp)
movq (%rax), %r14
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
cmpq -0x50(%rbp), %r14
je 0x2c77
movq -0xb0(%rbp), %rax
movq %rax, -0x70(%rbp)
movq %rbx, %rdi
leaq -0x38(%rbp), %rsi
leaq -0x70(%rbp), %r12
movq %r12, %rdx
callq 0x2fde
movq -0xb0(%rbp), %rax
movq %rax, -0x70(%rbp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x2fde
leaq -0x90(%rbp), %r13
movq %rbx, %rdi
leaq -0x38(%rbp), %rsi
callq 0x40be
movq (%rax), %rsi
movq %r13, %rdi
callq 0x301e
leaq -0x70(%rbp), %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x2ff0
movq %r15, %r12
movq %r13, %rdi
callq 0x2070
movq %rbx, %rdi
movq %r14, -0x30(%rbp)
movq %r14, %rsi
callq 0x40be
leaq -0xe8(%rbp), %r15
movq (%rax), %rsi
movq %r15, %rdi
callq 0x301e
movq %r13, %rdi
movq %r12, %r14
movq %r12, %rsi
movq %r15, %rdx
callq 0x2ff0
leaq -0x70(%rbp), %r12
movq %r15, %rdi
callq 0x2070
movq -0x30(%rbp), %rcx
movq (%rcx), %rax
cmpb $0x0, 0x18(%rax)
movb 0x8(%rcx), %r15b
leaq 0x34bc(%rip), %rsi      # 0x6079
leaq 0x3498(%rip), %rax      # 0x605c
cmovneq %rax, %rsi
leaq -0x2e8(%rbp), %rdi
callq 0x20f0
movq %rax, %rdi
pushq $0xa
popq %rsi
callq 0x2150
leaq -0x2e8(%rbp), %rdi
leaq 0x34a3(%rip), %rsi      # 0x6090
callq 0x20f0
movq %rax, %rdi
movq %r12, %rsi
callq 0x20e0
movq %rax, %rdi
leaq 0x348c(%rip), %rsi      # 0x6093
callq 0x20f0
movq %rax, %rdi
leaq -0x90(%rbp), %rsi
callq 0x20e0
movq %rax, %rdi
leaq 0x3473(%rip), %rsi      # 0x6098
callq 0x20f0
movsbl %r15b, %esi
movq %rax, %rdi
callq 0x2150
movq %rax, %rdi
leaq 0x3465(%rip), %rsi      # 0x60a5
callq 0x20f0
movq %rax, %rdi
pushq $0xa
popq %rsi
callq 0x2150
leaq -0x90(%rbp), %rdi
callq 0x2070
movq %r12, %rdi
callq 0x2070
movq -0x30(%rbp), %rax
addq $0x10, %rax
movq %r14, %r15
movq %rax, %r14
jmp 0x2af0
movq -0x48(%rbp), %rdx
incq %rdx
jmp 0x2abe
leaq 0x3420(%rip), %rsi      # 0x60aa
leaq -0x2e8(%rbp), %rdi
callq 0x20f0
pushq $0xa
popq %rsi
movq %rax, %rdi
callq 0x2150
leaq -0xc8(%rbp), %rdi
callq 0x35de
leaq -0x2e8(%rbp), %rdi
callq 0x2190
addq $0x2c8, %rsp            # imm = 0x2C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2cf3
movq %rax, %rbx
jmp 0x2d1c
movq %rax, %rbx
leaq -0xe8(%rbp), %rdi
jmp 0x2d02
jmp 0x2cf3
jmp 0x2cf3
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
jmp 0x2d0b
movq %rax, %rbx
jmp 0x2d07
movq %rax, %rbx
jmp 0x2d10
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x2070
leaq -0x70(%rbp), %rdi
callq 0x2070
leaq -0xc8(%rbp), %rdi
callq 0x35de
leaq -0x2e8(%rbp), %rdi
callq 0x2190
movq %rbx, %rdi
callq 0x21e0