// File: /workspace/github_cpp_makefile_star2_O3/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, %r15d
movq %rcx, %r14
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
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, 0x24(%rsp)
jne 0x3c7fa
movq %r12, %rdi
movq %r14, %rsi
callq 0x1b12c
movl 0xa8(%rsp), %esi
testl %esi, %esi
sete %cl
xorb $0x1, %al
orb %cl, %al
jne 0x3c7fa
movq %r12, %rdi
callq 0x54236
testq %rax, %rax
je 0x3c796
movss 0x10(%rax), %xmm0
movb $0x1, %bpl
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x3c796
jnp 0x3c7fc
movl $0x10, %edi
callq 0x6140
movq %rax, %rbx
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x7bd7c(%rip), %rsi     # 0xb852f
leaq 0x7bdce(%rip), %rdx     # 0xb8588
leaq 0x28(%rsp), %rdi
callq 0x7be0
movb $0x1, %bpl
leaq 0x28(%rsp), %rsi
movq %rbx, %rdi
callq 0x6320
leaq 0xbf5ed(%rip), %rax     # 0xfbdc8
addq $0x10, %rax
movq %rax, (%rbx)
xorl %ebp, %ebp
leaq 0xbf5c5(%rip), %rsi     # 0xfbdb0
movq 0xc07e6(%rip), %rdx     # 0xfcfd8
movq %rbx, %rdi
callq 0x6470
xorl %ebp, %ebp
testb %r15b, %r15b
je 0x3c80d
leaq 0x7aded(%rip), %rsi     # 0xb75f5
jmp 0x3c896
leaq 0x85d34(%rip), %rsi     # 0xc2548
movq %rsp, %rdi
callq 0x64e0
testb %r13b, %r13b
je 0x3c830
leaq 0x815c3(%rip), %rsi     # 0xbddeb
movq %rsp, %rdi
callq 0x64e0
cmpb $0x0, 0x88(%rsp)
je 0x3c849
leaq 0x7adff(%rip), %rsi     # 0xb7640
movq %rsp, %rdi
callq 0x64e0
cmpb $0x0, 0x80(%rsp)
je 0x3c862
leaq 0x7ae3d(%rip), %rsi     # 0xb7697
movq %rsp, %rdi
callq 0x64e0
movb 0x98(%rsp), %al
orb %bpl, %al
cmpb $0x1, %al
jne 0x3c87f
leaq 0x815ca(%rip), %rsi     # 0xbde41
movq %rsp, %rdi
callq 0x64e0
cmpl $0x0, 0xa8(%rsp)
sete %al
orb %bpl, %al
jne 0x3c89e
leaq 0x7add7(%rip), %rsi     # 0xb766d
movq %rsp, %rdi
callq 0x64e0
cmpb $0x0, 0x90(%rsp)
je 0x3c8b7
leaq 0x7adb0(%rip), %rsi     # 0xb765f
movq %rsp, %rdi
callq 0x64e0
cmpb $0x0, 0x43c(%r12)
movl $0x12b, %eax            # imm = 0x12B
movl $0x81, %ecx
cmovnel %eax, %ecx
cmpl %ecx, 0x438(%r12)
jbe 0x3c8f4
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0xe456
jmp 0x3c912
movq %rsp, %rdx
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rcx
movl 0xa8(%rsp), %r8d
movl 0x24(%rsp), %r9d
callq 0x3abd0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x3c92d
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x3c959
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x6260
testb %bpl, %bpl
jne 0x3c963
jmp 0x3c972
movq %rax, %r14
movq %rbx, %rdi
callq 0x6200
jmp 0x3c972
jmp 0x3c96f
movq %rax, %r14
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x3c98d
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
movq %r14, %rdi
callq 0x64a0
nop