// File: /workspace/github_cpp_makefile_star2_O3/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 $0x68, %rsp
movq %rsi, -0x48(%rbp)
movq %rdi, -0x38(%rbp)
testq %rdx, %rdx
je 0x4a63
movq %rdx, %r15
leaq 0x5282(%rip), %r12      # 0x9c80
leaq 0x528b(%rip), %r13      # 0x9c90
leaq 0x529c(%rip), %r14      # 0x9ca8
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0x2120
testq %rax, %rax
jne 0x4a91
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x2120
testq %rax, %rax
jne 0x4aeb
movq %r15, %rdi
movq %r12, %rsi
leaq 0x5279(%rip), %rdx      # 0x9cc0
xorl %ecx, %ecx
callq 0x2120
testq %rax, %rax
je 0x4b4e
movq 0x80(%rax), %r15
testq %r15, %r15
jne 0x4a0c
movl $0x8, %edi
callq 0x2070
movq 0x555c(%rip), %rcx      # 0x9fd0
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x555e(%rip), %rsi      # 0x9fe0
movq 0x556f(%rip), %rdx      # 0x9ff8
movq %rax, %rdi
callq 0x21b0
movq %rax, %rbx
movq 0x80(%rax), %rdx
movq -0x38(%rbp), %r15
movq %r15, %rdi
movq -0x48(%rbp), %r14
movq %r14, %rsi
callq 0x49d6
movq 0x88(%rbx), %rdx
leaq -0x80(%rbp), %rdi
movq %r14, %rsi
callq 0x49d6
movq -0x70(%rbp), %r14
movq %r15, -0x40(%rbp)
testq %r14, %r14
je 0x4b43
leaq -0x40(%rbp), %rbx
leaq 0x8(%r14), %rsi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x5d66
movq (%r14), %r14
testq %r14, %r14
jne 0x4ad2
jmp 0x4b43
movq %rax, %rbx
movq 0x80(%rax), %rdx
movq -0x38(%rbp), %r15
movq %r15, %rdi
movq -0x48(%rbp), %r14
movq %r14, %rsi
callq 0x49d6
movq 0x88(%rbx), %rdx
leaq -0x80(%rbp), %rdi
movq %r14, %rsi
callq 0x49d6
movq -0x70(%rbp), %r14
movq %r15, -0x40(%rbp)
testq %r14, %r14
je 0x4b43
leaq -0x40(%rbp), %rbx
leaq 0x8(%r14), %rsi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x5d66
movq (%r14), %r14
testq %r14, %r14
jne 0x4b2c
leaq -0x80(%rbp), %rdi
callq 0x43ae
jmp 0x4b9a
leaq 0x512b(%rip), %rsi      # 0x9c80
leaq 0x517c(%rip), %rdx      # 0x9cd8
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x2120
testq %rax, %rax
je 0x4bac
movb 0xb8(%rax), %al
leaq -0x7f(%rbp), %rdx
movb %al, -0x1(%rdx)
leaq -0x29(%rbp), %rax
movq %rax, (%rsp)
leaq -0x80(%rbp), %rsi
leaq -0x40(%rbp), %r8
leaq -0x2a(%rbp), %r9
movq -0x38(%rbp), %r15
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x6014
movq %r15, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x50cd(%rip), %rsi      # 0x9c80
leaq 0x5136(%rip), %rdx      # 0x9cf0
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x2120
testq %rax, %rax
je 0x4a63
movq -0x38(%rbp), %rax
movq $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 0x4b9d
jmp 0x4bfe
movq %rax, %rbx
jmp 0x4c11
jmp 0x4c05
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x43ae
movq -0x38(%rbp), %rdi
callq 0x43ae
movq %rbx, %rdi
callq 0x21c0