// File: Laakeri[P]maxpre/src/preprocessor.cpp
// Function: maxPreprocessor::Preprocessor::doPreprocess(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int, int, bool, bool)
int Preprocessor::doPreprocess(const string& techniques, int l, int r, bool debug, bool topLevel) {
	int found = 0;
	if (l == r) {
		char tc = techniques[l];
		if (tc == 'b') {
			while (int f = doBCE()) {
				found += f;
			}
			if (debug) doBCE2();
		}
		else if (tc == 'u') {
			while (int f = doUP()) {
				found += f;
			}
			if (debug) doUP2();
		}
		else if (tc == 'v') {
			while (int f = doBVE()) {
				found += f;
			}
			if (debug) doBVE2();
		}
		else if (tc == 's') {
			while (int f = doSE()) {
				found += f;
			}
			if (debug) doSE2();
		}
		else if (tc == 'r') {
			while (int f = doSSR()) {
				found += f;
			}
			if (debug) doSSR2();
		}
		else if (tc == 'l') {
			while (int f = doSLE()) {
				found += f;
			}
			if (debug) doSLE2();
		}
		else if (tc == 'c') {
			while (int f = doBCR()) {
				found += f;
			}
			if (debug) doBCR2();
		}
		else if (tc == 'i') {
			while (int f = doSIE()) {
				found += f;
			}
			if (debug) doSIE2();
		}
		else if (tc == 'e') {
			while (int f = doBIG(false)) {
				found += f;
			}
			if (debug) doBIG2(false);
		}
		else if (tc == 'a') {
			while (int f = doBVA()) {
				found += f;
			}
			if (debug) doBVA2();
		}
		else if (tc == 'g') {
			while (int f = doGSLE()) {
				found += f;
			}
			if (debug) doGSLE2();
		}
		else if (tc == 'p') {
			while (int f = doFLP()) {
				found += f;
			}
			// FLP already checks every label
		}
		else if (tc == 'h') {
			while (int f = doBIG(true)) {
				found += f;
			}
			if (debug) doBIG2(true);
		}
		else if (tc == 't') {
			found += doLS();
		}
		else {
			abort();
		}
		pi.tl.shrink(logLevel > 0);
	}
	else {
		int lp = l;
		int br = 0;
		for (int i = l; i <= r; i++) {
			if (techniques[i] == '[') {
				br++;
			}
			else if(techniques[i] == ']') {
				br--;
				if (br == 0) {
					while (int f = doPreprocess(techniques, lp + 1, i - 1, debug, false)) {
						found += f;
					}
					if (topLevel) {
						for (int j = lp + 1; j <= i - 1; j++) {
							if (techniques[j] != ']' && techniques[j] != '[' && (techniques[j] < '0' || techniques[j] > '9')) {
								bool neverAgain = true;
								for (int jj = i + 1; jj <= r; jj++) {
									if (techniques[jj] == techniques[j]) {
										neverAgain = false;
									}
								}
								if (neverAgain) {
									rLog.neverAgain(techniques[j]);
								}
							}
						}
					}
					lp = i + 1;
				}
			}
			else {
				if (br == 0) {
					assert(lp == i);
					found += doPreprocess(techniques, i, i, debug, false);
					if (topLevel) {
						bool neverAgain = true;
						for (int j = i + 1; j <= r; j++) {
							if (techniques[j] == techniques[i]) {
								neverAgain = false;
							}
						}
						if (neverAgain) {
							rLog.neverAgain(techniques[i]);
						}
					}
					lp = i + 1;
				}
			}
		}
		assert(br == 0);
	}
	return found;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movl %r8d, -0x9c(%rbp)
movl %ecx, %eax
movl -0x9c(%rbp), %ecx
movl %eax, -0x98(%rbp)
movl %edx, %eax
movl -0x98(%rbp), %edx
movl %eax, -0x94(%rbp)
movq %rsi, %rax
movl -0x94(%rbp), %esi
movq %rax, -0x90(%rbp)
movq %rdi, %r8
movq -0x90(%rbp), %rdi
movb %r9b, %al
movq %r8, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
andb $0x1, %cl
movb %cl, -0x19(%rbp)
andb $0x1, %al
movb %al, -0x1a(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x88(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x18(%rbp), %eax
jne 0x2ed78
movq -0x10(%rbp), %rdi
movslq -0x14(%rbp), %rsi
callq 0x4420
movb (%rax), %al
movb %al, -0x21(%rbp)
movsbl -0x21(%rbp), %eax
cmpl $0x62, %eax
jne 0x2ea06
jmp 0x2e9cf
movq -0x88(%rbp), %rdi
callq 0x1e790
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x2e9ef
movl -0x28(%rbp), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x2e9cf
testb $0x1, -0x19(%rbp)
je 0x2ea01
movq -0x88(%rbp), %rdi
callq 0x1ecb0
jmp 0x2ed50
movsbl -0x21(%rbp), %eax
cmpl $0x75, %eax
jne 0x2ea48
jmp 0x2ea11
movq -0x88(%rbp), %rdi
callq 0x12e90
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x2ea31
movl -0x2c(%rbp), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x2ea11
testb $0x1, -0x19(%rbp)
je 0x2ea43
movq -0x88(%rbp), %rdi
callq 0x130f0
jmp 0x2ed4e
movsbl -0x21(%rbp), %eax
cmpl $0x76, %eax
jne 0x2ea8a
jmp 0x2ea53
movq -0x88(%rbp), %rdi
callq 0x1b490
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0x2ea73
movl -0x30(%rbp), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x2ea53
testb $0x1, -0x19(%rbp)
je 0x2ea85
movq -0x88(%rbp), %rdi
callq 0x1bb00
jmp 0x2ed4c
movsbl -0x21(%rbp), %eax
cmpl $0x73, %eax
jne 0x2eacc
jmp 0x2ea95
movq -0x88(%rbp), %rdi
callq 0x153e0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x2eab5
movl -0x34(%rbp), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x2ea95
testb $0x1, -0x19(%rbp)
je 0x2eac7
movq -0x88(%rbp), %rdi
callq 0x15930
jmp 0x2ed4a
movsbl -0x21(%rbp), %eax
cmpl $0x72, %eax
jne 0x2eb0e
jmp 0x2ead7
movq -0x88(%rbp), %rdi
callq 0x1de70
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
je 0x2eaf7
movl -0x38(%rbp), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x2ead7
testb $0x1, -0x19(%rbp)
je 0x2eb09
movq -0x88(%rbp), %rdi
callq 0x1e2b0
jmp 0x2ed48
movsbl -0x21(%rbp), %eax
cmpl $0x6c, %eax
jne 0x2eb50
jmp 0x2eb19
movq -0x88(%rbp), %rdi
callq 0x1f430
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x2eb39
movl -0x3c(%rbp), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x2eb19
testb $0x1, -0x19(%rbp)
je 0x2eb4b
movq -0x88(%rbp), %rdi
callq 0x1fb50
jmp 0x2ed46
movsbl -0x21(%rbp), %eax
cmpl $0x63, %eax
jne 0x2eb92
jmp 0x2eb5b
movq -0x88(%rbp), %rdi
callq 0x20990
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
je 0x2eb7b
movl -0x40(%rbp), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x2eb5b
testb $0x1, -0x19(%rbp)
je 0x2eb8d
movq -0x88(%rbp), %rdi
callq 0x21340
jmp 0x2ed44
movsbl -0x21(%rbp), %eax
cmpl $0x69, %eax
jne 0x2ebd4
jmp 0x2eb9d
movq -0x88(%rbp), %rdi
callq 0x22800
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0x2ebbd
movl -0x44(%rbp), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x2eb9d
testb $0x1, -0x19(%rbp)
je 0x2ebcf
movq -0x88(%rbp), %rdi
callq 0x229b0
jmp 0x2ed42
movsbl -0x21(%rbp), %eax
cmpl $0x65, %eax
jne 0x2ec1a
jmp 0x2ebdf
movq -0x88(%rbp), %rdi
xorl %esi, %esi
callq 0x26c60
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x48(%rbp)
je 0x2ec01
movl -0x48(%rbp), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x2ebdf
testb $0x1, -0x19(%rbp)
je 0x2ec15
movq -0x88(%rbp), %rdi
xorl %esi, %esi
callq 0x26fe0
jmp 0x2ed40
movsbl -0x21(%rbp), %eax
cmpl $0x61, %eax
jne 0x2ec5c
jmp 0x2ec25
movq -0x88(%rbp), %rdi
callq 0x29760
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
je 0x2ec45
movl -0x4c(%rbp), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x2ec25
testb $0x1, -0x19(%rbp)
je 0x2ec57
movq -0x88(%rbp), %rdi
callq 0x29d10
jmp 0x2ed3e
movsbl -0x21(%rbp), %eax
cmpl $0x67, %eax
jne 0x2ec9e
jmp 0x2ec67
movq -0x88(%rbp), %rdi
callq 0x2b3b0
movl %eax, -0x50(%rbp)
cmpl $0x0, -0x50(%rbp)
je 0x2ec87
movl -0x50(%rbp), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x2ec67
testb $0x1, -0x19(%rbp)
je 0x2ec99
movq -0x88(%rbp), %rdi
callq 0x2bb90
jmp 0x2ed3c
movsbl -0x21(%rbp), %eax
cmpl $0x70, %eax
jne 0x2eccb
jmp 0x2eca9
movq -0x88(%rbp), %rdi
callq 0x2c860
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x54(%rbp)
je 0x2ecc9
movl -0x54(%rbp), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x2eca9
jmp 0x2ed3a
movsbl -0x21(%rbp), %eax
cmpl $0x68, %eax
jne 0x2ed14
jmp 0x2ecd6
movq -0x88(%rbp), %rdi
movl $0x1, %esi
callq 0x26c60
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x58(%rbp)
je 0x2ecfb
movl -0x58(%rbp), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x2ecd6
testb $0x1, -0x19(%rbp)
je 0x2ed12
movq -0x88(%rbp), %rdi
movl $0x1, %esi
callq 0x26fe0
jmp 0x2ed38
movsbl -0x21(%rbp), %eax
cmpl $0x74, %eax
jne 0x2ed31
movq -0x88(%rbp), %rdi
callq 0x2d530
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x2ed36
callq 0x41f0
jmp 0x2ed38
jmp 0x2ed3a
jmp 0x2ed3c
jmp 0x2ed3e
jmp 0x2ed40
jmp 0x2ed42
jmp 0x2ed44
jmp 0x2ed46
jmp 0x2ed48
jmp 0x2ed4a
jmp 0x2ed4c
jmp 0x2ed4e
jmp 0x2ed50
movq -0x88(%rbp), %rax
movq %rax, %rdi
addq $0x68, %rdi
cmpl $0x0, 0x2e8(%rax)
setg %al
movzbl %al, %esi
andl $0x1, %esi
callq 0x72290
jmp 0x2f095
movl -0x14(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl $0x0, -0x60(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
cmpl -0x18(%rbp), %eax
jg 0x2f06c
movq -0x10(%rbp), %rdi
movslq -0x64(%rbp), %rsi
callq 0x4420
movsbl (%rax), %eax
cmpl $0x5b, %eax
jne 0x2edba
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x2f05c
movq -0x10(%rbp), %rdi
movslq -0x64(%rbp), %rsi
callq 0x4420
movsbl (%rax), %eax
cmpl $0x5d, %eax
jne 0x2ef59
movl -0x60(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x60(%rbp)
cmpl $0x0, -0x60(%rbp)
jne 0x2ef54
jmp 0x2ede8
movq -0x88(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x5c(%rbp), %edx
addl $0x1, %edx
movl -0x64(%rbp), %ecx
subl $0x1, %ecx
movb -0x19(%rbp), %al
xorl %r9d, %r9d
andb $0x1, %al
movzbl %al, %r8d
callq 0x2e930
movl %eax, -0x68(%rbp)
cmpl $0x0, -0x68(%rbp)
je 0x2ee24
movl -0x68(%rbp), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x2ede8
testb $0x1, -0x1a(%rbp)
je 0x2ef4b
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movl -0x64(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jg 0x2ef49
movq -0x10(%rbp), %rdi
movslq -0x6c(%rbp), %rsi
callq 0x4420
movsbl (%rax), %eax
cmpl $0x5d, %eax
je 0x2ef39
movq -0x10(%rbp), %rdi
movslq -0x6c(%rbp), %rsi
callq 0x4420
movsbl (%rax), %eax
cmpl $0x5b, %eax
je 0x2ef39
movq -0x10(%rbp), %rdi
movslq -0x6c(%rbp), %rsi
callq 0x4420
movsbl (%rax), %eax
cmpl $0x30, %eax
jl 0x2eea8
movq -0x10(%rbp), %rdi
movslq -0x6c(%rbp), %rsi
callq 0x4420
movsbl (%rax), %eax
cmpl $0x39, %eax
jle 0x2ef39
movb $0x1, -0x6d(%rbp)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl -0x18(%rbp), %eax
jg 0x2ef01
movq -0x10(%rbp), %rdi
movslq -0x74(%rbp), %rsi
callq 0x4420
movsbl (%rax), %eax
movl %eax, -0xa0(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x6c(%rbp), %rsi
callq 0x4420
movq %rax, %rcx
movl -0xa0(%rbp), %eax
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x2eef4
movb $0x0, -0x6d(%rbp)
jmp 0x2eef6
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x2eeb5
testb $0x1, -0x6d(%rbp)
je 0x2ef37
movq -0x88(%rbp), %rax
addq $0x218, %rax            # imm = 0x218
movq %rax, -0xa8(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x6c(%rbp), %rsi
callq 0x4420
movq -0xa8(%rbp), %rdi
movsbl (%rax), %esi
callq 0x629f0
jmp 0x2ef39
jmp 0x2ef3b
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x2ee37
jmp 0x2ef4b
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x2f05a
cmpl $0x0, -0x60(%rbp)
jne 0x2f058
movl -0x5c(%rbp), %eax
cmpl -0x64(%rbp), %eax
jne 0x2ef6d
jmp 0x2ef8c
leaq 0x5816f(%rip), %rdi     # 0x870e3
leaq 0x5734c(%rip), %rsi     # 0x862c7
movl $0x291, %edx            # imm = 0x291
leaq 0x58164(%rip), %rcx     # 0x870eb
callq 0x4260
movq -0x88(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x64(%rbp), %edx
movl -0x64(%rbp), %ecx
movb -0x19(%rbp), %al
xorl %r9d, %r9d
andb $0x1, %al
movzbl %al, %r8d
callq 0x2e930
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
testb $0x1, -0x1a(%rbp)
je 0x2f04f
movb $0x1, -0x75(%rbp)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jg 0x2f017
movq -0x10(%rbp), %rdi
movslq -0x7c(%rbp), %rsi
callq 0x4420
movsbl (%rax), %eax
movl %eax, -0xac(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x64(%rbp), %rsi
callq 0x4420
movq %rax, %rcx
movl -0xac(%rbp), %eax
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x2f00a
movb $0x0, -0x75(%rbp)
jmp 0x2f00c
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x2efcb
testb $0x1, -0x75(%rbp)
je 0x2f04d
movq -0x88(%rbp), %rax
addq $0x218, %rax            # imm = 0x218
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x64(%rbp), %rsi
callq 0x4420
movq -0xb8(%rbp), %rdi
movsbl (%rax), %esi
callq 0x629f0
jmp 0x2f04f
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x2f05a
jmp 0x2f05c
jmp 0x2f05e
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x2ed8b
cmpl $0x0, -0x60(%rbp)
jne 0x2f074
jmp 0x2f093
leaq 0x580c6(%rip), %rdi     # 0x87141
leaq 0x57245(%rip), %rsi     # 0x862c7
movl $0x2a2, %edx            # imm = 0x2A2
leaq 0x5805d(%rip), %rcx     # 0x870eb
callq 0x4260
jmp 0x2f095
movl -0x20(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)