// File: MarkCBell[P]twister/./twister/kernel/parsing.cpp
// Function: expand_brackets(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&)
void expand_brackets(std::string &command, std::vector<std::string> &names, std::vector<std::string> &inverse_names)
{
	int num_names = int(names.size());
	
	for(size_t next = command.find(")"); next != std::string::npos; next = command.find(")", next))
	{
		size_t previous = command.rfind("(", next);
		std::string replacement = "", subreplacement = "";
		int power = atoi((char *) command.substr(next+2, std::string::npos).c_str());
		int power_length = digit_length(power);
		
		subreplacement = command.substr(previous+1, next-previous-1);
		if (power < 0)
		{
			size_t marker = 0;
			std::string new_subreplacement = "";
			for (std::string s = find_next_substring(subreplacement, separator, marker); marker != 0; s = find_next_substring(subreplacement, separator, marker))
			{
				for (int i = 0; i < num_names; i++)
				{
					if (names[i] == s)
					{
						s = inverse_names[i];
						break;
					}
					if (drill + names[i] == s)
					{
						s = drill + inverse_names[i];
						break;
					}
				}
				new_subreplacement = s + separator + new_subreplacement; // Restack the results.
			}
			subreplacement = new_subreplacement;
		}
		
		power = abs(power);
		
		for (int i = 0; i < power; i++)
			replacement += subreplacement;
		
		command.replace(previous, next-previous+1+1+power_length, replacement);
		
		next++;
	}
	
	return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x290, %rsp            # imm = 0x290
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x8c60
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x1393e(%rip), %rsi     # 0x2793c
xorl %eax, %eax
movl %eax, %edx
callq 0x35c0
movq %rax, -0x28(%rbp)
cmpq $-0x1, -0x28(%rbp)
je 0x14641
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x13326(%rip), %rsi     # 0x2734b
callq 0x3500
movq %rax, -0x30(%rbp)
leaq -0x51(%rbp), %rdi
movq %rdi, -0x260(%rbp)
callq 0x3560
movq -0x260(%rbp), %rdx
leaq 0x132a6(%rip), %rsi     # 0x272f2
leaq -0x50(%rbp), %rdi
callq 0x4e10
jmp 0x14057
leaq -0x51(%rbp), %rdi
callq 0x3360
leaq -0x89(%rbp), %rdi
movq %rdi, -0x268(%rbp)
callq 0x3560
movq -0x268(%rbp), %rdx
leaq 0x13271(%rip), %rsi     # 0x272f2
leaq -0x88(%rbp), %rdi
callq 0x4e10
jmp 0x1408f
leaq -0x89(%rbp), %rdi
callq 0x3360
movq -0x8(%rbp), %rsi
movq -0x28(%rbp), %rdx
addq $0x2, %rdx
leaq -0xb0(%rbp), %rdi
movq $-0x1, %rcx
callq 0x3320
jmp 0x140bc
leaq -0xb0(%rbp), %rdi
movq %rdi, -0x278(%rbp)
callq 0x3120
movq %rax, %rdi
callq 0x34a0
movq -0x278(%rbp), %rdi
movl %eax, -0x26c(%rbp)
callq 0x35f8
movl -0x26c(%rbp), %eax
movl %eax, -0x90(%rbp)
movl -0x90(%rbp), %edi
callq 0x12270
movl %eax, -0xb4(%rbp)
movq -0x8(%rbp), %rsi
movq -0x30(%rbp), %rcx
movq %rcx, %rdx
incq %rdx
movq -0x28(%rbp), %rax
notq %rcx
addq %rax, %rcx
leaq -0xd8(%rbp), %rdi
callq 0x3320
jmp 0x1412c
leaq -0x88(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x33c0
leaq -0xd8(%rbp), %rdi
callq 0x35f8
cmpl $0x0, -0x90(%rbp)
jge 0x14576
movq $0x0, -0xe0(%rbp)
leaq -0x101(%rbp), %rdi
movq %rdi, -0x280(%rbp)
callq 0x3560
movq -0x280(%rbp), %rdx
leaq 0x1316e(%rip), %rsi     # 0x272f2
leaq -0x100(%rbp), %rdi
callq 0x4e10
jmp 0x14192
leaq -0x101(%rbp), %rdi
callq 0x3360
leaq -0x148(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x3130
jmp 0x141b3
leaq 0x2140e(%rip), %rsi     # 0x355c8
leaq -0x168(%rbp), %rdi
callq 0x3130
jmp 0x141c8
leaq -0x128(%rbp), %rdi
leaq -0x148(%rbp), %rsi
leaq -0x168(%rbp), %rdx
leaq -0xe0(%rbp), %rcx
callq 0x11c10
jmp 0x141eb
leaq -0x168(%rbp), %rdi
callq 0x35f8
leaq -0x148(%rbp), %rdi
callq 0x35f8
cmpq $0x0, -0xe0(%rbp)
jne 0x142cf
leaq -0x128(%rbp), %rdi
callq 0x35f8
jmp 0x14542
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x51(%rbp), %rdi
callq 0x3360
jmp 0x1464a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x89(%rbp), %rdi
callq 0x3360
jmp 0x14636
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1462a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x101(%rbp), %rdi
callq 0x3360
jmp 0x1462a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x14565
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x142be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x35f8
leaq -0x148(%rbp), %rdi
callq 0x35f8
jmp 0x14565
movl $0x0, -0x16c(%rbp)
movl -0x16c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x143fc
movq -0x10(%rbp), %rdi
movslq -0x16c(%rbp), %rsi
callq 0x8c80
movq %rax, %rdi
leaq -0x128(%rbp), %rsi
callq 0x9a20
testb $0x1, %al
jne 0x1430d
jmp 0x14344
movq -0x18(%rbp), %rdi
movslq -0x16c(%rbp), %rsi
callq 0x8c80
movq %rax, %rsi
leaq -0x128(%rbp), %rdi
callq 0x3050
jmp 0x1432e
jmp 0x143fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x14534
movq -0x10(%rbp), %rdi
movslq -0x16c(%rbp), %rsi
callq 0x8c80
movq %rax, %rdx
leaq 0x2128a(%rip), %rsi     # 0x355e8
leaq -0x190(%rbp), %rdi
callq 0x14d90
jmp 0x1436c
leaq -0x190(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x9a20
movb %al, -0x281(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x35f8
movb -0x281(%rbp), %al
testb $0x1, %al
jne 0x1439d
jmp 0x143e6
movq -0x18(%rbp), %rdi
movslq -0x16c(%rbp), %rsi
callq 0x8c80
movq %rax, %rdx
leaq 0x21231(%rip), %rsi     # 0x355e8
leaq -0x1b0(%rbp), %rdi
callq 0x14d90
jmp 0x143c5
leaq -0x128(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x33c0
leaq -0x1b0(%rbp), %rdi
callq 0x35f8
jmp 0x143fc
jmp 0x143e8
movl -0x16c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x16c(%rbp)
jmp 0x142d9
leaq 0x211c5(%rip), %rdx     # 0x355c8
leaq -0x1f0(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x14d90
jmp 0x14418
leaq -0x1d0(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
leaq -0x100(%rbp), %rdx
callq 0x99d0
jmp 0x14434
leaq -0x100(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x33c0
leaq -0x1d0(%rbp), %rdi
callq 0x35f8
leaq -0x1f0(%rbp), %rdi
callq 0x35f8
leaq -0x230(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x3130
jmp 0x14474
leaq 0x2114d(%rip), %rsi     # 0x355c8
leaq -0x250(%rbp), %rdi
callq 0x3130
jmp 0x14489
leaq -0x210(%rbp), %rdi
leaq -0x230(%rbp), %rsi
leaq -0x250(%rbp), %rdx
leaq -0xe0(%rbp), %rcx
callq 0x11c10
jmp 0x144ac
leaq -0x128(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x33c0
leaq -0x210(%rbp), %rdi
callq 0x35f8
leaq -0x250(%rbp), %rdi
callq 0x35f8
leaq -0x230(%rbp), %rdi
callq 0x35f8
jmp 0x14203
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x35f8
jmp 0x14534
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x14528
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x35f8
leaq -0x230(%rbp), %rdi
callq 0x35f8
leaq -0x128(%rbp), %rdi
callq 0x35f8
jmp 0x14565
leaq -0x88(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x3050
jmp 0x14557
leaq -0x100(%rbp), %rdi
callq 0x35f8
jmp 0x14576
leaq -0x100(%rbp), %rdi
callq 0x35f8
jmp 0x1462a
movl -0x90(%rbp), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
movl %eax, -0x90(%rbp)
movl $0x0, -0x254(%rbp)
movl -0x254(%rbp), %eax
cmpl -0x90(%rbp), %eax
jge 0x145c6
leaq -0x50(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x33e0
jmp 0x145b3
jmp 0x145b5
movl -0x254(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x254(%rbp)
jmp 0x14593
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rax
subq %rsi, %rax
movslq -0xb4(%rbp), %rcx
leaq 0x2(%rax,%rcx), %rdx
leaq -0x50(%rbp), %rcx
callq 0x30f0
jmp 0x145ec
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x35f8
leaq -0x50(%rbp), %rdi
callq 0x35f8
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x13320(%rip), %rsi     # 0x2793c
callq 0x35c0
movq %rax, -0x28(%rbp)
jmp 0x1400b
leaq -0x88(%rbp), %rdi
callq 0x35f8
leaq -0x50(%rbp), %rdi
callq 0x35f8
jmp 0x1464a
addq $0x290, %rsp            # imm = 0x290
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x3550
nopw %cs:(%rax,%rax)