// File: /workspace/github_cpp_makefile_star2_O3/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 %rbx
movq 0x4230(%rdi), %rsi
testq %rsi, %rsi
js 0x5d7c
movq 0x20(%rdi), %rax
leaq 0x3e30(%rdi), %rcx
leaq -0x2(%rax), %rdx
movq %rsi, %r8
notq %r8
addq %rax, %r8
testq %rsi, %rsi
je 0x5c55
movq %rsi, %r9
shlq $0x4, %r9
movq -0x8(%r9,%rcx), %r9
leaq 0x2(%r9), %r10
cmpq %r10, %r8
setae %r11b
testq %r9, %r9
setne %r10b
cmpq $0x20, %rsi
jb 0x5c60
jmp 0x5d89
cmpq $0x2, %r8
setae %r11b
xorl %r10d, %r10d
movq %rsi, %r8
shlq $0x4, %r8
leaq (%rcx,%r8), %r9
movl (%rcx,%r8), %ebx
cmpl $0x1, %ebx
je 0x5cd0
testl %ebx, %ebx
jne 0x5cf5
testb %r11b, %r11b
je 0x5d01
movl $0x1, (%r9)
testq %rsi, %rsi
je 0x5d3b
leaq -0x1(%rsi), %r11
shlq $0x4, %r11
movq 0x8(%rcx,%r11), %r9
leaq 0x1(%r9), %r10
movq %r10, 0x8(%rcx,%r8)
cmpq $0x0, 0x28(%rdi,%rsi,8)
jle 0x5d51
cmpq $0x3, %r10
setb %r8b
testq %r9, %r9
setne %r9b
testb %r8b, %r9b
jne 0x5d63
jmp 0x5d73
testb %r10b, %r10b
je 0x5cf5
leaq -0x1(%rsi), %r10
cmpq $0x1f, %r10
jae 0x5da8
movl $0x2, (%r9)
shlq $0x4, %r10
movq 0x8(%rcx,%r10), %r9
jmp 0x5d24
movl $0x0, (%r9)
decq %rsi
jmp 0x5d66
leaq -0x1(%rsi), %r11
testb %r10b, %r10b
je 0x5d69
cmpq $0x1f, %r11
jae 0x5da8
movl $0x2, (%r9)
shlq $0x4, %r11
movq 0x8(%rcx,%r11), %r9
decq %r9
movq %r9, 0x8(%rcx,%r8)
cmpq $0x0, 0x28(%rdi,%rsi,8)
jle 0x5d73
cmpq %rdx, %rsi
jne 0x5d63
jmp 0x5d80
movq $0x1, 0x3e38(%rdi)
cmpq $0x0, 0x28(%rdi)
jg 0x5d63
xorl %esi, %esi
jmp 0x5d73
cmpl $0x1, (%rcx,%r11)
jne 0x5d73
testq %r9, %r9
je 0x5d73
cmpq $0x3, %r10
jae 0x5d73
incq %rsi
movq %rsi, %r11
movq %r11, 0x4230(%rdi)
movq %r11, %rsi
testq %rsi, %rsi
jns 0x5c1e
xorl %eax, %eax
popq %rbx
retq
callq 0x5f44
movb $0x1, %al
jmp 0x5d7e
leaq 0x36ba(%rip), %rdi      # 0x944a
leaq 0x34c2(%rip), %rsi      # 0x9259
leaq 0x36dd(%rip), %rcx      # 0x947b
movl $0x170, %edx            # imm = 0x170
callq 0x2120
leaq 0x374e(%rip), %rdi      # 0x94fd
leaq 0x34a3(%rip), %rsi      # 0x9259
leaq 0x3770(%rip), %rcx      # 0x952d
movl $0x1b7, %edx            # imm = 0x1B7
callq 0x2120
nop