// File: /workspace/github_cpp_makefile_star2_O1/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 0x345e6
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 0x3bed1
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 0x3bed1
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x148(%r14), %r13
movq %r14, %rdi
movl %r15d, %esi
callq 0x12cda
movq %rax, %r12
movq %r14, %rdi
movl %ebp, %esi
callq 0x12cda
testq %r12, %r12
je 0x3befa
movl 0x8(%r12), %r15d
testq %rax, %rax
je 0x3bf02
movl 0x8(%rax), %ebp
movq 0x18(%r13), %rcx
movq 0x20(%r13), %rax
movq %rax, %rdi
subq %rcx, %rdi
sarq $0x2, %rdi
movabsq $-0x3333333333333333, %rsi # imm = 0xCCCCCCCCCCCCCCCD
imulq %rsi, %rdi
sarq $0x2, %rdi
leaq (%rdi,%rdi,4), %r8
movq %rcx, %r9
testq %rdi, %rdi
jle 0x3bf69
movq %r8, %r9
shlq $0x4, %r9
addq %rcx, %r9
leaq 0x1(%rdi), %r10
leaq 0x28(%rcx), %rdx
cmpl %r15d, -0x24(%rdx)
je 0x3bfad
cmpl %r15d, -0x10(%rdx)
je 0x3bfb3
cmpl %r15d, 0x4(%rdx)
je 0x3bfbd
cmpl %r15d, 0x18(%rdx)
je 0x3bfb9
decq %r10
addq $0x50, %rdx
cmpq $0x1, %r10
jg 0x3bf44
movq %rax, %r10
subq %r9, %r10
sarq $0x2, %r10
imulq %rsi, %r10
cmpq $0x1, %r10
je 0x3bfa0
cmpq $0x2, %r10
je 0x3bf96
movq %rax, %rdx
cmpq $0x3, %r10
jne 0x3bfbd
cmpl %r15d, 0x4(%r9)
je 0x3bfa8
addq $0x14, %r9
cmpl %r15d, 0x4(%r9)
je 0x3bfa8
addq $0x14, %r9
cmpl %r15d, 0x4(%r9)
cmovneq %rax, %r9
movq %r9, %rdx
jmp 0x3bfbd
addq $-0x28, %rdx
jmp 0x3bfbd
addq $-0x14, %rdx
jmp 0x3bfbd
addq $0x14, %rdx
movq %rcx, %r9
testq %rdi, %rdi
jle 0x3bffb
shlq $0x4, %r8
movq %r8, %r9
addq %rcx, %r9
incq %rdi
leaq 0x28(%rcx), %r8
cmpl %ebp, -0x24(%r8)
je 0x3c03f
cmpl %ebp, -0x10(%r8)
je 0x3c045
cmpl %ebp, 0x4(%r8)
je 0x3c04f
cmpl %ebp, 0x18(%r8)
je 0x3c04b
decq %rdi
addq $0x50, %r8
cmpq $0x1, %rdi
jg 0x3bfd6
movq %rax, %rdi
subq %r9, %rdi
sarq $0x2, %rdi
imulq %rsi, %rdi
cmpq $0x1, %rdi
je 0x3c032
cmpq $0x2, %rdi
je 0x3c028
movq %rax, %r8
cmpq $0x3, %rdi
jne 0x3c04f
cmpl %ebp, 0x4(%r9)
je 0x3c03a
addq $0x14, %r9
cmpl %ebp, 0x4(%r9)
je 0x3c03a
addq $0x14, %r9
cmpl %ebp, 0x4(%r9)
cmovneq %rax, %r9
movq %r9, %r8
jmp 0x3c04f
addq $-0x28, %r8
jmp 0x3c04f
addq $-0x14, %r8
jmp 0x3c04f
addq $0x14, %r8
cmpq %rax, %rdx
jne 0x3c14c
cmpq %rax, %r8
jne 0x3c14c
movq 0x1d8(%r14), %rcx
movq 0x1e0(%r14), %rax
movq %rax, %rdi
subq %rcx, %rdi
sarq $0x2, %rdi
movabsq $-0x5555555555555555, %rsi # imm = 0xAAAAAAAAAAAAAAAB
imulq %rsi, %rdi
sarq $0x2, %rdi
testq %rdi, %rdi
jle 0x3c0f1
leaq (%rdi,%rdi,2), %r8
shlq $0x4, %r8
addq %rcx, %r8
incq %rdi
addq $0x18, %rcx
movq %rcx, %rdx
cmpl %r15d, -0x14(%rdx)
jne 0x3c0b4
cmpl %ebp, -0x10(%rdx)
je 0x3c2ab
cmpl %r15d, -0x8(%rdx)
jne 0x3c0c3
cmpl %ebp, -0x4(%rdx)
je 0x3c2b1
cmpl %r15d, 0x4(%rdx)
jne 0x3c0d2
cmpl %ebp, 0x8(%rdx)
je 0x3c2bb
cmpl %r15d, 0x10(%rdx)
jne 0x3c0e1
cmpl %ebp, 0x14(%rdx)
je 0x3c2b7
decq %rdi
addq $0x30, %rdx
cmpq $0x1, %rdi
jg 0x3c0a5
movq %r8, %rcx
movq %rax, %rdi
subq %rcx, %rdi
sarq $0x2, %rdi
imulq %rsi, %rdi
cmpq $0x1, %rdi
je 0x3c136
cmpq $0x2, %rdi
je 0x3c127
movq %rax, %rdx
cmpq $0x3, %rdi
jne 0x3c2bb
cmpl %r15d, 0x4(%rcx)
jne 0x3c123
cmpl %ebp, 0x8(%rcx)
je 0x3c144
addq $0xc, %rcx
cmpl %r15d, 0x4(%rcx)
jne 0x3c132
cmpl %ebp, 0x8(%rcx)
je 0x3c144
addq $0xc, %rcx
xorl 0x4(%rcx), %r15d
xorl 0x8(%rcx), %ebp
orl %r15d, %ebp
cmovneq %rax, %rcx
movq %rcx, %rdx
jmp 0x3c2bb
cmpq %rax, %rdx
je 0x3c162
movq %rdx, %rsi
subq %rcx, %rsi
shrq $0x2, %rsi
imull $0xcccccccd, %esi, %r15d # imm = 0xCCCCCCCD
cmpq %rax, %r8
je 0x3c179
subq %rcx, %r8
shrq $0x2, %r8
imull $0xcccccccd, %r8d, %ebp # imm = 0xCCCCCCCD
xorl %ecx, %ecx
jmp 0x3c17b
movb $0x1, %cl
cmpq %rax, %rdx
sete %dl
movq 0x148(%r14), %rax
movq 0x80(%rax), %rdi
movq 0x88(%rax), %rax
movq %rax, %r8
subq %rdi, %r8
movq %r8, %r9
sarq $0x6, %r9
testq %r9, %r9
jle 0x3c231
andq $-0x40, %r8
addq %rdi, %r8
incq %r9
addq $0x20, %rdi
movq %rdi, %rsi
cmpb %dl, -0x14(%rsi)
jne 0x3c1d6
cmpb %cl, -0x13(%rsi)
jne 0x3c1d6
cmpl %r15d, -0x1c(%rsi)
jne 0x3c1d6
cmpl %ebp, -0x18(%rsi)
je 0x3c2e9
cmpb %dl, -0x4(%rsi)
jne 0x3c1ef
cmpb %cl, -0x3(%rsi)
jne 0x3c1ef
cmpl %r15d, -0xc(%rsi)
jne 0x3c1ef
cmpl %ebp, -0x8(%rsi)
je 0x3c2ef
cmpb %dl, 0xc(%rsi)
jne 0x3c208
cmpb %cl, 0xd(%rsi)
jne 0x3c208
cmpl %r15d, 0x4(%rsi)
jne 0x3c208
cmpl %ebp, 0x8(%rsi)
je 0x3c2f9
cmpb %dl, 0x1c(%rsi)
jne 0x3c221
cmpb %cl, 0x1d(%rsi)
jne 0x3c221
cmpl %r15d, 0x14(%rsi)
jne 0x3c221
cmpl %ebp, 0x18(%rsi)
je 0x3c2f5
decq %r9
addq $0x40, %rsi
cmpq $0x1, %r9
jg 0x3c1bd
movq %r8, %rdi
movq %rax, %r8
subq %rdi, %r8
sarq $0x4, %r8
cmpq $0x1, %r8
je 0x3c286
cmpq $0x2, %r8
je 0x3c26d
movq %rax, %rsi
cmpq $0x3, %r8
jne 0x3c2f9
cmpb %dl, 0xc(%rdi)
jne 0x3c269
cmpb %cl, 0xd(%rdi)
jne 0x3c269
cmpl %r15d, 0x4(%rdi)
jne 0x3c269
cmpl %ebp, 0x8(%rdi)
je 0x3c2a6
addq $0x10, %rdi
cmpb %dl, 0xc(%rdi)
jne 0x3c282
cmpb %cl, 0xd(%rdi)
jne 0x3c282
cmpl %r15d, 0x4(%rdi)
jne 0x3c282
cmpl %ebp, 0x8(%rdi)
je 0x3c2a6
addq $0x10, %rdi
movq %rax, %rsi
cmpb %dl, 0xc(%rdi)
jne 0x3c2f9
movq %rax, %rsi
cmpb %cl, 0xd(%rdi)
jne 0x3c2f9
movq %rax, %rsi
cmpl %r15d, 0x4(%rdi)
jne 0x3c2f9
cmpl %ebp, 0x8(%rdi)
cmovneq %rax, %rdi
movq %rdi, %rsi
jmp 0x3c2f9
addq $-0x18, %rdx
jmp 0x3c2bb
addq $-0xc, %rdx
jmp 0x3c2bb
addq $0xc, %rdx
cmpq %rax, %rdx
je 0x3c42e
movl (%rdx), %edx
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x345e6
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
leaq 0x8(%rsp), %rdi
callq 0x60b0
jmp 0x3c325
addq $-0x20, %rsi
jmp 0x3c2f9
addq $-0x10, %rsi
jmp 0x3c2f9
addq $0x10, %rsi
cmpq %rax, %rsi
je 0x3c3c8
movl (%rsi), %edx
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x345e6
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 0x3c347
movq %rsi, (%rbx)
movq (%rcx), %rdx
movq %rdx, 0x10(%rbx)
jmp 0x3c34d
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 0x3c37f
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x3c39b
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3c3b6
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 0x7d06d(%rip), %rsi     # 0xb9452
leaq 0x7d0df(%rip), %rdx     # 0xb94cb
leaq 0x8(%rsp), %rdi
callq 0x7c64
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x6320
leaq 0xc098b(%rip), %rax     # 0xfcd98
addq $0x10, %rax
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0xc0963(%rip), %rsi     # 0xfcd80
movq 0xc1bb4(%rip), %rdx     # 0xfdfd8
movq %r14, %rdi
callq 0x6470
jmp 0x3c492
movl $0x10, %edi
callq 0x6140
movq %rax, %r14
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x7d081(%rip), %rsi     # 0xb94cc
leaq 0x7d0e9(%rip), %rdx     # 0xb953b
leaq 0x8(%rsp), %rdi
callq 0x7c64
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x6320
leaq 0xc0925(%rip), %rax     # 0xfcd98
addq $0x10, %rax
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0xc08fd(%rip), %rsi     # 0xfcd80
movq 0xc1b4e(%rip), %rdx     # 0xfdfd8
movq %r14, %rdi
callq 0x6470
jmp 0x3c496
jmp 0x3c4b2
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x3c4b8
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x3c4b8
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x3c4f4
movq %r14, %rdi
callq 0x6200
jmp 0x3c4f4
jmp 0x3c4c9
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3c4f4
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x3c4f4
jmp 0x3c4f1
jmp 0x3c4f1
jmp 0x3c4f1
jmp 0x3c4f1
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x3c510
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3c52b
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6260
movq %rbx, %rdi
callq 0x64a0
nop