// File: rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::flags_to_precision_qualifiers_glsl(spirv_cross::SPIRType const&, spirv_cross::Bitset const&)
const char *CompilerGLSL::flags_to_precision_qualifiers_glsl(const SPIRType &type, const Bitset &flags)
{
	// Structs do not have precision qualifiers, neither do doubles (desktop only anyways, so no mediump/highp).
	if (type.basetype != SPIRType::Float && type.basetype != SPIRType::Int && type.basetype != SPIRType::UInt &&
	    type.basetype != SPIRType::Image && type.basetype != SPIRType::SampledImage &&
	    type.basetype != SPIRType::Sampler)
		return "";

	if (options.es)
	{
		auto &execution = get_entry_point();

		if (flags.get(DecorationRelaxedPrecision))
		{
			bool implied_fmediump = type.basetype == SPIRType::Float &&
			                        options.fragment.default_float_precision == Options::Mediump &&
			                        execution.model == ExecutionModelFragment;

			bool implied_imediump = (type.basetype == SPIRType::Int || type.basetype == SPIRType::UInt) &&
			                        options.fragment.default_int_precision == Options::Mediump &&
			                        execution.model == ExecutionModelFragment;

			return implied_fmediump || implied_imediump ? "" : "mediump ";
		}
		else
		{
			bool implied_fhighp =
			    type.basetype == SPIRType::Float && ((options.fragment.default_float_precision == Options::Highp &&
			                                          execution.model == ExecutionModelFragment) ||
			                                         (execution.model != ExecutionModelFragment));

			bool implied_ihighp = (type.basetype == SPIRType::Int || type.basetype == SPIRType::UInt) &&
			                      ((options.fragment.default_int_precision == Options::Highp &&
			                        execution.model == ExecutionModelFragment) ||
			                       (execution.model != ExecutionModelFragment));

			return implied_fhighp || implied_ihighp ? "" : "highp ";
		}
	}
	else if (backend.allow_precision_qualifiers)
	{
		// Vulkan GLSL supports precision qualifiers, even in desktop profiles, which is convenient.
		// The default is highp however, so only emit mediump in the rare case that a shader has these.
		if (flags.get(DecorationRelaxedPrecision))
			return "mediump ";
		else
			return "";
	}
	else
		return "";
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
cmpl $0xa, 0xc(%rax)
je 0x61898
movq -0x18(%rbp), %rax
cmpl $0x4, 0xc(%rax)
je 0x61898
movq -0x18(%rbp), %rax
cmpl $0x5, 0xc(%rax)
je 0x61898
movq -0x18(%rbp), %rax
cmpl $0xd, 0xc(%rax)
je 0x61898
movq -0x18(%rbp), %rax
cmpl $0xe, 0xc(%rax)
je 0x61898
movq -0x18(%rbp), %rax
cmpl $0xf, 0xc(%rax)
je 0x61898
leaq 0xdd00f(%rip), %rax     # 0x13e89e
movq %rax, -0x8(%rbp)
jmp 0x61a90
movq -0x38(%rbp), %rax
testb $0x1, 0x43c(%rax)
je 0x61a4d
movq -0x38(%rbp), %rdi
callq 0x25150
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0xef50
testb $0x1, %al
jne 0x618ca
jmp 0x6197a
movq -0x18(%rbp), %rcx
xorl %eax, %eax
cmpl $0xa, 0xc(%rcx)
movb %al, -0x39(%rbp)
jne 0x618fc
movq -0x38(%rbp), %rcx
xorl %eax, %eax
cmpl $0x2, 0x448(%rcx)
movb %al, -0x39(%rbp)
jne 0x618fc
movq -0x28(%rbp), %rax
cmpl $0x4, 0xb8(%rax)
sete %al
movb %al, -0x39(%rbp)
movb -0x39(%rbp), %al
andb $0x1, %al
movb %al, -0x29(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x4, 0xc(%rax)
je 0x6191d
movq -0x18(%rbp), %rcx
xorl %eax, %eax
cmpl $0x5, 0xc(%rcx)
movb %al, -0x3a(%rbp)
jne 0x61940
movq -0x38(%rbp), %rcx
xorl %eax, %eax
cmpl $0x2, 0x44c(%rcx)
movb %al, -0x3a(%rbp)
jne 0x61940
movq -0x28(%rbp), %rax
cmpl $0x4, 0xb8(%rax)
sete %al
movb %al, -0x3a(%rbp)
movb -0x3a(%rbp), %al
andb $0x1, %al
movb %al, -0x2a(%rbp)
movb $0x1, %al
testb $0x1, -0x29(%rbp)
movb %al, -0x3b(%rbp)
jne 0x61959
movb -0x2a(%rbp), %al
movb %al, -0x3b(%rbp)
movb -0x3b(%rbp), %dl
leaq 0xe312a(%rip), %rax     # 0x144a8d
leaq 0xdcf34(%rip), %rcx     # 0x13e89e
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, -0x8(%rbp)
jmp 0x61a90
movq -0x18(%rbp), %rcx
xorl %eax, %eax
cmpl $0xa, 0xc(%rcx)
movb %al, -0x3c(%rbp)
jne 0x619bf
movq -0x38(%rbp), %rax
cmpl $0x3, 0x448(%rax)
jne 0x619a8
movq -0x28(%rbp), %rcx
movb $0x1, %al
cmpl $0x4, 0xb8(%rcx)
movb %al, -0x3d(%rbp)
je 0x619b9
movq -0x28(%rbp), %rax
cmpl $0x4, 0xb8(%rax)
setne %al
movb %al, -0x3d(%rbp)
movb -0x3d(%rbp), %al
movb %al, -0x3c(%rbp)
movb -0x3c(%rbp), %al
andb $0x1, %al
movb %al, -0x2b(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x4, 0xc(%rax)
je 0x619e0
movq -0x18(%rbp), %rcx
xorl %eax, %eax
cmpl $0x5, 0xc(%rcx)
movb %al, -0x3e(%rbp)
jne 0x61a16
movq -0x38(%rbp), %rax
cmpl $0x3, 0x44c(%rax)
jne 0x619ff
movq -0x28(%rbp), %rcx
movb $0x1, %al
cmpl $0x4, 0xb8(%rcx)
movb %al, -0x3f(%rbp)
je 0x61a10
movq -0x28(%rbp), %rax
cmpl $0x4, 0xb8(%rax)
setne %al
movb %al, -0x3f(%rbp)
movb -0x3f(%rbp), %al
movb %al, -0x3e(%rbp)
movb -0x3e(%rbp), %al
andb $0x1, %al
movb %al, -0x2c(%rbp)
movb $0x1, %al
testb $0x1, -0x2b(%rbp)
movb %al, -0x40(%rbp)
jne 0x61a2f
movb -0x2c(%rbp), %al
movb %al, -0x40(%rbp)
movb -0x40(%rbp), %dl
leaq 0xe305d(%rip), %rax     # 0x144a96
leaq 0xdce5e(%rip), %rcx     # 0x13e89e
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, -0x8(%rbp)
jmp 0x61a90
movq -0x38(%rbp), %rax
testb $0x1, 0x62b(%rax)
je 0x61a85
movq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0xef50
testb $0x1, %al
jne 0x61a6b
jmp 0x61a78
leaq 0xe301b(%rip), %rax     # 0x144a8d
movq %rax, -0x8(%rbp)
jmp 0x61a90
leaq 0xdce1f(%rip), %rax     # 0x13e89e
movq %rax, -0x8(%rbp)
jmp 0x61a90
leaq 0xdce12(%rip), %rax     # 0x13e89e
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)