// File: rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::branch(unsigned int, unsigned int, unsigned int, unsigned int)
void CompilerGLSL::branch(uint32_t from, uint32_t cond, uint32_t true_block, uint32_t false_block)
{
	// If we branch directly to a selection merge target, we don't really need a code path.
	bool true_sub = !is_conditional(true_block);
	bool false_sub = !is_conditional(false_block);

	if (true_sub)
	{
		emit_block_hints(get<SPIRBlock>(from));
		statement("if (", to_expression(cond), ")");
		begin_scope();
		branch(from, true_block);
		end_scope();

		if (false_sub || is_continue(false_block) || is_break(false_block))
		{
			statement("else");
			begin_scope();
			branch(from, false_block);
			end_scope();
		}
		else if (flush_phi_required(from, false_block))
		{
			statement("else");
			begin_scope();
			flush_phi(from, false_block);
			end_scope();
		}
	}
	else if (false_sub && !true_sub)
	{
		// Only need false path, use negative conditional.
		emit_block_hints(get<SPIRBlock>(from));
		statement("if (!", to_enclosed_expression(cond), ")");
		begin_scope();
		branch(from, false_block);
		end_scope();

		if (is_continue(true_block) || is_break(true_block))
		{
			statement("else");
			begin_scope();
			branch(from, true_block);
			end_scope();
		}
		else if (flush_phi_required(from, true_block))
		{
			statement("else");
			begin_scope();
			flush_phi(from, true_block);
			end_scope();
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movl %r8d, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x78(%rbp)
movl -0x14(%rbp), %esi
callq 0xa84a0
movq -0x78(%rbp), %rdi
xorb $-0x1, %al
andb $0x1, %al
movb %al, -0x19(%rbp)
movl -0x18(%rbp), %esi
callq 0xa84a0
xorb $-0x1, %al
andb $0x1, %al
movb %al, -0x1a(%rbp)
testb $0x1, -0x19(%rbp)
je 0x99edc
movq -0x78(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x87d0
movq -0x78(%rbp), %rdi
movq %rax, %rsi
movq (%rdi), %rax
movq 0x158(%rax), %rax
callq *%rax
movq -0x78(%rbp), %rsi
movl -0x10(%rbp), %edx
leaq -0x40(%rbp), %rdi
movq %rdi, -0x80(%rbp)
callq 0x71b50
movq -0x78(%rbp), %rdi
movq -0x80(%rbp), %rdx
leaq 0xab101(%rip), %rsi     # 0x144ee3
leaq 0xab110(%rip), %rcx     # 0x144ef9
callq 0xa84e0
jmp 0x99df0
leaq -0x40(%rbp), %rdi
callq 0x7708
movq -0x78(%rbp), %rdi
callq 0x5c200
movq -0x78(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x14(%rbp), %edx
callq 0x99b90
movq -0x78(%rbp), %rdi
callq 0x876c0
testb $0x1, -0x1a(%rbp)
jne 0x99e42
movq -0x78(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x2fdb0
testb $0x1, %al
jne 0x99e42
movq -0x78(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0xa82f0
testb $0x1, %al
jne 0x99e42
jmp 0x99e8f
movq -0x78(%rbp), %rdi
leaq 0xa6eba(%rip), %rsi     # 0x140d07
callq 0xa8610
movq -0x78(%rbp), %rdi
callq 0x5c200
movq -0x78(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x18(%rbp), %edx
callq 0x99b90
movq -0x78(%rbp), %rdi
callq 0x876c0
jmp 0x99ed7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x7708
jmp 0x9a031
movq -0x78(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x18(%rbp), %edx
callq 0x996c0
testb $0x1, %al
jne 0x99ea4
jmp 0x99ed5
movq -0x78(%rbp), %rdi
leaq 0xa6e58(%rip), %rsi     # 0x140d07
callq 0xa8610
movq -0x78(%rbp), %rdi
callq 0x5c200
movq -0x78(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x18(%rbp), %edx
callq 0x99760
movq -0x78(%rbp), %rdi
callq 0x876c0
jmp 0x99ed7
jmp 0x9a028
testb $0x1, -0x1a(%rbp)
je 0x9a026
testb $0x1, -0x19(%rbp)
jne 0x9a026
movq -0x78(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x87d0
movq -0x78(%rbp), %rdi
movq %rax, %rsi
movq (%rdi), %rax
movq 0x158(%rax), %rax
callq *%rax
movq -0x78(%rbp), %rsi
movl -0x10(%rbp), %edx
leaq -0x70(%rbp), %rdi
movq %rdi, -0x88(%rbp)
callq 0x72630
movq -0x78(%rbp), %rdi
movq -0x88(%rbp), %rdx
leaq 0xaafb0(%rip), %rsi     # 0x144ee8
leaq 0xaafba(%rip), %rcx     # 0x144ef9
callq 0xa8730
jmp 0x99f46
leaq -0x70(%rbp), %rdi
callq 0x7708
movq -0x78(%rbp), %rdi
callq 0x5c200
movq -0x78(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x18(%rbp), %edx
callq 0x99b90
movq -0x78(%rbp), %rdi
callq 0x876c0
movq -0x78(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x2fdb0
testb $0x1, %al
jne 0x99f92
movq -0x78(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0xa82f0
testb $0x1, %al
jne 0x99f92
jmp 0x99fdc
movq -0x78(%rbp), %rdi
leaq 0xa6d6a(%rip), %rsi     # 0x140d07
callq 0xa8610
movq -0x78(%rbp), %rdi
callq 0x5c200
movq -0x78(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x14(%rbp), %edx
callq 0x99b90
movq -0x78(%rbp), %rdi
callq 0x876c0
jmp 0x9a024
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x7708
jmp 0x9a031
movq -0x78(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x14(%rbp), %edx
callq 0x996c0
testb $0x1, %al
jne 0x99ff1
jmp 0x9a022
movq -0x78(%rbp), %rdi
leaq 0xa6d0b(%rip), %rsi     # 0x140d07
callq 0xa8610
movq -0x78(%rbp), %rdi
callq 0x5c200
movq -0x78(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x14(%rbp), %edx
callq 0x99760
movq -0x78(%rbp), %rdi
callq 0x876c0
jmp 0x9a024
jmp 0x9a026
jmp 0x9a028
addq $0x90, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x7640
nopw (%rax,%rax)