// File: ghallak[P]regex-to-dfa/src/RegexTree.cpp
// Function: RegexTree::CalcFollowPos(RegexTree::Node*)
void RegexTree::CalcFollowPos(RegexTree::Node* n) {
  if (auto node = dynamic_cast<RegexTree::UnionNode*>(n)) {
    CalcFollowPos(node->left.get());
    CalcFollowPos(node->right.get());
  } else if (auto node = dynamic_cast<RegexTree::ConcatNode*>(n)) {
    for (auto i : node->left->lastpos) {
      leaves[i]->followpos.insert(node->right->firstpos.cbegin(),
                                  node->right->firstpos.cend());
    }
    CalcFollowPos(node->left.get());
    CalcFollowPos(node->right.get());
  } else if (auto node = dynamic_cast<RegexTree::StarNode*>(n)) {
    for (auto i : node->lastpos) {
      leaves[i]->followpos.insert(node->firstpos.cbegin(),
                                  node->firstpos.cend());
    }
    CalcFollowPos(node->child.get());
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x90(%rbp)
cmpq $0x0, %rax
je 0xd2b6
movq -0x90(%rbp), %rdi
leaq 0x119eb(%rip), %rsi     # 0x1ec88
leaq 0x11a0c(%rip), %rdx     # 0x1ecb0
xorl %eax, %eax
movl %eax, %ecx
callq 0x21a0
movq %rax, -0xa0(%rbp)
jmp 0xd2c1
xorl %eax, %eax
movq %rax, -0xa0(%rbp)
jmp 0xd2c1
movq -0xa0(%rbp), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0xd316
movq -0x18(%rbp), %rdi
addq $0x80, %rdi
callq 0x5cb0
movq -0x98(%rbp), %rdi
movq %rax, %rsi
callq 0xd260
movq -0x18(%rbp), %rdi
addq $0x88, %rdi
callq 0x5cb0
movq -0x98(%rbp), %rdi
movq %rax, %rsi
callq 0xd260
jmp 0xd5bb
movq -0x10(%rbp), %rax
movq %rax, -0xa8(%rbp)
cmpq $0x0, %rax
je 0xd34e
movq -0xa8(%rbp), %rdi
leaq 0x11953(%rip), %rsi     # 0x1ec88
leaq 0x1195c(%rip), %rdx     # 0x1ec98
xorl %eax, %eax
movl %eax, %ecx
callq 0x21a0
movq %rax, -0xb0(%rbp)
jmp 0xd359
xorl %eax, %eax
movq %rax, -0xb0(%rbp)
jmp 0xd359
movq -0xb0(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0xd48c
movq -0x20(%rbp), %rdi
addq $0x80, %rdi
callq 0x5c90
addq $0x40, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x4d60
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
callq 0x4d90
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x4dc0
testb $0x1, %al
jne 0xd3b7
jmp 0xd449
leaq -0x30(%rbp), %rdi
callq 0x4df0
movq -0x98(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rsi
callq 0xe070
movq (%rax), %rax
addq $0x80, %rax
movq %rax, -0xb8(%rbp)
movq -0x20(%rbp), %rdi
addq $0x88, %rdi
callq 0x5c90
movq %rax, %rdi
addq $0x8, %rdi
callq 0x4be0
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rdi
addq $0x88, %rdi
callq 0x5c90
movq %rax, %rdi
addq $0x8, %rdi
callq 0x4c10
movq -0xb8(%rbp), %rdi
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x4f30
leaq -0x30(%rbp), %rdi
callq 0x4f70
jmp 0xd3a1
movq -0x20(%rbp), %rdi
addq $0x80, %rdi
callq 0x5cb0
movq -0x98(%rbp), %rdi
movq %rax, %rsi
callq 0xd260
movq -0x20(%rbp), %rdi
addq $0x88, %rdi
callq 0x5cb0
movq -0x98(%rbp), %rdi
movq %rax, %rsi
callq 0xd260
jmp 0xd5b9
movq -0x10(%rbp), %rax
movq %rax, -0xc0(%rbp)
cmpq $0x0, %rax
je 0xd4c4
movq -0xc0(%rbp), %rdi
leaq 0x117dd(%rip), %rsi     # 0x1ec88
leaq 0x11816(%rip), %rdx     # 0x1ecc8
xorl %eax, %eax
movl %eax, %ecx
callq 0x21a0
movq %rax, -0xc8(%rbp)
jmp 0xd4cf
xorl %eax, %eax
movq %rax, -0xc8(%rbp)
jmp 0xd4cf
movq -0xc8(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0xd5b7
movq -0x58(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
callq 0x4d60
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rdi
callq 0x4d90
movq %rax, -0x70(%rbp)
leaq -0x68(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x4dc0
testb $0x1, %al
jne 0xd51e
jmp 0xd598
leaq -0x68(%rbp), %rdi
callq 0x4df0
movq -0x98(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rsi
callq 0xe070
movq (%rax), %rax
addq $0x80, %rax
movq %rax, -0xd0(%rbp)
movq -0x58(%rbp), %rdi
addq $0x8, %rdi
callq 0x4be0
movq %rax, -0x80(%rbp)
movq -0x58(%rbp), %rdi
addq $0x8, %rdi
callq 0x4c10
movq -0xd0(%rbp), %rdi
movq %rax, -0x88(%rbp)
movq -0x80(%rbp), %rsi
movq -0x88(%rbp), %rdx
callq 0x4f30
leaq -0x68(%rbp), %rdi
callq 0x4f70
jmp 0xd50b
movq -0x58(%rbp), %rdi
addq $0x80, %rdi
callq 0x5cb0
movq -0x98(%rbp), %rdi
movq %rax, %rsi
callq 0xd260
jmp 0xd5b9
jmp 0xd5bb
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop