// File: /workspace/github_cpp_makefile_star2_O3/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 $0x68, %rsp
movl %ecx, %ebp
movl %edx, %r15d
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x48(%rsp), %r12
movq %r12, %rdi
callq 0x33f8a
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq %r12, %rdi
movl $0x5b, %esi
xorl %edx, %edx
callq 0x6340
cmpq $-0x1, %rax
je 0x3b6bf
leaq 0x8(%rsp), %rdi
leaq 0x48(%rsp), %rsi
movq %rax, %rdx
movq $-0x1, %rcx
callq 0x6290
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %r12
movq %r12, %rsi
callq 0x6310
movq (%r12), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x3b6bf
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x148(%r14), %r13
movq %r14, %rdi
movl %r15d, %esi
callq 0x12c9a
movq %rax, %r12
movq %r14, %rdi
movl %ebp, %esi
callq 0x12c9a
testq %r12, %r12
je 0x3b6e8
movl 0x8(%r12), %r15d
testq %rax, %rax
je 0x3b6f0
movl 0x8(%rax), %ebp
movq 0x18(%r13), %rcx
movq 0x20(%r13), %rax
movq %rax, %r8
subq %rcx, %r8
movq %r8, %rdi
sarq $0x2, %rdi
movabsq $-0x3333333333333333, %rsi # imm = 0xCCCCCCCCCCCCCCCD
imulq %rsi, %rdi
sarq $0x2, %rdi
leaq (%rdi,%rdi,4), %r9
movq %r8, %r11
movq %rcx, %r10
testq %rdi, %rdi
jle 0x3b763
movq %r9, %r10
shlq $0x4, %r10
addq %rcx, %r10
leaq 0x1(%rdi), %r11
leaq 0x28(%rcx), %rdx
cmpl %r15d, -0x24(%rdx)
je 0x3b7a1
cmpl %r15d, -0x10(%rdx)
je 0x3b7a7
cmpl %r15d, 0x4(%rdx)
je 0x3b7b1
cmpl %r15d, 0x18(%rdx)
je 0x3b7ad
decq %r11
addq $0x50, %rdx
cmpq $0x1, %r11
jg 0x3b738
movq %rax, %r11
subq %r10, %r11
sarq $0x2, %r11
imulq %rsi, %r11
cmpq $0x1, %r11
je 0x3b794
cmpq $0x2, %r11
je 0x3b78a
movq %rax, %rdx
cmpq $0x3, %r11
jne 0x3b7b1
cmpl %r15d, 0x4(%r10)
je 0x3b79c
addq $0x14, %r10
cmpl %r15d, 0x4(%r10)
je 0x3b79c
addq $0x14, %r10
cmpl %r15d, 0x4(%r10)
cmovneq %rax, %r10
movq %r10, %rdx
jmp 0x3b7b1
addq $-0x28, %rdx
jmp 0x3b7b1
addq $-0x14, %rdx
jmp 0x3b7b1
addq $0x14, %rdx
movq %rcx, %r10
testq %rdi, %rdi
jle 0x3b7f5
shlq $0x4, %r9
movq %r9, %r10
addq %rcx, %r10
incq %rdi
leaq 0x28(%rcx), %r9
cmpl %ebp, -0x24(%r9)
je 0x3b833
cmpl %ebp, -0x10(%r9)
je 0x3b839
cmpl %ebp, 0x4(%r9)
je 0x3b843
cmpl %ebp, 0x18(%r9)
je 0x3b83f
decq %rdi
addq $0x50, %r9
cmpq $0x1, %rdi
jg 0x3b7ca
movq %rax, %r8
subq %r10, %r8
sarq $0x2, %r8
imulq %rsi, %r8
cmpq $0x1, %r8
je 0x3b826
cmpq $0x2, %r8
je 0x3b81c
movq %rax, %r9
cmpq $0x3, %r8
jne 0x3b843
cmpl %ebp, 0x4(%r10)
je 0x3b82e
addq $0x14, %r10
cmpl %ebp, 0x4(%r10)
je 0x3b82e
addq $0x14, %r10
cmpl %ebp, 0x4(%r10)
cmovneq %rax, %r10
movq %r10, %r9
jmp 0x3b843
addq $-0x28, %r9
jmp 0x3b843
addq $-0x14, %r9
jmp 0x3b843
addq $0x14, %r9
cmpq %rax, %rdx
jne 0x3b8f1
cmpq %rax, %r9
jne 0x3b8f1
movq 0x1d8(%r14), %rdx
movq 0x1e0(%r14), %rax
movq %rax, %r8
subq %rdx, %r8
movq %r8, %rdi
sarq $0x2, %rdi
movabsq $-0x5555555555555555, %rsi # imm = 0xAAAAAAAAAAAAAAAB
imulq %rsi, %rdi
sarq $0x2, %rdi
testq %rdi, %rdi
jle 0x3ba64
leaq (%rdi,%rdi,2), %rcx
shlq $0x4, %rcx
addq %rdx, %rcx
incq %rdi
addq $0x18, %rdx
cmpl %r15d, -0x14(%rdx)
jne 0x3b8ac
cmpl %ebp, -0x10(%rdx)
je 0x3bab6
cmpl %r15d, -0x8(%rdx)
jne 0x3b8bb
cmpl %ebp, -0x4(%rdx)
je 0x3babc
cmpl %r15d, 0x4(%rdx)
jne 0x3b8ca
cmpl %ebp, 0x8(%rdx)
je 0x3bac6
cmpl %r15d, 0x10(%rdx)
jne 0x3b8d9
cmpl %ebp, 0x14(%rdx)
je 0x3bac2
decq %rdi
addq $0x30, %rdx
cmpq $0x1, %rdi
jg 0x3b89d
movq %rax, %r8
subq %rcx, %r8
jmp 0x3ba67
cmpq %rax, %rdx
je 0x3b907
movq %rdx, %rsi
subq %rcx, %rsi
shrq $0x2, %rsi
imull $0xcccccccd, %esi, %r15d # imm = 0xCCCCCCCD
cmpq %rax, %r9
je 0x3b91e
subq %rcx, %r9
shrq $0x2, %r9
imull $0xcccccccd, %r9d, %ebp # imm = 0xCCCCCCCD
xorl %esi, %esi
jmp 0x3b921
movb $0x1, %sil
cmpq %rax, %rdx
sete %dl
movq 0x148(%r14), %rax
movq 0x80(%rax), %rdi
movq 0x88(%rax), %rax
movq %rax, %r9
subq %rdi, %r9
movq %r9, %r8
sarq $0x6, %r8
testq %r8, %r8
jle 0x3b9e0
andq $-0x40, %r9
movq %r9, %rcx
addq %rdi, %rcx
incq %r8
addq $0x20, %rdi
cmpb %dl, -0x14(%rdi)
jne 0x3b97d
cmpb %sil, -0x13(%rdi)
jne 0x3b97d
cmpl %r15d, -0x1c(%rdi)
jne 0x3b97d
cmpl %ebp, -0x18(%rdi)
je 0x3baf4
cmpb %dl, -0x4(%rdi)
jne 0x3b997
cmpb %sil, -0x3(%rdi)
jne 0x3b997
cmpl %r15d, -0xc(%rdi)
jne 0x3b997
cmpl %ebp, -0x8(%rdi)
je 0x3bafa
cmpb %dl, 0xc(%rdi)
jne 0x3b9b1
cmpb %sil, 0xd(%rdi)
jne 0x3b9b1
cmpl %r15d, 0x4(%rdi)
jne 0x3b9b1
cmpl %ebp, 0x8(%rdi)
je 0x3bb04
cmpb %dl, 0x1c(%rdi)
jne 0x3b9cb
cmpb %sil, 0x1d(%rdi)
jne 0x3b9cb
cmpl %r15d, 0x14(%rdi)
jne 0x3b9cb
cmpl %ebp, 0x18(%rdi)
je 0x3bb00
decq %r8
addq $0x40, %rdi
cmpq $0x1, %r8
jg 0x3b963
movq %rax, %r9
subq %rcx, %r9
jmp 0x3b9e3
movq %rdi, %rcx
sarq $0x4, %r9
cmpq $0x1, %r9
je 0x3ba39
cmpq $0x2, %r9
je 0x3ba1b
cmpq $0x3, %r9
jne 0x3bbd6
cmpb %dl, 0xc(%rcx)
jne 0x3ba17
cmpb %sil, 0xd(%rcx)
jne 0x3ba17
cmpl %r15d, 0x4(%rcx)
jne 0x3ba17
cmpl %ebp, 0x8(%rcx)
je 0x3bb07
addq $0x10, %rcx
cmpb %dl, 0xc(%rcx)
jne 0x3ba35
cmpb %sil, 0xd(%rcx)
jne 0x3ba35
cmpl %r15d, 0x4(%rcx)
jne 0x3ba35
cmpl %ebp, 0x8(%rcx)
je 0x3bb07
addq $0x10, %rcx
cmpb %dl, 0xc(%rcx)
jne 0x3bbd6
cmpb %sil, 0xd(%rcx)
jne 0x3bbd6
cmpl %r15d, 0x4(%rcx)
jne 0x3bbd6
cmpl %ebp, 0x8(%rcx)
je 0x3bb07
jmp 0x3bbd6
movq %rdx, %rcx
sarq $0x2, %r8
imulq %rsi, %r8
cmpq $0x1, %r8
je 0x3baa3
cmpq $0x2, %r8
je 0x3ba94
cmpq $0x3, %r8
jne 0x3bc3c
cmpl %r15d, 0x4(%rcx)
jne 0x3ba90
cmpl %ebp, 0x8(%rcx)
je 0x3bab1
addq $0xc, %rcx
cmpl %r15d, 0x4(%rcx)
jne 0x3ba9f
cmpl %ebp, 0x8(%rcx)
je 0x3bab1
addq $0xc, %rcx
xorl 0x4(%rcx), %r15d
xorl 0x8(%rcx), %ebp
orl %r15d, %ebp
cmovneq %rax, %rcx
movq %rcx, %rdx
jmp 0x3bac6
addq $-0x18, %rdx
jmp 0x3bac6
addq $-0xc, %rdx
jmp 0x3bac6
addq $0xc, %rdx
cmpq %rax, %rdx
je 0x3bc3c
movl (%rdx), %edx
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x33f8a
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
leaq 0x8(%rsp), %rdi
callq 0x60b0
jmp 0x3bb33
addq $-0x20, %rdi
jmp 0x3bb04
addq $-0x10, %rdi
jmp 0x3bb04
addq $0x10, %rdi
movq %rdi, %rcx
cmpq %rax, %rcx
je 0x3bbd6
movl (%rcx), %edx
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x33f8a
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
leaq 0x8(%rsp), %rdi
callq 0x60b0
leaq 0x10(%rbx), %rdx
movq %rdx, (%rbx)
movq (%rax), %rsi
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rsi
je 0x3bb55
movq %rsi, (%rbx)
movq (%rcx), %rdx
movq %rdx, 0x10(%rbx)
jmp 0x3bb5b
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rbx)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3bb8d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x3bba9
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3bbc4
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6260
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x6140
movq %rax, %r14
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x7c84f(%rip), %rsi     # 0xb8442
leaq 0x7c8c1(%rip), %rdx     # 0xb84bb
leaq 0x8(%rsp), %rdi
callq 0x7be0
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x6320
leaq 0xc01ad(%rip), %rax     # 0xfbdc8
addq $0x10, %rax
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0xc0185(%rip), %rsi     # 0xfbdb0
movq 0xc13a6(%rip), %rdx     # 0xfcfd8
movq %r14, %rdi
callq 0x6470
jmp 0x3bca0
movl $0x10, %edi
callq 0x6140
movq %rax, %r14
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x7c863(%rip), %rsi     # 0xb84bc
leaq 0x7c8cb(%rip), %rdx     # 0xb852b
leaq 0x8(%rsp), %rdi
callq 0x7be0
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x6320
leaq 0xc0147(%rip), %rax     # 0xfbdc8
addq $0x10, %rax
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0xc011f(%rip), %rsi     # 0xfbdb0
movq 0xc1340(%rip), %rdx     # 0xfcfd8
movq %r14, %rdi
callq 0x6470
jmp 0x3bcd3
jmp 0x3bcf4
jmp 0x3bca8
jmp 0x3bcce
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3bcff
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x3bcff
jmp 0x3bcce
jmp 0x3bcce
jmp 0x3bcce
movq %rax, %rbx
jmp 0x3bcff
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x3bced
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
testb %bpl, %bpl
jne 0x3bcf7
jmp 0x3bcff
movq %rax, %rbx
movq %r14, %rdi
callq 0x6200
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x3bd1b
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3bd36
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6260
movq %rbx, %rdi
callq 0x64a0