// File: /workspace/github_cpp_makefile_star2_O1/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, %r14
movq %rsi, -0x40(%rbp)
movq %rdi, %rbx
leaq 0x50f8(%rip), %r12      # 0x9c80
leaq 0x5101(%rip), %r13      # 0x9c90
testq %r14, %r14
je 0x4ba9
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0x2120
movq %rax, %r15
jmp 0x4bac
xorl %r15d, %r15d
testq %r15, %r15
jne 0x4c0a
testq %r14, %r14
je 0x4bcf
movq %r14, %rdi
movq %r12, %rsi
leaq 0x50e5(%rip), %rdx      # 0x9ca8
xorl %ecx, %ecx
callq 0x2120
movq %rax, %r15
jmp 0x4bd2
xorl %r15d, %r15d
testq %r15, %r15
jne 0x4c5d
testq %r14, %r14
je 0x4bf6
movq %r14, %rdi
movq %r12, %rsi
leaq 0x50d3(%rip), %rdx      # 0x9cc0
xorl %ecx, %ecx
callq 0x2120
jmp 0x4bf8
xorl %eax, %eax
testq %rax, %rax
je 0x4cbc
movq 0x80(%rax), %r14
jmp 0x4b8f
movq 0x80(%r15), %rdx
movq %rbx, %rdi
movq -0x40(%rbp), %r14
movq %r14, %rsi
callq 0x4b66
movq 0x88(%r15), %rdx
leaq -0x78(%rbp), %rdi
movq %r14, %rsi
callq 0x4b66
movq -0x68(%rbp), %r15
movq %rbx, -0x38(%rbp)
testq %r15, %r15
je 0x4cae
leaq -0x38(%rbp), %r14
leaq 0x8(%r15), %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x5efe
movq (%r15), %r15
testq %r15, %r15
jne 0x4c44
jmp 0x4cae
movq 0x80(%r15), %rdx
movq %rbx, %rdi
movq -0x40(%rbp), %r14
movq %r14, %rsi
callq 0x4b66
movq 0x88(%r15), %rdx
leaq -0x78(%rbp), %rdi
movq %r14, %rsi
callq 0x4b66
movq -0x68(%rbp), %r15
movq %rbx, -0x38(%rbp)
testq %r15, %r15
je 0x4cae
leaq -0x38(%rbp), %r14
leaq 0x8(%r15), %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x5efe
movq (%r15), %r15
testq %r15, %r15
jne 0x4c97
leaq -0x78(%rbp), %rdi
callq 0x44ca
jmp 0x4d61
testq %r14, %r14
je 0x4cdb
leaq 0x4fb8(%rip), %rsi      # 0x9c80
leaq 0x5009(%rip), %rdx      # 0x9cd8
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x2120
jmp 0x4cdd
xorl %eax, %eax
testq %rax, %rax
je 0x4d0f
movb 0xb8(%rax), %al
leaq -0x77(%rbp), %rdx
movb %al, -0x1(%rdx)
leaq -0x29(%rbp), %rax
movq %rax, (%rsp)
leaq -0x78(%rbp), %rsi
leaq -0x38(%rbp), %r8
leaq -0x2a(%rbp), %r9
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x61e2
jmp 0x4d61
testq %r14, %r14
je 0x4d73
leaq 0x4f65(%rip), %rsi      # 0x9c80
leaq 0x4fce(%rip), %rdx      # 0x9cf0
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x2120
testq %rax, %rax
je 0x4d73
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movups %xmm0, 0x20(%rbx)
movups %xmm0, 0x10(%rbx)
movq $0x0, 0x30(%rbx)
leaq 0x30(%rbx), %rax
movq %rax, (%rbx)
movq $0x1, 0x8(%rbx)
movl $0x3f800000, 0x20(%rbx) # imm = 0x3F800000
movups %xmm0, 0x28(%rbx)
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x8, %edi
callq 0x2070
movq 0x524c(%rip), %rcx      # 0x9fd0
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x524e(%rip), %rsi      # 0x9fe0
movq 0x525f(%rip), %rdx      # 0x9ff8
movq %rax, %rdi
callq 0x21b0
jmp 0x4da3
movq %rax, %r14
jmp 0x4db6
jmp 0x4daa
movq %rax, %r14
leaq -0x78(%rbp), %rdi
callq 0x44ca
movq %rbx, %rdi
callq 0x44ca
movq %r14, %rdi
callq 0x21c0