// File: /workspace/github_cpp_makefile_star2_O2/rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::to_function_name[abi:cxx11](unsigned int, spirv_cross::SPIRType const&, bool, bool, bool, bool, bool, bool, bool, unsigned int)
string CompilerGLSL::to_function_name(uint32_t tex, const SPIRType &imgtype, bool is_fetch, bool is_gather,
                                      bool is_proj, bool has_array_offsets, bool has_offset, bool has_grad, bool,
                                      uint32_t lod)
{
	string fname;

	// textureLod on sampler2DArrayShadow and samplerCubeShadow does not exist in GLSL for some reason.
	// To emulate this, we will have to use textureGrad with a constant gradient of 0.
	// The workaround will assert that the LOD is in fact constant 0, or we cannot emit correct code.
	// This happens for HLSL SampleCmpLevelZero on Texture2DArray and TextureCube.
	bool workaround_lod_array_shadow_as_grad = false;
	if (((imgtype.image.arrayed && imgtype.image.dim == Dim2D) || imgtype.image.dim == DimCube) &&
	    image_is_comparison(imgtype, tex) && lod)
	{
		auto *constant_lod = maybe_get<SPIRConstant>(lod);
		if (!constant_lod || constant_lod->scalar_f32() != 0.0f)
			SPIRV_CROSS_THROW(
			    "textureLod on sampler2DArrayShadow is not constant 0.0. This cannot be expressed in GLSL.");
		workaround_lod_array_shadow_as_grad = true;
	}

	if (is_fetch)
		fname += "texelFetch";
	else
	{
		fname += "texture";

		if (is_gather)
			fname += "Gather";
		if (has_array_offsets)
			fname += "Offsets";
		if (is_proj)
			fname += "Proj";
		if (has_grad || workaround_lod_array_shadow_as_grad)
			fname += "Grad";
		if (!!lod && !workaround_lod_array_shadow_as_grad)
			fname += "Lod";
	}

	if (has_offset)
		fname += "Offset";

	return is_legacy() ? legacy_tex_op(fname, imgtype, lod, tex) : fname;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r9d, %r13d
movl %r8d, %r12d
movq %rcx, %r14
movq %rsi, %r15
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movq %rdi, %rbx
movb $0x0, (%rax)
movl 0x84(%rcx), %eax
cmpl $0x1, %eax
sete %cl
andb 0x89(%r14), %cl
cmpl $0x3, %eax
sete %al
orb %cl, %al
cmpb $0x1, %al
movl %edx, 0x4(%rsp)
jne 0x319ea
movq %r15, %rdi
movq %r14, %rsi
callq 0x16cd4
movl 0xa8(%rsp), %esi
testl %esi, %esi
sete %cl
xorb $0x1, %al
orb %cl, %al
jne 0x319ea
movq %r15, %rdi
callq 0x43b76
testq %rax, %rax
je 0x319a1
movss 0x10(%rax), %xmm0
movb $0x1, %bpl
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x319a1
jnp 0x319ec
pushq $0x10
popq %rdi
callq 0x6140
movq %rax, %rbx
leaq 0x61b5c(%rip), %rsi     # 0x9350f
leaq 0x28(%rsp), %rdi
leaq 0x3(%rsp), %rdx
callq 0x6100
movb $0x1, %bpl
leaq 0x28(%rsp), %rsi
movq %rbx, %rdi
callq 0x6f6e
xorl %ebp, %ebp
leaq 0xb53e5(%rip), %rsi     # 0xe6dc0
movq 0xb65fe(%rip), %rdx     # 0xe7fe0
movq %rbx, %rdi
callq 0x6490
xorl %ebp, %ebp
testb %r12b, %r12b
je 0x319fd
leaq 0x60bdd(%rip), %rsi     # 0x925d5
jmp 0x31a90
leaq 0x6bafc(%rip), %rsi     # 0x9d500
leaq 0x8(%rsp), %rdi
callq 0x64d0
testb %r13b, %r13b
je 0x31a24
leaq 0x67361(%rip), %rsi     # 0x98d7b
leaq 0x8(%rsp), %rdi
callq 0x64d0
cmpb $0x0, 0x88(%rsp)
je 0x31a3f
leaq 0x60beb(%rip), %rsi     # 0x92620
leaq 0x8(%rsp), %rdi
callq 0x64d0
cmpb $0x0, 0x80(%rsp)
je 0x31a5a
leaq 0x60c27(%rip), %rsi     # 0x92677
leaq 0x8(%rsp), %rdi
callq 0x64d0
movb 0x98(%rsp), %al
orb %bpl, %al
cmpb $0x1, %al
jne 0x31a79
leaq 0x67362(%rip), %rsi     # 0x98dd1
leaq 0x8(%rsp), %rdi
callq 0x64d0
cmpl $0x0, 0xa8(%rsp)
sete %al
orb %bpl, %al
jne 0x31a9a
leaq 0x60bbd(%rip), %rsi     # 0x9264d
leaq 0x8(%rsp), %rdi
callq 0x64d0
cmpb $0x0, 0x90(%rsp)
je 0x31ab5
leaq 0x60b94(%rip), %rsi     # 0x9263f
leaq 0x8(%rsp), %rdi
callq 0x64d0
movq %r15, %rdi
callq 0x41b9c
testb %al, %al
je 0x31ae3
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rcx
movl 0xa8(%rsp), %r8d
movl 0x4(%rsp), %r9d
callq 0x302ce
jmp 0x31af0
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x63c0
leaq 0x8(%rsp), %rdi
callq 0x6548
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq 0x28(%rsp), %rdi
callq 0x6548
testb %bpl, %bpl
jne 0x31b23
jmp 0x31b32
movq %rax, %r14
movq %rbx, %rdi
callq 0x6200
jmp 0x31b32
jmp 0x31b2f
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x6548
movq %r14, %rdi
callq 0x64b0