// File: /workspace/github_cpp_makefile_star2_O1/rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::to_trivial_mix_op(spirv_cross::SPIRType const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, unsigned int, unsigned int, unsigned int)
bool CompilerGLSL::to_trivial_mix_op(const SPIRType &type, string &op, uint32_t left, uint32_t right, uint32_t lerp)
{
	auto *cleft = maybe_get<SPIRConstant>(left);
	auto *cright = maybe_get<SPIRConstant>(right);
	auto &lerptype = expression_type(lerp);

	// If our targets aren't constants, we cannot use construction.
	if (!cleft || !cright)
		return false;

	// If our targets are spec constants, we cannot use construction.
	if (cleft->specialization || cright->specialization)
		return false;

	// We can only use trivial construction if we have a scalar
	// (should be possible to do it for vectors as well, but that is overkill for now).
	if (lerptype.basetype != SPIRType::Boolean || lerptype.vecsize > 1)
		return false;

	// If our bool selects between 0 and 1, we can cast from bool instead, making our trivial constructor.
	bool ret = false;
	switch (type.basetype)
	{
	case SPIRType::Int:
	case SPIRType::UInt:
		ret = cleft->scalar() == 0 && cright->scalar() == 1;
		break;

	case SPIRType::Half:
		ret = cleft->scalar_f16() == 0.0f && cright->scalar_f16() == 1.0f;
		break;

	case SPIRType::Float:
		ret = cleft->scalar_f32() == 0.0f && cright->scalar_f32() == 1.0f;
		break;

	case SPIRType::Double:
		ret = cleft->scalar_f64() == 0.0 && cright->scalar_f64() == 1.0;
		break;

	case SPIRType::Int64:
	case SPIRType::UInt64:
		ret = cleft->scalar_u64() == 0 && cright->scalar_u64() == 1;
		break;

	default:
		break;
	}

	if (ret)
		op = type_to_glsl_constructor(type);
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r9d, %r12d
movl %r8d, %r13d
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movl %ecx, %esi
callq 0x54a30
movq %rax, %rbp
movq %r15, %rdi
movl %r13d, %esi
callq 0x54a30
movq %rax, %r13
movq %r15, %rdi
movl %r12d, %esi
callq 0x12aba
testq %rbp, %rbp
sete %cl
testq %r13, %r13
sete %dl
orb %cl, %dl
jne 0x353e7
cmpb $0x0, 0x108(%rbp)
jne 0x353e7
cmpb $0x0, 0x108(%r13)
je 0x353fc
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r12d, %r12d
cmpl $0x2, 0xc(%rax)
jne 0x353ea
cmpl $0x1, 0x14(%rax)
ja 0x353ea
movl 0xc(%r14), %eax
xorl %r12d, %r12d
addl $-0x4, %eax
cmpl $0x7, %eax
ja 0x354d3
leaq 0x81377(%rip), %rcx     # 0xb679c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x0, 0x10(%rbp)
jne 0x35497
cmpl $0x1, 0x10(%r13)
jmp 0x35447
cmpq $0x0, 0x10(%rbp)
jne 0x35497
cmpq $0x1, 0x10(%r13)
sete %r12b
jmp 0x354d3
movss 0x10(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x35497
jp 0x35497
movss 0x82069(%rip), %xmm0    # 0xb74d0
cmpeqss 0x10(%r13), %xmm0
jmp 0x354ca
movsd 0x10(%rbp), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x35497
jp 0x35497
movsd 0x8202f(%rip), %xmm0    # 0xb74b8
cmpeqsd 0x10(%r13), %xmm0
movq %xmm0, %r12
jmp 0x354cf
xorl %r12d, %r12d
jmp 0x354d3
xorl %r12d, %r12d
movq %rbp, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x53c24
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x354d3
jp 0x354d3
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x53c24
cmpeqss 0x82006(%rip), %xmm0    # 0xb74d0
movd %xmm0, %r12d
andl $0x1, %r12d
testb %r12b, %r12b
je 0x353ea
leaq 0x8(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x35152
movq %rbx, %rdi
movq %r13, %rsi
callq 0x6310
movq (%r13), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x353ea
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x353ea