// File: davinash[P]regex/src/regex.cpp
// Function: RegEx::ClosureOptional()
bool RegEx::ClosureOptional() {

	Table PrevTable;
	if(!PopTable(PrevTable))
		return false;

	RegExState *LeftTable  = new RegExState(m_nNextStateID++);
	RegExState *RightTable = new RegExState(m_nNextStateID++);

	LeftTable->AddTransition(EPSILON, RightTable);
	LeftTable->AddTransition(EPSILON, ((*(PrevTable.begin()))));
	((*(PrevTable.rbegin())))->AddTransition(EPSILON, RightTable);

	PrevTable.insert( PrevTable.begin(), LeftTable );
	PrevTable.push_back ( RightTable);

	m_CharacterClassStack.push(PrevTable);

	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0x28(%rbp), %rdi
movq %rdi, -0x80(%rbp)
callq 0xa470
movq -0x88(%rbp), %rdi
movq -0x80(%rbp), %rsi
callq 0x7370
movb %al, -0x71(%rbp)
jmp 0x777c
movb -0x71(%rbp), %al
testb $0x1, %al
jne 0x77a6
jmp 0x7785
movb $0x0, -0x1(%rbp)
movl $0x1, -0x38(%rbp)
jmp 0x7973
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x798a
movl $0x78, %edi
callq 0x3250
movq %rax, -0x90(%rbp)
jmp 0x77b9
movq -0x90(%rbp), %rdi
movq -0x88(%rbp), %rax
movl 0x14c(%rax), %esi
movl %esi, %ecx
incl %ecx
movl %ecx, 0x14c(%rax)
callq 0xab80
jmp 0x77de
movq -0x90(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x78, %edi
callq 0x3250
movq %rax, -0x98(%rbp)
jmp 0x77fc
movq -0x98(%rbp), %rdi
movq -0x88(%rbp), %rax
movl 0x14c(%rax), %esi
movl %esi, %ecx
incl %ecx
movl %ecx, 0x14c(%rax)
callq 0xab80
jmp 0x7821
movq -0x98(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rdx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x13ec0
jmp 0x7840
movq -0x40(%rbp), %rax
movq %rax, -0xa0(%rbp)
leaq -0x28(%rbp), %rdi
callq 0xa9e0
movq %rax, -0x50(%rbp)
leaq -0x50(%rbp), %rdi
callq 0xaa10
movq -0xa0(%rbp), %rdi
movq (%rax), %rdx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x13ec0
jmp 0x7877
leaq -0x58(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
leaq -0x28(%rbp), %rsi
callq 0xa960
movq -0xb0(%rbp), %rdi
callq 0xa9b0
movq %rax, -0xa8(%rbp)
jmp 0x78a0
movq -0xa8(%rbp), %rax
movq (%rax), %rdi
movq -0x48(%rbp), %rdx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x13ec0
jmp 0x78ba
leaq -0x28(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0xa9e0
movq %rax, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0xab10
movq -0xc0(%rbp), %rdi
movq -0x60(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0xaca0
movq %rax, -0xb8(%rbp)
jmp 0x78f8
movq -0xb8(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xabe0
jmp 0x7912
movq -0x88(%rbp), %rdi
addq $0x30, %rdi
leaq -0x28(%rbp), %rsi
callq 0xab50
jmp 0x7928
movb $0x1, -0x1(%rbp)
movl $0x1, -0x38(%rbp)
jmp 0x7973
movq -0x90(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
movl $0x78, %esi
callq 0x3260
jmp 0x798a
movq -0x98(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
movl $0x78, %esi
callq 0x3260
jmp 0x798a
leaq -0x28(%rbp), %rdi
callq 0xa530
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xc0, %rsp
popq %rbp
retq
leaq -0x28(%rbp), %rdi
callq 0xa530
movq -0x30(%rbp), %rdi
callq 0x33a0
nopl (%rax)