// File: /workspace/github_cpp_makefile_star2_O1/ksabry[P]bfbrute/src/ProgramIterator.h
// Function: ProgramIterator<400ul, 32ul, 12ul, 32ul>::NextBrackets()
bool NextBrackets()
	{
		while (bracketIdx >= 0)
		{
			uint_fast32_t remainingBrackets = iteratorCount - bracketIdx - 1;
			bool left_valid = bracketIdx == 0 ? remainingBrackets >= 2 : remainingBrackets >= brackets[bracketIdx - 1].depth + 2;
			bool right_valid = bracketIdx == 0 ? false : brackets[bracketIdx - 1].depth > 0;

			// EMPTY -> LEFT -> RIGHT -> EMPTY
			assert(bracketIdx >= 0 && bracketIdx < max_program_size);
			if (brackets[bracketIdx].bracket == Bracket::EMPTY)
			{
				if (left_valid)
				{
					if (!SetBracketLeft()) continue;
					bracketIdx++;
				}
				else if (right_valid)
				{
					if (!SetBracketRight()) continue;
					if (bracketIdx == iteratorCount - 2)
					{
						SetJumps();
						return true;
					}
					bracketIdx++;
				}
				else
				{
					bracketIdx--;
				}
			}
			else if (brackets[bracketIdx].bracket == Bracket::LEFT)
			{
				if (right_valid)
				{
					if (!SetBracketRight()) continue;
					if (bracketIdx == iteratorCount - 2)
					{
						SetJumps();
						return true;
					}
					bracketIdx++;
				}
				else
				{
					brackets[bracketIdx].bracket = Bracket::EMPTY;
					bracketIdx--;
				}
			}
			else
			{
				brackets[bracketIdx].bracket = Bracket::EMPTY;
				bracketIdx--;
			}
		}
		return false;
	}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq 0x4230(%rdi), %rsi
testq %rsi, %rsi
setns %bl
js 0x5df3
movq 0x20(%rdi), %rax
leaq 0x3e30(%rdi), %rcx
leaq -0x2(%rax), %rdx
movq %rsi, %r8
notq %r8
addq %rax, %r8
testq %rsi, %rsi
je 0x5ccc
movq %rsi, %r9
shlq $0x4, %r9
movq -0x8(%r9,%rcx), %r9
addq $0x2, %r9
cmpq %r9, %r8
jmp 0x5cd0
cmpq $0x2, %r8
setae %r9b
testq %rsi, %rsi
je 0x5cec
movq %rsi, %r8
shlq $0x4, %r8
cmpq $0x0, -0x8(%r8,%rcx)
setne %r11b
jmp 0x5cef
xorl %r11d, %r11d
cmpq $0x20, %rsi
jae 0x5dff
movq %rsi, %r8
shlq $0x4, %r8
leaq (%rcx,%r8), %r10
movl (%rcx,%r8), %ebp
cmpl $0x1, %ebp
je 0x5d2c
testl %ebp, %ebp
jne 0x5d37
testb %r9b, %r9b
je 0x5d43
movl $0x1, (%r10)
testq %rsi, %rsi
je 0x5d7d
movq -0x8(%r8,%rcx), %r9
incq %r9
jmp 0x5d83
testb %r11b, %r11b
je 0x5d37
leaq -0x1(%rsi), %r9
jmp 0x5d4c
movl $0x0, (%r10)
decq %rsi
jmp 0x5db5
leaq -0x1(%rsi), %r9
testb %r11b, %r11b
je 0x5db8
cmpq $0x1f, %r9
jae 0x5e1e
movl $0x2, (%r10)
shlq $0x4, %r9
movq 0x8(%rcx,%r9), %r9
decq %r9
movq %r9, 0x8(%rcx,%r8)
cmpq $0x0, 0x28(%rdi,%rsi,8)
jle 0x5dc2
cmpq %rdx, %rsi
jne 0x5db2
jmp 0x5dee
movl $0x1, %r9d
movq %r9, 0x8(%rcx,%r8)
cmpq $0x0, 0x28(%rdi,%rsi,8)
jle 0x5dd0
cmpq $0x3, %r9
setb %r10b
testq %rsi, %rsi
je 0x5dad
cmpq $0x2, %r9
ja 0x5dad
cmpq $0x0, -0x8(%r8,%rcx)
setne %r10b
testb %r10b, %r10b
je 0x5dc2
incq %rsi
movq %rsi, %r9
movq %r9, 0x4230(%rdi)
movq %r9, %rsi
testq %rsi, %rsi
setns %bl
jns 0x5ca9
jmp 0x5df3
testq %rsi, %rsi
je 0x5dc2
cmpl $0x1, -0x10(%r8,%rcx)
sete %r11b
cmpq $0x3, %r9
setb %r10b
andb %r11b, %r10b
jne 0x5da3
jmp 0x5dad
callq 0x5fae
andb $0x1, %bl
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x3624(%rip), %rdi      # 0x942a
leaq 0x342c(%rip), %rsi      # 0x9239
leaq 0x3647(%rip), %rcx      # 0x945b
movl $0x170, %edx            # imm = 0x170
callq 0x2120
leaq 0x36b8(%rip), %rdi      # 0x94dd
leaq 0x340d(%rip), %rsi      # 0x9239
leaq 0x36da(%rip), %rcx      # 0x950d
movl $0x1b7, %edx            # imm = 0x1B7
callq 0x2120
nop