// File: /workspace/github_cpp_makefile_star2_O1/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 0x3d04a
movq %r12, %rdi
movq %r14, %rsi
callq 0x1b812
movl 0xa8(%rsp), %esi
testl %esi, %esi
sete %cl
xorb $0x1, %al
orb %cl, %al
jne 0x3d04a
movq %r12, %rdi
callq 0x54a30
testq %rax, %rax
je 0x3cfe6
movss 0x10(%rax), %xmm0
movb $0x1, %bpl
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x3cfe6
jnp 0x3d04c
movl $0x10, %edi
callq 0x6140
movq %rax, %rbx
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x7c53c(%rip), %rsi     # 0xb953f
leaq 0x7c58e(%rip), %rdx     # 0xb9598
leaq 0x28(%rsp), %rdi
callq 0x7c64
movb $0x1, %bpl
leaq 0x28(%rsp), %rsi
movq %rbx, %rdi
callq 0x6320
leaq 0xbfd6d(%rip), %rax     # 0xfcd98
addq $0x10, %rax
movq %rax, (%rbx)
xorl %ebp, %ebp
leaq 0xbfd45(%rip), %rsi     # 0xfcd80
movq 0xc0f96(%rip), %rdx     # 0xfdfd8
movq %rbx, %rdi
callq 0x6470
xorl %ebp, %ebp
testb %r15b, %r15b
je 0x3d05d
leaq 0x7b5ad(%rip), %rsi     # 0xb8605
jmp 0x3d0e6
leaq 0x86514(%rip), %rsi     # 0xc3578
movq %rsp, %rdi
callq 0x64e0
testb %r13b, %r13b
je 0x3d080
leaq 0x81d6b(%rip), %rsi     # 0xbede3
movq %rsp, %rdi
callq 0x64e0
cmpb $0x0, 0x88(%rsp)
je 0x3d099
leaq 0x7b5bf(%rip), %rsi     # 0xb8650
movq %rsp, %rdi
callq 0x64e0
cmpb $0x0, 0x80(%rsp)
je 0x3d0b2
leaq 0x7b5fd(%rip), %rsi     # 0xb86a7
movq %rsp, %rdi
callq 0x64e0
movb 0x98(%rsp), %al
orb %bpl, %al
cmpb $0x1, %al
jne 0x3d0cf
leaq 0x81d72(%rip), %rsi     # 0xbee39
movq %rsp, %rdi
callq 0x64e0
cmpl $0x0, 0xa8(%rsp)
sete %al
orb %bpl, %al
jne 0x3d0ee
leaq 0x7b597(%rip), %rsi     # 0xb867d
movq %rsp, %rdi
callq 0x64e0
cmpb $0x0, 0x90(%rsp)
je 0x3d107
leaq 0x7b570(%rip), %rsi     # 0xb866f
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 0x3d144
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0xe480
jmp 0x3d162
movq %rsp, %rdx
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rcx
movl 0xa8(%rsp), %r8d
movl 0x24(%rsp), %r9d
callq 0x3b3dc
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x3d17d
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 0x3d1b1
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x3d1b1
movq %rax, %r14
movb $0x1, %bpl
testb %bpl, %bpl
je 0x3d1c5
movq %rbx, %rdi
callq 0x6200
jmp 0x3d1c5
jmp 0x3d1c2
movq %rax, %r14
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x3d1e0
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
movq %r14, %rdi
callq 0x64a0