// File: /workspace/github_cpp_makefile_star2_O2/rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::branch(unsigned int, unsigned int)
void CompilerGLSL::branch(uint32_t from, uint32_t to)
{
	flush_phi(from, to);
	flush_control_dependent_expressions(from);
	flush_all_active_variables();

	// This is only a continue if we branch to our loop dominator.
	if ((ir.block_meta[to] & ParsedIR::BLOCK_META_LOOP_HEADER_BIT) != 0 && get<SPIRBlock>(from).loop_dominator == to)
	{
		// This can happen if we had a complex continue block which was emitted.
		// Once the continue block tries to branch to the loop header, just emit continue;
		// and end the chain here.
		statement("continue;");
	}
	else if (is_break(to))
	{
		// Very dirty workaround.
		// Switch constructs are able to break, but they cannot break out of a loop at the same time.
		// Only sensible solution is to make a ladder variable, which we declare at the top of the switch block,
		// write to the ladder here, and defer the break.
		// The loop we're breaking out of must dominate the switch block, or there is no ladder breaking case.
		if (current_emitting_switch && is_loop_break(to) && current_emitting_switch->loop_dominator != -1u &&
		    get<SPIRBlock>(current_emitting_switch->loop_dominator).merge_block == to)
		{
			if (!current_emitting_switch->need_ladder_break)
			{
				force_recompile = true;
				current_emitting_switch->need_ladder_break = true;
			}

			statement("_", current_emitting_switch->self, "_ladder_break = true;");
		}
		statement("break;");
	}
	else if (is_continue(to) || (from == to))
	{
		// For from == to case can happen for a do-while loop which branches into itself.
		// We don't mark these cases as continue blocks, but the only possible way to branch into
		// ourselves is through means of continue blocks.
		branch_to_continue(from, to);
	}
	else if (!is_conditional(to))
		emit_block_chain(get<SPIRBlock>(to));

	// It is important that we check for break before continue.
	// A block might serve two purposes, a break block for the inner scope, and
	// a continue block in the outer scope.
	// Inner scope always takes precedence.
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %rbx
callq 0x3f670
movq %rbx, %rdi
movl %r14d, %esi
callq 0x10956
movq %rbx, %rdi
callq 0x109b8
movl %ebp, %r15d
movq 0x80(%rbx), %rax
movb (%rax,%r15), %al
testb $0x1, %al
je 0x3f94c
movq %rbx, %rdi
movl %r14d, %esi
callq 0x6bf0
cmpl %ebp, 0xb4(%rax)
jne 0x3f941
leaq 0x56090(%rip), %rsi     # 0x959bf
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x46dde
movq 0x80(%rbx), %rax
movb (%rax,%r15), %al
testb $0x14, %al
je 0x3f9cf
movq 0x418(%rbx), %rcx
testq %rcx, %rcx
sete %dl
testb $0x4, %al
sete %al
orb %dl, %al
jne 0x3f9b6
movl 0xb4(%rcx), %esi
cmpl $-0x1, %esi
je 0x3f9b6
movq %rbx, %rdi
callq 0x6bf0
cmpl %ebp, 0x1c(%rax)
jne 0x3f9b6
movq 0x418(%rbx), %rdx
cmpb $0x0, 0xb2(%rdx)
jne 0x3f99c
movb $0x1, %al
movb %al, 0x1d0(%rbx)
movb %al, 0xb2(%rdx)
addq $0x8, %rdx
leaq 0x595a0(%rip), %rsi     # 0x98f47
leaq 0x5601b(%rip), %rcx     # 0x959c9
movq %rbx, %rdi
callq 0x46e9a
leaq 0x5d2b3(%rip), %rsi     # 0x9cc70
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x4120e
cmpl %ebp, %r14d
je 0x3f9fe
movl %eax, %ecx
andb $0x2, %cl
jne 0x3f9fe
testb $0x8, %al
jne 0x3fa15
movq %rbx, %rdi
movl %ebp, %esi
callq 0x6bf0
movq %rbx, %rdi
movq %rax, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x3eae8
movq %rbx, %rdi
movl %r14d, %esi
movl %ebp, %edx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x3f790
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq