// File: /workspace/github_cpp_makefile_star2_O2/rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::emit_mix_op(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int)
void CompilerGLSL::emit_mix_op(uint32_t result_type, uint32_t id, uint32_t left, uint32_t right, uint32_t lerp)
{
	auto &lerptype = expression_type(lerp);
	auto &restype = get<SPIRType>(result_type);

	string mix_op;
	bool has_boolean_mix = backend.boolean_mix_support &&
	                       ((options.es && options.version >= 310) || (!options.es && options.version >= 450));
	bool trivial_mix = to_trivial_mix_op(restype, mix_op, left, right, lerp);

	// Cannot use boolean mix when the lerp argument is just one boolean,
	// fall back to regular trinary statements.
	if (lerptype.vecsize == 1)
		has_boolean_mix = false;

	// If we can reduce the mix to a simple cast, do so.
	// This helps for cases like int(bool), uint(bool) which is implemented with
	// OpSelect bool 1 0.
	if (trivial_mix)
	{
		emit_unary_func_op(result_type, id, lerp, mix_op.c_str());
	}
	else if (!has_boolean_mix && lerptype.basetype == SPIRType::Boolean)
	{
		// Boolean mix not supported on desktop without extension.
		// Was added in OpenGL 4.5 with ES 3.1 compat.
		//
		// Could use GL_EXT_shader_integer_mix on desktop at least,
		// but Apple doesn't support it. :(
		// Just implement it as ternary expressions.
		auto expr = to_ternary_expression(get<SPIRType>(result_type), lerp, right, left);
		emit_op(result_type, id, expr, should_forward(left) && should_forward(right) && should_forward(lerp));
		inherit_expression_dependencies(id, left);
		inherit_expression_dependencies(id, right);
		inherit_expression_dependencies(id, lerp);
	}
	else
		emit_trinary_func_op(result_type, id, left, right, lerp, "mix");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r9d, %ebx
movl %r8d, 0x10(%rsp)
movl %ecx, %r12d
movl %edx, 0x14(%rsp)
movl %esi, %r13d
movq %rdi, %r14
movl %r9d, %esi
callq 0x104b0
movq %rax, %rbp
movq %r14, %rdi
movl %r13d, %esi
callq 0x90a4
leaq 0x28(%rsp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
cmpb $0x1, 0x62a(%r14)
jne 0x30a76
movb 0x43c(%r14), %cl
movl 0x438(%r14), %edx
cmpl $0x136, %edx            # imm = 0x136
setae %sil
movb $0x1, %r15b
testb %sil, %cl
jne 0x30a79
cmpl $0x1c2, %edx            # imm = 0x1C2
setae %dl
notb %cl
andb %dl, %cl
movl %ecx, %r15d
jmp 0x30a79
xorl %r15d, %r15d
leaq 0x18(%rsp), %rdx
movq %r14, %rdi
movq %rax, %rsi
movl %r12d, %ecx
movl 0x10(%rsp), %r8d
movl %ebx, %r9d
callq 0x2c3dc
testb %al, %al
je 0x30ab3
movq 0x18(%rsp), %r8
movq %r14, %rdi
movl %r13d, %esi
movl 0x14(%rsp), %edx
movl %ebx, %ecx
callq 0x2f9ee
jmp 0x30b8c
cmpl $0x1, 0x14(%rbp)
setne %al
testb %r15b, %al
jne 0x30b19
cmpl $0x2, 0xc(%rbp)
jne 0x30b19
movq %r14, %rdi
movl %r13d, %esi
callq 0x90a4
leaq 0x38(%rsp), %rdi
movq %r14, %rsi
movq %rax, %rdx
movl %ebx, %ecx
movl 0x10(%rsp), %r8d
movl %r12d, %r9d
callq 0x2c550
movq %r14, %rdi
movl %r12d, %esi
callq 0x2f360
movl 0x14(%rsp), %ebp
testb %al, %al
je 0x30b40
movq %r14, %rdi
movl 0x10(%rsp), %esi
callq 0x2f360
testb %al, %al
je 0x30b40
movq %r14, %rdi
movl %ebx, %esi
callq 0x2f360
jmp 0x30b42
leaq 0x61a2a(%rip), %rax     # 0x9254a
movq %rax, (%rsp)
movq %r14, %rdi
movl %r13d, %esi
movl 0x14(%rsp), %edx
movl %r12d, %ecx
movl 0x10(%rsp), %r8d
movl %ebx, %r9d
callq 0x2fe8e
jmp 0x30b8c
xorl %eax, %eax
movzbl %al, %r8d
leaq 0x38(%rsp), %rcx
movq %r14, %rdi
movl %r13d, %esi
movl %ebp, %edx
xorl %r9d, %r9d
callq 0x2f196
movq %r14, %rdi
movl %ebp, %esi
movl %r12d, %edx
callq 0x13128
movq %r14, %rdi
movl %ebp, %esi
movl 0x10(%rsp), %edx
callq 0x13128
movq %r14, %rdi
movl %ebp, %esi
movl %ebx, %edx
callq 0x13128
leaq 0x38(%rsp), %rdi
callq 0x6548
leaq 0x18(%rsp), %rdi
callq 0x6548
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x30bb6
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x6548
jmp 0x30bb9
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x6548
movq %rbx, %rdi
callq 0x64b0
nop