// File: /workspace/github_cpp_makefile_star2_O2/rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::to_combined_image_sampler[abi:cxx11](unsigned int, unsigned int)
string CompilerGLSL::to_combined_image_sampler(uint32_t image_id, uint32_t samp_id)
{
	// Keep track of the array indices we have used to load the image.
	// We'll need to use the same array index into the combined image sampler array.
	auto image_expr = to_expression(image_id);
	string array_expr;
	auto array_index = image_expr.find_first_of('[');
	if (array_index != string::npos)
		array_expr = image_expr.substr(array_index, string::npos);

	auto &args = current_function->arguments;

	// For GLSL and ESSL targets, we must enumerate all possible combinations for sampler2D(texture2D, sampler) and redirect
	// all possible combinations into new sampler2D uniforms.
	auto *image = maybe_get_backing_variable(image_id);
	auto *samp = maybe_get_backing_variable(samp_id);
	if (image)
		image_id = image->self;
	if (samp)
		samp_id = samp->self;

	auto image_itr = find_if(begin(args), end(args),
	                         [image_id](const SPIRFunction::Parameter &param) { return param.id == image_id; });

	auto sampler_itr = find_if(begin(args), end(args),
	                           [samp_id](const SPIRFunction::Parameter &param) { return param.id == samp_id; });

	if (image_itr != end(args) || sampler_itr != end(args))
	{
		// If any parameter originates from a parameter, we will find it in our argument list.
		bool global_image = image_itr == end(args);
		bool global_sampler = sampler_itr == end(args);
		uint32_t iid = global_image ? image_id : uint32_t(image_itr - begin(args));
		uint32_t sid = global_sampler ? samp_id : uint32_t(sampler_itr - begin(args));

		auto &combined = current_function->combined_parameters;
		auto itr = find_if(begin(combined), end(combined), [=](const SPIRFunction::CombinedImageSamplerParameter &p) {
			return p.global_image == global_image && p.global_sampler == global_sampler && p.image_id == iid &&
			       p.sampler_id == sid;
		});

		if (itr != end(combined))
			return to_expression(itr->id) + array_expr;
		else
		{
			SPIRV_CROSS_THROW(
			    "Cannot find mapping for combined sampler parameter, was build_combined_image_samplers() used "
			    "before compile() was called?");
		}
	}
	else
	{
		// For global sampler2D, look directly at the global remapping table.
		auto &mapping = combined_image_samplers;
		auto itr = find_if(begin(mapping), end(mapping), [image_id, samp_id](const CombinedImageSampler &combined) {
			return combined.image_id == image_id && combined.sampler_id == samp_id;
		});

		if (itr != end(combined_image_samplers))
			return to_expression(itr->combined_id) + array_expr;
		else
		{
			SPIRV_CROSS_THROW("Cannot find mapping for combined sampler, was build_combined_image_samplers() used "
			                  "before compile() was called?");
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %ecx, %r15d
movl %edx, %r12d
movq %rsi, %r14
movq %rdi, %rbp
leaq 0x58(%rsp), %r13
movq %r13, %rdi
callq 0x2b9f0
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
pushq $0x5b
popq %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x6370
cmpq $-0x1, %rax
je 0x30c46
leaq 0x18(%rsp), %rdi
leaq 0x58(%rsp), %rsi
pushq $-0x1
popq %rcx
movq %rax, %rdx
callq 0x62b0
leaq 0x38(%rsp), %rdi
leaq 0x18(%rsp), %r13
movq %r13, %rsi
callq 0x6320
movq %r13, %rdi
callq 0x6548
movq 0x148(%r14), %rbx
movq %r14, %rdi
movl %r12d, %esi
callq 0x1067e
movq %rax, %r13
movq %r14, %rdi
movl %r15d, %esi
callq 0x1067e
testq %r13, %r13
je 0x30c6f
movl 0x8(%r13), %r12d
testq %rax, %rax
je 0x30c78
movl 0x8(%rax), %r15d
movq 0x18(%rbx), %r8
movq 0x20(%rbx), %rdi
movq %rdi, %rcx
subq %r8, %rcx
pushq $0x14
popq %r9
movq %rcx, %rax
cqto
idivq %r9
movq %rax, %rsi
sarq $0x2, %rsi
movq %rcx, %rax
movq %r8, %r11
movq %rsi, %rdx
testq %rdx, %rdx
jle 0x30ccc
cmpl %r12d, 0x4(%r11)
je 0x30d14
cmpl %r12d, 0x18(%r11)
je 0x30d04
cmpl %r12d, 0x2c(%r11)
je 0x30d0a
cmpl %r12d, 0x40(%r11)
je 0x30d10
addq $0x50, %r11
decq %rdx
addq $-0x50, %rax
jmp 0x30ca2
cqto
idivq %r9
cmpq $0x1, %rax
je 0x30cfa
cmpq $0x2, %rax
je 0x30cf0
movq %rdi, %r10
cmpq $0x3, %rax
jne 0x30d17
cmpl %r12d, 0x4(%r11)
je 0x30d14
addq $0x14, %r11
cmpl %r12d, 0x4(%r11)
je 0x30d14
addq $0x14, %r11
cmpl %r12d, 0x4(%r11)
cmovneq %rdi, %r11
jmp 0x30d14
addq $0x14, %r11
jmp 0x30d14
addq $0x28, %r11
jmp 0x30d14
addq $0x3c, %r11
movq %r11, %r10
movq %r8, %r11
testq %rsi, %rsi
jle 0x30d44
cmpl %r15d, 0x4(%r11)
je 0x30d8f
cmpl %r15d, 0x18(%r11)
je 0x30d7f
cmpl %r15d, 0x2c(%r11)
je 0x30d85
cmpl %r15d, 0x40(%r11)
je 0x30d8b
addq $0x50, %r11
decq %rsi
addq $-0x50, %rcx
jmp 0x30d1a
movq %rcx, %rax
cqto
idivq %r9
cmpq $0x1, %rax
je 0x30d75
cmpq $0x2, %rax
je 0x30d6b
movq %rdi, %rcx
cmpq $0x3, %rax
jne 0x30d92
cmpl %r15d, 0x4(%r11)
je 0x30d8f
addq $0x14, %r11
cmpl %r15d, 0x4(%r11)
je 0x30d8f
addq $0x14, %r11
cmpl %r15d, 0x4(%r11)
cmovneq %rdi, %r11
jmp 0x30d8f
addq $0x14, %r11
jmp 0x30d8f
addq $0x28, %r11
jmp 0x30d8f
addq $0x3c, %r11
movq %r11, %rcx
cmpq %rdi, %r10
jne 0x30e1e
cmpq %rdi, %rcx
jne 0x30e1e
movq 0x1d8(%r14), %rdi
movq 0x1e0(%r14), %rsi
movq %rsi, %rcx
subq %rdi, %rcx
pushq $0xc
popq %r8
movq %rcx, %rax
cqto
idivq %r8
sarq $0x2, %rax
addq $0x18, %rdi
testq %rax, %rax
jle 0x30f4a
cmpl %r12d, -0x14(%rdi)
jne 0x30de1
cmpl %r15d, -0x10(%rdi)
je 0x30f79
cmpl %r12d, -0x8(%rdi)
jne 0x30df1
cmpl %r15d, -0x4(%rdi)
je 0x30f8e
cmpl %r12d, 0x4(%rdi)
jne 0x30e01
cmpl %r15d, 0x8(%rdi)
je 0x30f98
cmpl %r12d, 0x10(%rdi)
jne 0x30e11
cmpl %r15d, 0x14(%rdi)
je 0x30f94
decq %rax
addq $0x30, %rdi
addq $-0x30, %rcx
jmp 0x30dc8
cmpq %rdi, %r10
je 0x30e31
movq %r10, %rax
subq %r8, %rax
cqto
idivq %r9
movq %rax, %r12
cmpq %rdi, %rcx
movq %rbp, 0x10(%rsp)
je 0x30e4d
subq %r8, %rcx
movq %rcx, %rax
cqto
idivq %r9
movq %rax, %r15
xorl %eax, %eax
jmp 0x30e52
movl $0x100, %eax            # imm = 0x100
xorl %ecx, %ecx
cmpq %rdi, %r10
sete %cl
movq 0x148(%r14), %rdx
movq 0x80(%rdx), %r13
movq 0x88(%rdx), %rbx
shlq $0x20, %r12
orq %rax, %r12
orq %r12, %rcx
leaq 0x18(%rsp), %r12
movq %rcx, (%r12)
movl %r15d, 0x8(%r12)
movq %rbx, 0x8(%rsp)
subq %r13, %rbx
movq %rbx, %rbp
sarq $0x6, %rbp
testq %rbp, %rbp
jle 0x30f00
movq %r12, %rdi
movq %r13, %rsi
callq 0x40cb4
testb %al, %al
jne 0x30f7f
leaq 0x10(%r13), %r15
movq %r12, %rdi
movq %r15, %rsi
callq 0x40cb4
testb %al, %al
jne 0x30f82
leaq 0x20(%r13), %r15
movq %r12, %rdi
movq %r15, %rsi
callq 0x40cb4
testb %al, %al
jne 0x30f82
leaq 0x30(%r13), %r15
movq %r12, %rdi
movq %r15, %rsi
callq 0x40cb4
testb %al, %al
jne 0x30f82
addq $0x40, %r13
decq %rbp
addq $-0x40, %rbx
jmp 0x30e96
sarq $0x4, %rbx
cmpq $0x1, %rbx
je 0x30fe3
cmpq $0x2, %rbx
movq 0x10(%rsp), %rbp
je 0x30fc7
cmpq $0x3, %rbx
jne 0x310e8
leaq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x40cb4
testb %al, %al
movq 0x8(%rsp), %rbx
jne 0x31000
addq $0x10, %r13
jmp 0x30fcc
movq %rcx, %rax
cqto
idivq %r8
leaq -0x18(%rdi), %rcx
cmpq $0x1, %rax
je 0x31089
cmpq $0x3, %rax
je 0x3105e
cmpq $0x2, %rax
je 0x31075
jmp 0x3109d
addq $-0x18, %rdi
jmp 0x30f98
movq %r13, %r15
movq 0x10(%rsp), %rbp
movq 0x8(%rsp), %rbx
jmp 0x31003
addq $-0xc, %rdi
jmp 0x30f98
addq $0xc, %rdi
movq %rdi, %rcx
cmpq %rsi, %rcx
je 0x3109d
movl (%rcx), %edx
leaq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0x2b9f0
leaq 0x18(%rsp), %rsi
leaq 0x38(%rsp), %rdx
movq %rbp, %rdi
callq 0x42dd2
jmp 0x3102e
movq 0x8(%rsp), %rbx
leaq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x40cb4
testb %al, %al
jne 0x31000
addq $0x10, %r13
jmp 0x30fed
movq 0x10(%rsp), %rbp
movq 0x8(%rsp), %rbx
leaq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x40cb4
testb %al, %al
cmoveq %rbx, %r13
movq %r13, %r15
cmpq %rbx, %r15
je 0x310e8
movl (%r15), %edx
leaq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0x2b9f0
leaq 0x18(%rsp), %rsi
leaq 0x38(%rsp), %rdx
movq %rbp, %rdi
callq 0x42dd2
leaq 0x18(%rsp), %rdi
callq 0x6548
leaq 0x38(%rsp), %rdi
callq 0x6548
leaq 0x58(%rsp), %rdi
callq 0x6548
movq %rbp, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl %r12d, -0x14(%rdi)
jne 0x3106e
cmpl %r15d, -0x10(%rdi)
je 0x30f9b
addq $-0xc, %rdi
movq %rdi, %rcx
cmpl %r12d, 0x4(%rcx)
jne 0x31085
cmpl %r15d, 0x8(%rcx)
je 0x30f9b
addq $0xc, %rcx
xorl 0x4(%rcx), %r12d
xorl 0x8(%rcx), %r15d
orl %r12d, %r15d
cmovneq %rsi, %rcx
jmp 0x30f9b
pushq $0x10
popq %rdi
callq 0x6140
movq %rax, %r14
leaq 0x623ed(%rip), %rsi     # 0x9349c
leaq 0x18(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x6100
movb $0x1, %bpl
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
callq 0x6f6e
xorl %ebp, %ebp
leaq 0xb5ce9(%rip), %rsi     # 0xe6dc0
movq 0xb6f02(%rip), %rdx     # 0xe7fe0
movq %r14, %rdi
callq 0x6490
jmp 0x31131
pushq $0x10
popq %rdi
callq 0x6140
movq %rax, %r14
leaq 0x62328(%rip), %rsi     # 0x93422
leaq 0x18(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x6100
movb $0x1, %bpl
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
callq 0x6f6e
xorl %ebp, %ebp
leaq 0xb5c9e(%rip), %rsi     # 0xe6dc0
movq 0xb6eb7(%rip), %rdx     # 0xe7fe0
movq %r14, %rdi
callq 0x6490
jmp 0x31135
jmp 0x31149
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x6548
testb %bpl, %bpl
jne 0x3114c
jmp 0x31172
movq %rax, %rbx
movq %r14, %rdi
callq 0x6200
jmp 0x31172
jmp 0x31158
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x6548
jmp 0x31172
jmp 0x3116f
jmp 0x3116f
jmp 0x3116f
jmp 0x3116f
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x6548
leaq 0x58(%rsp), %rdi
callq 0x6548
movq %rbx, %rdi
callq 0x64b0