// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rdx, 0x28(%rsp)
movq %rsi, %r14
movq %rdi, %r12
movq 0x8(%rsi), %r15
subq (%rsi), %r15
shrq $0x5, %r15
leaq 0x8397(%rip), %rsi      # 0x11924
xorl %ebx, %ebx
xorl %edx, %edx
callq 0x3430
testl %r15d, %r15d
cmovlel %ebx, %r15d
shlq $0x5, %r15
addq $0x20, %r15
movq %r15, 0x60(%rsp)
leaq 0xe8(%rsp), %rbp
leaq 0xc8(%rsp), %r13
leaq 0x168(%rsp), %r15
movq %r12, 0x50(%rsp)
cmpq $-0x1, %rax
je 0x9926
movq %r12, %rdi
leaq 0x7d8d(%rip), %rsi      # 0x11368
movq %rax, %rdx
movq %rax, 0x8(%rsp)
callq 0x33a0
movq %rax, 0x20(%rsp)
movq %rbp, %rdi
movq %r13, %rbx
leaq 0x7d15(%rip), %r13      # 0x1130f
movq %r13, %rsi
movq %rbx, %rdx
callq 0x3e82
movq %rbx, %rdi
leaq 0xa8(%rsp), %rbx
movq %r13, %rsi
movq %rbx, %rdx
callq 0x3e82
movq 0x8(%rsp), %rax
leaq 0x2(%rax), %rdx
movq %rbx, %rdi
movq %r12, %rsi
pushq $-0x1
popq %rcx
callq 0x3260
movq %r12, %r13
movq 0xa8(%rsp), %rdi
callq 0x3340
movl %eax, %r12d
movq %rbx, %rdi
callq 0x3458
movl %r12d, %edi
callq 0x84d3
movl %eax, 0x1c(%rsp)
movq 0x20(%rsp), %rax
leaq 0x1(%rax), %rdx
movq 0x8(%rsp), %rcx
subq %rax, %rcx
movq %rcx, 0x58(%rsp)
decq %rcx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3260
leaq 0xc8(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
callq 0x32a0
movq %rbx, %rdi
callq 0x3458
testl %r12d, %r12d
jns 0x98b5
movl %r12d, 0x18(%rsp)
andq $0x0, 0x10(%rsp)
movq %rbx, %rdi
leaq 0x7c59(%rip), %rsi      # 0x1130f
leaq 0x30(%rsp), %rdx
callq 0x3e82
leaq 0x88(%rsp), %rdi
movq %r13, %rsi
callq 0x32e0
leaq 0x68(%rsp), %rdi
leaq 0xfe1c(%rip), %rsi      # 0x194f8
callq 0x32e0
leaq 0x30(%rsp), %rdi
leaq 0x88(%rsp), %rsi
leaq 0x68(%rsp), %rdx
leaq 0x10(%rsp), %rcx
callq 0x8133
leaq 0x68(%rsp), %rdi
callq 0x3458
leaq 0x88(%rsp), %rdi
callq 0x3458
cmpq $0x0, 0x10(%rsp)
je 0x9893
xorl %ebp, %ebp
xorl %r12d, %r12d
leaq -0x20(%r12), %rbx
movq 0x60(%rsp), %rax
addq %rbx, %rax
je 0x97cf
movq (%r14), %rdi
addq %rbp, %rdi
leaq 0x30(%rsp), %rsi
callq 0x6722
testb %al, %al
jne 0x97ba
movq (%r14), %rdx
addq %rbp, %rdx
movq %r15, %rdi
leaq 0xfdbc(%rip), %rsi      # 0x19518
callq 0x9c51
addq $0x20, %rbp
movq %r15, %rdi
leaq 0x30(%rsp), %rsi
callq 0x6722
movl %eax, %r13d
movq %r15, %rdi
callq 0x3458
movq %rbx, %r12
testb %r13b, %r13b
je 0x9725
movq 0x28(%rsp), %rax
movq (%rax), %rdx
subq %rbx, %rdx
addq $-0x20, %rdx
movq %r15, %rdi
leaq 0xfd7a(%rip), %rsi      # 0x19518
callq 0x9c51
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
callq 0x32a0
movq %r15, %rdi
callq 0x3458
jmp 0x97cf
movq 0x28(%rsp), %rax
movq (%rax), %rsi
subq %r12, %rsi
leaq 0x30(%rsp), %rdi
callq 0x3160
leaq 0x148(%rsp), %r12
movq %r12, %rdi
leaq 0x30(%rsp), %rsi
leaq 0xfd12(%rip), %rdx      # 0x194f8
callq 0x9c51
leaq 0xc8(%rsp), %r13
movq %r15, %rdi
movq %r12, %rsi
leaq 0xa8(%rsp), %rbx
movq %rbx, %rdx
callq 0x6703
movq %rbx, %rdi
movq %r15, %rsi
callq 0x32a0
movq %r15, %rdi
callq 0x3458
movq %r12, %rdi
callq 0x3458
leaq 0x128(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
callq 0x32e0
leaq 0x108(%rsp), %rbp
movq %rbp, %rdi
leaq 0xfcaf(%rip), %rsi      # 0x194f8
callq 0x32e0
movq %r15, %rdi
movq %r12, %rsi
movq %rbp, %rdx
leaq 0x10(%rsp), %rcx
callq 0x8133
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
callq 0x32a0
movq %r15, %rdi
callq 0x3458
movq %rbp, %rdi
callq 0x3458
movq %r12, %rdi
callq 0x3458
leaq 0xe8(%rsp), %rbp
jmp 0x9714
leaq 0x30(%rsp), %rdi
callq 0x3458
movq %r13, %rdi
movq %rbx, %rsi
callq 0x3160
movq %rbx, %rdi
callq 0x3458
movl 0x18(%rsp), %r12d
movl %r12d, %ebx
negl %ebx
cmovsl %r12d, %ebx
movq 0x50(%rsp), %r12
subl $0x1, %ebx
jb 0x98d5
movq %rbp, %rdi
movq %r13, %rsi
callq 0x3420
jmp 0x98c3
movslq 0x1c(%rsp), %rax
movq 0x58(%rsp), %rcx
leaq (%rcx,%rax), %rdx
addq $0x2, %rdx
movq %r12, %rdi
movq 0x20(%rsp), %rsi
movq %rbp, %rcx
callq 0x30e0
movq 0x8(%rsp), %rbx
incq %rbx
movq %r13, %rdi
callq 0x3458
movq %rbp, %rdi
callq 0x3458
movq %r12, %rdi
leaq 0x800b(%rip), %rsi      # 0x11924
movq %rbx, %rdx
callq 0x3430
jmp 0x95c7
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9958
jmp 0x99a1
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x3458
jmp 0x994e
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
jmp 0x99ae
movq %rax, %rbx
jmp 0x99b3
jmp 0x99a1
movq %rax, %rbx
jmp 0x99cd
jmp 0x99a1
jmp 0x99a1
jmp 0x99a6
jmp 0x99a6
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
jmp 0x9998
jmp 0x99a6
movq %rax, %rbx
jmp 0x9990
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x3458
leaq 0x128(%rsp), %rdi
callq 0x3458
jmp 0x99a9
jmp 0x99a6
movq %rax, %rbx
jmp 0x99c0
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x3458
leaq 0xa8(%rsp), %rdi
callq 0x3458
leaq 0xc8(%rsp), %rdi
callq 0x3458
leaq 0xe8(%rsp), %rdi
callq 0x3458
movq %rbx, %rdi
callq 0x33d0