// File: /workspace/github_cpp_makefile_star2_O2/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, %ebp
movl %r8d, %r12d
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movl %ecx, %esi
callq 0x43b76
movq %rax, %r13
movq %r15, %rdi
movl %r12d, %esi
callq 0x43b76
movq %rax, %r12
movq %r15, %rdi
movl %ebp, %esi
callq 0x104b0
movq %rax, %rcx
testq %r13, %r13
sete %al
testq %r12, %r12
sete %dl
orb %al, %dl
jne 0x2c443
cmpb $0x0, 0x108(%r13)
jne 0x2c443
cmpb $0x0, 0x108(%r12)
je 0x2c454
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
cmpl $0x2, 0xc(%rcx)
jne 0x2c445
cmpl $0x1, 0x14(%rcx)
ja 0x2c445
movl 0xc(%r14), %ecx
xorl %eax, %eax
addl $-0x4, %ecx
cmpl $0x7, %ecx
ja 0x2c445
leaq 0x642f5(%rip), %rdx     # 0x9076c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
cmpl $0x0, 0x10(%r13)
jne 0x2c443
cmpl $0x1, 0x10(%r12)
jne 0x2c443
jmp 0x2c523
cmpq $0x0, 0x10(%r13)
jne 0x2c443
cmpq $0x1, 0x10(%r12)
jne 0x2c443
jmp 0x2c523
movss 0x10(%r13), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x2c443
jp 0x2c443
movss 0x10(%r12), %xmm0
jmp 0x2c510
movsd 0x10(%r13), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x2c443
jp 0x2c443
movsd 0x10(%r12), %xmm0
ucomisd 0x64fa1(%rip), %xmm0    # 0x91488
jmp 0x2c517
movzwl 0x10(%r13), %edi
callq 0x47e70
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x2c443
jp 0x2c443
movzwl 0x10(%r12), %edi
callq 0x47e70
ucomiss 0x64f89(%rip), %xmm0    # 0x914a0
jne 0x2c443
jp 0x2c443
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x2c226
movq %rbx, %rdi
movq %r12, %rsi
callq 0x6320
movq %r12, %rdi
callq 0x6548
movb $0x1, %al
jmp 0x2c445