// File: MarkCBell[P]twister/./twister/kernel/parsing.cpp
// Function: tokenise_command(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<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>>>> const&)
void tokenise_command(std::string &command, const std::set<std::string> &valid_names)
{
	std::string new_command = "";
	std::string new_subcommand = "";
	size_t marker = 0;
	
	do
	{
		if (command.substr(marker,1) == drill)
		{
			new_command += separator + drill;
			marker++;
		}
		if (command.substr(marker,1) == "(")
		{
			new_command += separator + "(";
			marker++;
		}
		if (command.substr(marker,1) == ")")
		{
			int power = atoi((char *) command.substr(marker).c_str());
			int power_length = digit_length(power);
			
			new_command += separator + command.substr(marker, 2+power_length);
			marker += 2+power_length;
		}
		
		size_t old_marker = marker;
		new_subcommand = find_next_substring(command, separator, marker);
		
		for (int j = new_subcommand.size(); j >= 0; j--)
		{
			if (j > 0)
			{
				if (valid_names.find(new_subcommand.substr(0,j)) != valid_names.end())
				{
					new_command += new_subcommand.substr(0,j) + separator;
					marker = old_marker + j;
					break;
				}
			}
			else
				new_command += new_subcommand + separator;
		}
	} while (marker != 0);
	
	command = new_command;
	
	return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2c0, %rsp            # imm = 0x2C0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x290(%rbp)
callq 0x3560
movq -0x290(%rbp), %rdx
leaq 0x13de1(%rip), %rsi     # 0x272f2
leaq -0x30(%rbp), %rdi
callq 0x4e10
jmp 0x1351c
leaq -0x31(%rbp), %rdi
callq 0x3360
leaq -0x69(%rbp), %rdi
movq %rdi, -0x298(%rbp)
callq 0x3560
movq -0x298(%rbp), %rdx
leaq 0x13daf(%rip), %rsi     # 0x272f2
leaq -0x68(%rbp), %rdi
callq 0x4e10
jmp 0x1354e
leaq -0x69(%rbp), %rdi
callq 0x3360
movq $0x0, -0x78(%rbp)
movq -0x8(%rbp), %rsi
movq -0x78(%rbp), %rdx
leaq -0x98(%rbp), %rdi
movl $0x1, %ecx
callq 0x3320
jmp 0x1357a
leaq -0x98(%rbp), %rdi
leaq 0x22060(%rip), %rsi     # 0x355e8
callq 0x9a20
movb %al, -0x299(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x35f8
movb -0x299(%rbp), %al
testb $0x1, %al
jne 0x135ae
jmp 0x13658
leaq 0x22013(%rip), %rsi     # 0x355c8
leaq 0x2202c(%rip), %rdx     # 0x355e8
leaq -0xb8(%rbp), %rdi
callq 0x14d90
jmp 0x135ca
leaq -0x30(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x33e0
jmp 0x135dc
leaq -0xb8(%rbp), %rdi
callq 0x35f8
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0x13658
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x3360
jmp 0x13bb5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x69(%rbp), %rdi
callq 0x3360
jmp 0x13bac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x13ba3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x35f8
jmp 0x13ba3
movq -0x8(%rbp), %rsi
movq -0x78(%rbp), %rdx
leaq -0xd8(%rbp), %rdi
movl $0x1, %ecx
callq 0x3320
jmp 0x13673
leaq 0x13cd1(%rip), %rsi     # 0x2734b
leaq -0xd8(%rbp), %rdi
callq 0x8ca0
movb %al, -0x29a(%rbp)
jmp 0x1368e
leaq -0xd8(%rbp), %rdi
callq 0x35f8
movb -0x29a(%rbp), %al
testb $0x1, %al
jne 0x136a9
jmp 0x1372b
leaq 0x21f18(%rip), %rsi     # 0x355c8
leaq 0x13c94(%rip), %rdx     # 0x2734b
leaq -0xf8(%rbp), %rdi
callq 0x9200
jmp 0x136c5
leaq -0x30(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x33e0
jmp 0x136d7
leaq -0xf8(%rbp), %rdi
callq 0x35f8
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0x1372b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x35f8
jmp 0x13ba3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x35f8
jmp 0x13ba3
movq -0x8(%rbp), %rsi
movq -0x78(%rbp), %rdx
leaq -0x118(%rbp), %rdi
movl $0x1, %ecx
callq 0x3320
jmp 0x13746
leaq 0x141ef(%rip), %rsi     # 0x2793c
leaq -0x118(%rbp), %rdi
callq 0x8ca0
movb %al, -0x29b(%rbp)
jmp 0x13761
leaq -0x118(%rbp), %rdi
callq 0x35f8
movb -0x29b(%rbp), %al
testb $0x1, %al
jne 0x1377c
jmp 0x138b4
movq -0x8(%rbp), %rsi
movq -0x78(%rbp), %rdx
leaq -0x140(%rbp), %rdi
movq $-0x1, %rcx
callq 0x3320
jmp 0x13799
leaq -0x140(%rbp), %rdi
movq %rdi, -0x2a8(%rbp)
callq 0x3120
movq %rax, %rdi
callq 0x34a0
movq -0x2a8(%rbp), %rdi
movl %eax, -0x2a0(%rbp)
callq 0x35f8
movl -0x2a0(%rbp), %eax
movl %eax, -0x11c(%rbp)
movl -0x11c(%rbp), %edi
callq 0x12270
movl %eax, -0x144(%rbp)
movq -0x8(%rbp), %rsi
movq -0x78(%rbp), %rdx
movl -0x144(%rbp), %eax
addl $0x2, %eax
movslq %eax, %rcx
leaq -0x188(%rbp), %rdi
callq 0x3320
jmp 0x13805
leaq 0x21dbc(%rip), %rsi     # 0x355c8
leaq -0x168(%rbp), %rdi
leaq -0x188(%rbp), %rdx
callq 0x14d40
jmp 0x13821
leaq -0x30(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0x33e0
jmp 0x13833
leaq -0x168(%rbp), %rdi
callq 0x35f8
leaq -0x188(%rbp), %rdi
callq 0x35f8
movl -0x144(%rbp), %eax
addl $0x2, %eax
cltq
addq -0x78(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x138b4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x35f8
jmp 0x13ba3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x138a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x35f8
leaq -0x188(%rbp), %rdi
callq 0x35f8
jmp 0x13ba3
movq -0x78(%rbp), %rax
movq %rax, -0x190(%rbp)
movq -0x8(%rbp), %rsi
leaq -0x1d0(%rbp), %rdi
callq 0x3130
jmp 0x138d1
leaq 0x21cf0(%rip), %rsi     # 0x355c8
leaq -0x1f0(%rbp), %rdi
callq 0x3130
jmp 0x138e6
leaq -0x1b0(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
leaq -0x1f0(%rbp), %rdx
leaq -0x78(%rbp), %rcx
callq 0x11c10
jmp 0x13906
leaq -0x68(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x33c0
leaq -0x1b0(%rbp), %rdi
callq 0x35f8
leaq -0x1f0(%rbp), %rdi
callq 0x35f8
leaq -0x1d0(%rbp), %rdi
callq 0x35f8
leaq -0x68(%rbp), %rdi
callq 0x31f0
movl %eax, -0x1f4(%rbp)
cmpl $0x0, -0x1f4(%rbp)
jl 0x13b6c
cmpl $0x0, -0x1f4(%rbp)
jle 0x13b03
movq -0x10(%rbp), %rax
movq %rax, -0x2b0(%rbp)
movslq -0x1f4(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
leaq -0x220(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x3320
jmp 0x1398b
movq -0x2b0(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x14e40
movq %rax, -0x2b8(%rbp)
jmp 0x139a7
movq -0x2b8(%rbp), %rax
movq %rax, -0x200(%rbp)
movq -0x10(%rbp), %rdi
callq 0x14e70
movq %rax, -0x228(%rbp)
leaq -0x200(%rbp), %rdi
leaq -0x228(%rbp), %rsi
callq 0x14e10
movb %al, -0x2b9(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x35f8
movb -0x2b9(%rbp), %al
testb $0x1, %al
jne 0x139f9
jmp 0x13b01
movslq -0x1f4(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
leaq -0x268(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x3320
jmp 0x13a16
leaq 0x21bab(%rip), %rdx     # 0x355c8
leaq -0x248(%rbp), %rdi
leaq -0x268(%rbp), %rsi
callq 0x99d0
jmp 0x13a32
leaq -0x30(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0x33e0
jmp 0x13a44
leaq -0x248(%rbp), %rdi
callq 0x35f8
leaq -0x268(%rbp), %rdi
callq 0x35f8
movq -0x190(%rbp), %rax
movslq -0x1f4(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
jmp 0x13b6c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x13a9c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x35f8
leaq -0x1d0(%rbp), %rdi
callq 0x35f8
jmp 0x13ba3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x35f8
jmp 0x13ba3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x13af0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x248(%rbp), %rdi
callq 0x35f8
leaq -0x268(%rbp), %rdi
callq 0x35f8
jmp 0x13ba3
jmp 0x13b56
leaq 0x21abe(%rip), %rdx     # 0x355c8
leaq -0x288(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x14d90
jmp 0x13b1c
leaq -0x30(%rbp), %rdi
leaq -0x288(%rbp), %rsi
callq 0x33e0
jmp 0x13b2e
leaq -0x288(%rbp), %rdi
callq 0x35f8
jmp 0x13b56
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x288(%rbp), %rdi
callq 0x35f8
jmp 0x13ba3
jmp 0x13b58
movl -0x1f4(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1f4(%rbp)
jmp 0x13949
jmp 0x13b6e
cmpq $0x0, -0x78(%rbp)
jne 0x1355f
movq -0x8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3050
jmp 0x13b88
leaq -0x68(%rbp), %rdi
callq 0x35f8
leaq -0x30(%rbp), %rdi
callq 0x35f8
addq $0x2c0, %rsp            # imm = 0x2C0
popq %rbp
retq
leaq -0x68(%rbp), %rdi
callq 0x35f8
leaq -0x30(%rbp), %rdi
callq 0x35f8
movq -0x40(%rbp), %rdi
callq 0x3550
nop