// File: davinash[P]regex/src/regex.cpp
// Function: RegEx::PreProcessBracket(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
std::string RegEx::PreProcessBracket( std::string strRegEx) {
	std::string::size_type startPos, endPos, separatorPos;
	std::string ReplacedStrRegEx;

	startPos = strRegEx.find_first_of("[");
	endPos   = strRegEx.find_first_of("]");
	separatorPos = strRegEx.find_first_of("-");

	if ( startPos == std::string::npos || endPos == std::string::npos )
		return strRegEx;

	ReplacedStrRegEx += strRegEx.substr( 0, startPos );
	ReplacedStrRegEx.push_back('(');
	std::string result = strRegEx.substr( startPos + 1, endPos - startPos - 1);
	char first = result[0];
	char last  = result[result.size() - 1 ];

	if ( separatorPos != std::string::npos ) {		
		while ( first != last ) {
			ReplacedStrRegEx.push_back(first);
			ReplacedStrRegEx += "|";
			first++;
		}
		ReplacedStrRegEx.push_back(first);				
	} else {
		startPos++;
		while ( startPos != endPos - 1) {
			ReplacedStrRegEx.push_back(strRegEx[startPos]);
			ReplacedStrRegEx += "|";
			startPos++;
		}
		ReplacedStrRegEx.push_back(strRegEx[endPos - 1]);
	}
	ReplacedStrRegEx += strRegEx.substr( endPos + 1, strRegEx.size() - endPos );
	ReplacedStrRegEx += ")";

	return ReplacedStrRegEx;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdx, -0xd8(%rbp)
movq %rdi, -0xe8(%rbp)
movq %rdi, %rax
movq %rax, -0xe0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x3320
movq -0xd8(%rbp), %rdi
leaq 0xd3e9(%rip), %rsi      # 0x165cf
xorl %eax, %eax
movl %eax, %edx
callq 0x30f0
movq -0xd8(%rbp), %rdi
movq %rax, -0x20(%rbp)
leaq 0xd1aa(%rip), %rsi      # 0x163ab
xorl %eax, %eax
movl %eax, %edx
callq 0x30f0
movq -0xd8(%rbp), %rdi
movq %rax, -0x28(%rbp)
leaq 0xd3b5(%rip), %rsi      # 0x165d1
xorl %eax, %eax
movl %eax, %edx
callq 0x30f0
movq %rax, -0x30(%rbp)
cmpq $-0x1, -0x20(%rbp)
je 0x9237
cmpq $-0x1, -0x28(%rbp)
jne 0x9256
movq -0xd8(%rbp), %rsi
movq -0xe8(%rbp), %rdi
callq 0x3120
movl $0x1, -0x54(%rbp)
jmp 0x9531
movq -0xd8(%rbp), %rsi
movq -0x20(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
leaq -0x78(%rbp), %rdi
callq 0x3270
jmp 0x9270
leaq -0x50(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x3310
jmp 0x927f
leaq -0x78(%rbp), %rdi
callq 0x3140
leaq -0x50(%rbp), %rdi
movl $0x28, %esi
callq 0x3200
jmp 0x9298
movq -0xd8(%rbp), %rsi
movq -0x20(%rbp), %rcx
movq %rcx, %rdx
incq %rdx
movq -0x28(%rbp), %rax
notq %rcx
addq %rax, %rcx
leaq -0xa8(%rbp), %rdi
callq 0x3270
jmp 0x92c1
xorl %eax, %eax
movl %eax, %esi
leaq -0xa8(%rbp), %rdi
callq 0x3410
movq %rax, -0xf0(%rbp)
jmp 0x92da
movq -0xf0(%rbp), %rax
movb (%rax), %al
movb %al, -0xa9(%rbp)
leaq -0xa8(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x3190
movq -0x100(%rbp), %rdi
movq %rax, %rsi
decq %rsi
callq 0x3410
movq %rax, -0xf8(%rbp)
jmp 0x9317
movq -0xf8(%rbp), %rax
movb (%rax), %al
movb %al, -0xaa(%rbp)
cmpq $-0x1, -0x30(%rbp)
je 0x93d5
jmp 0x9333
movsbl -0xa9(%rbp), %eax
movsbl -0xaa(%rbp), %ecx
cmpl %ecx, %eax
je 0x93be
movsbl -0xa9(%rbp), %esi
leaq -0x50(%rbp), %rdi
callq 0x3200
jmp 0x9357
leaq 0xd275(%rip), %rsi      # 0x165d3
leaq -0x50(%rbp), %rdi
callq 0x3230
jmp 0x9369
movb -0xa9(%rbp), %al
addb $0x1, %al
movb %al, -0xa9(%rbp)
jmp 0x9333
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x954a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x3140
jmp 0x954a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x9523
movsbl -0xa9(%rbp), %esi
leaq -0x50(%rbp), %rdi
callq 0x3200
jmp 0x93d0
jmp 0x9473
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
je 0x9440
movq -0xd8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x3410
movq %rax, -0x108(%rbp)
jmp 0x940b
movq -0x108(%rbp), %rax
movsbl (%rax), %esi
leaq -0x50(%rbp), %rdi
callq 0x3200
jmp 0x9420
leaq 0xd1ac(%rip), %rsi      # 0x165d3
leaq -0x50(%rbp), %rdi
callq 0x3230
jmp 0x9432
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x93e1
movq -0xd8(%rbp), %rdi
movq -0x28(%rbp), %rsi
decq %rsi
callq 0x3410
movq %rax, -0x110(%rbp)
jmp 0x945c
movq -0x110(%rbp), %rax
movsbl (%rax), %esi
leaq -0x50(%rbp), %rdi
callq 0x3200
jmp 0x9471
jmp 0x9473
movq -0xd8(%rbp), %rdi
movq -0x28(%rbp), %rax
incq %rax
movq %rax, -0x118(%rbp)
callq 0x3190
movq -0xd8(%rbp), %rsi
movq -0x118(%rbp), %rdx
movq %rax, %rcx
movq -0x28(%rbp), %rax
subq %rax, %rcx
leaq -0xd0(%rbp), %rdi
callq 0x3270
jmp 0x94b3
leaq -0x50(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x3310
jmp 0x94c5
leaq -0xd0(%rbp), %rdi
callq 0x3140
leaq 0xceef(%rip), %rsi      # 0x163c7
leaq -0x50(%rbp), %rdi
callq 0x3230
jmp 0x94e3
movq -0xe8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x3120
movl $0x1, -0x54(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x3140
jmp 0x9531
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x3140
leaq -0xa8(%rbp), %rdi
callq 0x3140
jmp 0x954a
leaq -0x50(%rbp), %rdi
callq 0x3140
movq -0xe0(%rbp), %rax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
leaq -0x50(%rbp), %rdi
callq 0x3140
movq -0x80(%rbp), %rdi
callq 0x33a0
nopl (%rax)