// File: /workspace/github_cpp_makefile_star2_O2/ghallak[P]regex-to-dfa/src/RegexTree.cpp
// Function: RegexTree::Alphabet(RegexTree::Node*)
std::unordered_set<char> RegexTree::Alphabet(RegexTree::Node* n) {
  if (auto node = dynamic_cast<RegexTree::ConcatNode*>(n)) {
    auto alphabet1 = Alphabet(node->left.get());
    auto alphabet2 = Alphabet(node->right.get());
    alphabet1.insert(alphabet2.begin(), alphabet2.end());
    return alphabet1;
  } else if (auto node = dynamic_cast<RegexTree::UnionNode*>(n)) {
    auto alphabet1 = Alphabet(node->left.get());
    auto alphabet2 = Alphabet(node->right.get());
    alphabet1.insert(alphabet2.begin(), alphabet2.end());
    return alphabet1;
  } else if (auto node = dynamic_cast<RegexTree::StarNode*>(n)) {
    return Alphabet(node->child.get());
  } else if (auto node = dynamic_cast<RegexTree::LeafNode*>(n)) {
    return std::unordered_set<char>({node->label});
  } else if (auto node = dynamic_cast<RegexTree::EndNode*>(n)) {
    return std::unordered_set<char>();
  } else {
    // there is no 6th type of RegexTree nodes
    throw std::exception();
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %r15
movq %rsi, -0x40(%rbp)
movq %rdi, -0x38(%rbp)
leaq 0x541f(%rip), %r12      # 0x9c88
leaq 0x5428(%rip), %r13      # 0x9c98
leaq 0x5439(%rip), %rbx      # 0x9cb0
testq %r15, %r15
je 0x4a00
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0x2130
testq %rax, %rax
jne 0x48d0
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x2130
testq %rax, %rax
jne 0x4910
movq %r15, %rdi
movq %r12, %rsi
leaq 0x5411(%rip), %rdx      # 0x9cc8
xorl %ecx, %ecx
callq 0x2130
testq %rax, %rax
je 0x4959
movq 0x80(%rax), %r15
jmp 0x4877
movq %rax, %r14
movq 0x80(%rax), %rdx
movq -0x38(%rbp), %rbx
movq %rbx, %rdi
movq -0x40(%rbp), %r15
movq %r15, %rsi
callq 0x4846
movq 0x88(%r14), %rdx
leaq -0x78(%rbp), %rdi
movq %r15, %rsi
callq 0x4846
movq -0x68(%rbp), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x5972
jmp 0x494e
movq %rax, %r14
movq 0x80(%rax), %rdx
movq -0x38(%rbp), %rbx
movq %rbx, %rdi
movq -0x40(%rbp), %r15
movq %r15, %rsi
callq 0x4846
movq 0x88(%r14), %rdx
leaq -0x78(%rbp), %rdi
movq %r15, %rsi
callq 0x4846
movq -0x68(%rbp), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x5972
leaq -0x78(%rbp), %rdi
callq 0x432c
jmp 0x49a5
leaq 0x5328(%rip), %rsi      # 0x9c88
leaq 0x5379(%rip), %rdx      # 0x9ce0
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x2130
testq %rax, %rax
je 0x49b7
movb 0xb8(%rax), %al
leaq -0x77(%rbp), %rdx
movb %al, -0x1(%rdx)
leaq -0x29(%rbp), %rax
movq %rax, (%rsp)
leaq -0x78(%rbp), %rsi
leaq -0x2b(%rbp), %r8
leaq -0x2a(%rbp), %r9
movq -0x38(%rbp), %rbx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x5d54
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x52ca(%rip), %rsi      # 0x9c88
leaq 0x5333(%rip), %rdx      # 0x9cf8
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x2130
testq %rax, %rax
je 0x4a00
movq -0x38(%rbp), %rax
andq $0x0, 0x20(%rax)
leaq 0x30(%rax), %rcx
movq %rcx, (%rax)
movq $0x1, 0x8(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movl $0x3f800000, 0x20(%rax) # imm = 0x3F800000
movups %xmm0, 0x28(%rax)
jmp 0x49a8
pushq $0x8
popq %rdi
callq 0x2080
movq 0x55c1(%rip), %rcx      # 0x9fd0
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x55c3(%rip), %rsi      # 0x9fe0
movq 0x55d4(%rip), %rdx      # 0x9ff8
movq %rax, %rdi
callq 0x21d0
jmp 0x4a30
jmp 0x4a3e
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x432c
jmp 0x4a41
movq %rax, %rbx
movq -0x38(%rbp), %rdi
callq 0x432c
movq %rbx, %rdi
callq 0x21e0