// File: /workspace/github_cpp_makefile_star2_O1/rossy[P]crossc/SPIRV-Cross/spirv_cross.cpp
// Function: spirv_cross::Compiler::CombinedImageSamplerHandler::register_combined_image_sampler(spirv_cross::SPIRFunction&, unsigned int, unsigned int, bool)
void Compiler::CombinedImageSamplerHandler::register_combined_image_sampler(SPIRFunction &caller, uint32_t image_id,
                                                                            uint32_t sampler_id, bool depth)
{
	// We now have a texture ID and a sampler ID which will either be found as a global
	// or a parameter in our own function. If both are global, they will not need a parameter,
	// otherwise, add it to our list.
	SPIRFunction::CombinedImageSamplerParameter param = {
		0u, image_id, sampler_id, true, true, depth,
	};

	auto texture_itr = find_if(begin(caller.arguments), end(caller.arguments),
	                           [image_id](const SPIRFunction::Parameter &p) { return p.id == image_id; });
	auto sampler_itr = find_if(begin(caller.arguments), end(caller.arguments),
	                           [sampler_id](const SPIRFunction::Parameter &p) { return p.id == sampler_id; });

	if (texture_itr != end(caller.arguments))
	{
		param.global_image = false;
		param.image_id = uint32_t(texture_itr - begin(caller.arguments));
	}

	if (sampler_itr != end(caller.arguments))
	{
		param.global_sampler = false;
		param.sampler_id = uint32_t(sampler_itr - begin(caller.arguments));
	}

	if (param.global_image && param.global_sampler)
		return;

	auto itr = find_if(begin(caller.combined_parameters), end(caller.combined_parameters),
	                   [&param](const SPIRFunction::CombinedImageSamplerParameter &p) {
		                   return param.image_id == p.image_id && param.sampler_id == p.sampler_id &&
		                          param.global_image == p.global_image && param.global_sampler == p.global_sampler;
	                   });

	if (itr == end(caller.combined_parameters))
	{
		uint32_t id = compiler.ir.increase_bound_by(3);
		auto type_id = id + 0;
		auto ptr_type_id = id + 1;
		auto combined_id = id + 2;
		auto &base = compiler.expression_type(image_id);
		auto &type = compiler.set<SPIRType>(type_id);
		auto &ptr_type = compiler.set<SPIRType>(ptr_type_id);

		type = base;
		type.self = type_id;
		type.basetype = SPIRType::SampledImage;
		type.pointer = false;
		type.storage = StorageClassGeneric;
		type.image.depth = depth;

		ptr_type = type;
		ptr_type.pointer = true;
		ptr_type.storage = StorageClassUniformConstant;

		// Build new variable.
		compiler.set<SPIRVariable>(combined_id, ptr_type_id, StorageClassFunction, 0);

		// Inherit RelaxedPrecision (and potentially other useful flags if deemed relevant).
		auto &new_flags = compiler.ir.meta[combined_id].decoration.decoration_flags;
		auto &old_flags = compiler.ir.meta[sampler_id].decoration.decoration_flags;
		new_flags.reset();
		if (old_flags.get(DecorationRelaxedPrecision))
			new_flags.set(DecorationRelaxedPrecision);

		param.id = combined_id;

		compiler.set_name(combined_id,
		                  join("SPIRV_Cross_Combined", compiler.to_name(image_id), compiler.to_name(sampler_id)));

		caller.combined_parameters.push_back(param);
		caller.shadow_arguments.push_back({ ptr_type_id, combined_id, 0u, 0u, true });
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movl %ecx, %ebp
movl %edx, %r15d
movq %rdi, %r14
movl $0x0, 0x4(%rsp)
movl %edx, 0x8(%rsp)
movl %ecx, 0xc(%rsp)
movw $0x101, 0x10(%rsp)      # imm = 0x101
movb %r8b, 0x12(%rsp)
movq 0x18(%rsi), %rax
movq 0x20(%rsi), %rcx
movq %rcx, %rdi
subq %rax, %rdi
sarq $0x2, %rdi
movabsq $-0x3333333333333333, %r11 # imm = 0xCCCCCCCCCCCCCCCD
imulq %r11, %rdi
sarq $0x2, %rdi
leaq (%rdi,%rdi,4), %rbx
movq %rax, %r9
testq %rdi, %rdi
jle 0x172fc
movq %rbx, %r9
shlq $0x4, %r9
addq %rax, %r9
leaq 0x1(%rdi), %r10
leaq 0x28(%rax), %rdx
cmpl %r15d, -0x24(%rdx)
je 0x17340
cmpl %r15d, -0x10(%rdx)
je 0x17346
cmpl %r15d, 0x4(%rdx)
je 0x17350
cmpl %r15d, 0x18(%rdx)
je 0x1734c
decq %r10
addq $0x50, %rdx
cmpq $0x1, %r10
jg 0x172d7
movq %rcx, %r10
subq %r9, %r10
sarq $0x2, %r10
imulq %r11, %r10
cmpq $0x1, %r10
je 0x17333
cmpq $0x2, %r10
je 0x17329
movq %rcx, %rdx
cmpq $0x3, %r10
jne 0x17350
cmpl %r15d, 0x4(%r9)
je 0x1733b
addq $0x14, %r9
cmpl %r15d, 0x4(%r9)
je 0x1733b
addq $0x14, %r9
cmpl %r15d, 0x4(%r9)
cmovneq %rcx, %r9
movq %r9, %rdx
jmp 0x17350
addq $-0x28, %rdx
jmp 0x17350
addq $-0x14, %rdx
jmp 0x17350
addq $0x14, %rdx
movq %rax, %r9
testq %rdi, %rdi
jle 0x1738e
shlq $0x4, %rbx
movq %rbx, %r9
addq %rax, %r9
incq %rdi
leaq 0x28(%rax), %r10
cmpl %ebp, -0x24(%r10)
je 0x173d2
cmpl %ebp, -0x10(%r10)
je 0x173d8
cmpl %ebp, 0x4(%r10)
je 0x173e2
cmpl %ebp, 0x18(%r10)
je 0x173de
decq %rdi
addq $0x50, %r10
cmpq $0x1, %rdi
jg 0x17369
movq %rcx, %rdi
subq %r9, %rdi
sarq $0x2, %rdi
imulq %r11, %rdi
cmpq $0x1, %rdi
je 0x173c5
cmpq $0x2, %rdi
je 0x173bb
movq %rcx, %r10
cmpq $0x3, %rdi
jne 0x173e2
cmpl %ebp, 0x4(%r9)
je 0x173cd
addq $0x14, %r9
cmpl %ebp, 0x4(%r9)
je 0x173cd
addq $0x14, %r9
cmpl %ebp, 0x4(%r9)
cmovneq %rcx, %r9
movq %r9, %r10
jmp 0x173e2
addq $-0x28, %r10
jmp 0x173e2
addq $-0x14, %r10
jmp 0x173e2
addq $0x14, %r10
cmpq %rcx, %rdx
je 0x173fd
movb $0x0, 0x10(%rsp)
subq %rax, %rdx
shrq $0x2, %rdx
imull $0xcccccccd, %edx, %edx # imm = 0xCCCCCCCD
movl %edx, 0x8(%rsp)
cmpq %rcx, %r10
je 0x17419
movb $0x0, 0x11(%rsp)
subq %rax, %r10
shrq $0x2, %r10
imull $0xcccccccd, %r10d, %eax # imm = 0xCCCCCCCD
movl %eax, 0xc(%rsp)
movb 0x10(%rsp), %cl
cmpb $0x1, %cl
jne 0x1742d
cmpb $0x0, 0x11(%rsp)
jne 0x17932
movq 0x80(%rsi), %rdx
movq 0x88(%rsi), %rax
movq %rax, %rdi
subq %rdx, %rdi
movq %rdi, %r12
sarq $0x6, %r12
testq %r12, %r12
jle 0x174ed
movl 0x8(%rsp), %r9d
movl 0xc(%rsp), %r10d
andq $-0x40, %rdi
addq %rdx, %rdi
movb 0x11(%rsp), %r11b
incq %r12
addq $0x20, %rdx
movq %rdx, %rbx
cmpl -0x1c(%rbx), %r9d
jne 0x1748c
cmpl -0x18(%rbx), %r10d
jne 0x1748c
cmpb -0x14(%rbx), %cl
jne 0x1748c
cmpb -0x13(%rbx), %r11b
je 0x1758c
cmpl -0xc(%rbx), %r9d
jne 0x174a7
cmpl -0x8(%rbx), %r10d
jne 0x174a7
cmpb -0x4(%rbx), %cl
jne 0x174a7
cmpb -0x3(%rbx), %r11b
je 0x17592
cmpl 0x4(%rbx), %r9d
jne 0x174c2
cmpl 0x8(%rbx), %r10d
jne 0x174c2
cmpb 0xc(%rbx), %cl
jne 0x174c2
cmpb 0xd(%rbx), %r11b
je 0x1759c
cmpl 0x14(%rbx), %r9d
jne 0x174dd
cmpl 0x18(%rbx), %r10d
jne 0x174dd
cmpb 0x1c(%rbx), %cl
jne 0x174dd
cmpb 0x1d(%rbx), %r11b
je 0x17598
decq %r12
addq $0x40, %rbx
cmpq $0x1, %r12
jg 0x17471
movq %rdi, %rdx
movq %rax, %rdi
subq %rdx, %rdi
sarq $0x4, %rdi
cmpq $0x1, %rdi
je 0x1755c
cmpq $0x2, %rdi
je 0x17536
movq %rax, %rbx
cmpq $0x3, %rdi
jne 0x1759c
movl 0x8(%rsp), %edi
cmpl 0x4(%rdx), %edi
jne 0x17532
movl 0xc(%rsp), %edi
cmpl 0x8(%rdx), %edi
jne 0x17532
cmpb 0xc(%rdx), %cl
jne 0x17532
movb 0x11(%rsp), %dil
cmpb 0xd(%rdx), %dil
je 0x17587
addq $0x10, %rdx
movl 0x8(%rsp), %edi
cmpl 0x4(%rdx), %edi
jne 0x17558
movl 0xc(%rsp), %edi
cmpl 0x8(%rdx), %edi
jne 0x17558
cmpb 0xc(%rdx), %cl
jne 0x17558
movb 0x11(%rsp), %dil
cmpb 0xd(%rdx), %dil
je 0x17587
addq $0x10, %rdx
movl 0x8(%rsp), %edi
movq %rax, %rbx
cmpl 0x4(%rdx), %edi
jne 0x1759c
movl 0xc(%rsp), %edi
movq %rax, %rbx
cmpl 0x8(%rdx), %edi
jne 0x1759c
movq %rax, %rbx
cmpb 0xc(%rdx), %cl
jne 0x1759c
movb 0x11(%rsp), %cl
cmpb 0xd(%rdx), %cl
cmovneq %rax, %rdx
movq %rdx, %rbx
jmp 0x1759c
addq $-0x20, %rbx
jmp 0x1759c
addq $-0x10, %rbx
jmp 0x1759c
addq $0x10, %rbx
cmpq %rax, %rbx
jne 0x17932
movl %r8d, 0x24(%rsp)
movq %rsi, 0x48(%rsp)
movq 0x8(%r14), %rdi
addq $0x8, %rdi
movl $0x3, %esi
callq 0x2561c
movl %eax, %r12d
movl %eax, 0x20(%rsp)
leal 0x1(%r12), %eax
movl %eax, 0x14(%rsp)
movq 0x8(%r14), %rbx
movq %rbx, %rdi
movl %r15d, %esi
callq 0x13116
movq %rbx, %rdi
movl %eax, %esi
callq 0x1b9de
movq %rax, %rbx
movq 0x8(%r14), %rdi
movq %r12, 0x18(%rsp)
movl %r12d, %esi
callq 0x1c15a
movq %rax, %r12
movq %r14, 0x70(%rsp)
movq 0x8(%r14), %rdi
movl 0x14(%rsp), %esi
callq 0x1c15a
movq %rax, %r14
movl 0x8(%rbx), %eax
movl %eax, 0x8(%r12)
leaq 0xc(%r12), %rax
movq %rax, 0x58(%rsp)
movups 0xc(%rbx), %xmm0
movups %xmm0, 0xc(%r12)
leaq 0x20(%r12), %rdi
leaq 0x20(%rbx), %rsi
movq %rdi, 0x68(%rsp)
callq 0x1c2c2
leaq 0x38(%r12), %rdi
leaq 0x38(%rbx), %rsi
movq %rdi, 0x60(%rsp)
callq 0x1c398
movq 0x60(%rbx), %rax
movq %rax, 0x60(%r12)
leaq 0x68(%r12), %rdi
leaq 0x68(%rbx), %rsi
movq %rdi, 0x50(%rsp)
callq 0x1c2c2
leaq 0x80(%r12), %r13
movups 0x80(%rbx), %xmm0
movups 0x90(%rbx), %xmm1
movups %xmm0, 0x80(%r12)
movups %xmm1, 0x90(%r12)
cmpq %r12, %rbx
je 0x176b5
movl $0xa0, %eax
leaq (%r12,%rax), %rdi
addq %rax, %rbx
movq %rbx, %rsi
callq 0xd5d6
movq 0x18(%rsp), %rax
addl $0x2, %eax
movq %rax, 0x18(%rsp)
movl 0x20(%rsp), %ecx
movl %ecx, 0x8(%r12)
movl $0xe, 0xc(%r12)
movb $0x0, 0x60(%r12)
movl $0x8, 0x64(%r12)
movl 0x24(%rsp), %eax
movb %al, 0x88(%r12)
movl %ecx, 0x8(%r14)
movq 0x58(%rsp), %rax
movups (%rax), %xmm0
movups %xmm0, 0xc(%r14)
leaq 0x20(%r14), %rdi
movq 0x68(%rsp), %rsi
callq 0x1c2c2
leaq 0x38(%r14), %rdi
movq 0x60(%rsp), %rsi
callq 0x1c398
movq 0x60(%r12), %rax
movq %rax, 0x60(%r14)
leaq 0x68(%r14), %rdi
movq 0x50(%rsp), %rsi
callq 0x1c2c2
movups (%r13), %xmm0
movups 0x10(%r13), %xmm1
movups %xmm0, 0x80(%r14)
movups %xmm1, 0x90(%r14)
cmpq %r14, %r12
je 0x17768
movl $0xa0, %eax
movq %r14, %rdi
addq %rax, %rdi
addq %rax, %r12
movq %r12, %rsi
callq 0xd5d6
movb $0x1, 0x60(%r14)
xorl %eax, %eax
movl %eax, 0x64(%r14)
movq 0x70(%rsp), %r13
movq 0x8(%r13), %rdi
leaq 0x28(%rsp), %rcx
movl $0x7, (%rcx)
leaq 0x78(%rsp), %r8
movl %eax, (%r8)
leaq 0x14(%rsp), %rdx
movq 0x18(%rsp), %rbx
movl %ebx, %esi
callq 0x1c196
movq 0x8(%r13), %rax
movl %ebx, %ecx
movq 0x38(%rax), %rbx
imulq $0x148, %rcx, %r14      # imm = 0x148
movl %ebp, %eax
imulq $0x148, %rax, %r12      # imm = 0x148
leaq (%rbx,%r14), %rdi
addq $0x68, %rdi
movq $0x0, -0x8(%rdi)
callq 0xd540
testb $0x1, 0x60(%rbx,%r12)
je 0x177e2
leaq (%rbx,%r14), %rax
addq $0x60, %rax
orb $0x1, (%rax)
movq 0x18(%rsp), %r14
movl %r14d, 0x4(%rsp)
movq 0x8(%r13), %rbx
movq (%rbx), %rax
leaq 0x78(%rsp), %rdi
movq %rbx, %rsi
movl %r15d, %edx
movl $0x1, %ecx
callq *0x38(%rax)
movq 0x8(%r13), %rsi
movq (%rsi), %rax
leaq 0x98(%rsp), %rdi
movl %ebp, %edx
movl $0x1, %ecx
callq *0x38(%rax)
leaq 0x9e72a(%rip), %rsi     # 0xb5f50
leaq 0x28(%rsp), %rdi
leaq 0x78(%rsp), %rdx
leaq 0x98(%rsp), %rcx
callq 0x1c1dd
addq $0x8, %rbx
leaq 0x28(%rsp), %rdx
movq %rbx, %rdi
movl %r14d, %esi
callq 0x2464c
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
movq 0x48(%rsp), %rbx
je 0x17871
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x17892
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x178b3
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x88(%rbx), %rsi
cmpq 0x90(%rbx), %rsi
je 0x178d5
movups 0x4(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x10, 0x88(%rbx)
jmp 0x178e6
leaq 0x80(%rbx), %rdi
leaq 0x4(%rsp), %rdx
callq 0x23104
movl 0x14(%rsp), %eax
movl %eax, 0x28(%rsp)
movl %r14d, 0x2c(%rsp)
movq $0x0, 0x30(%rsp)
movb $0x1, 0x38(%rsp)
movq 0x38(%rbx), %rsi
cmpq 0x40(%rbx), %rsi
je 0x17921
movl 0x38(%rsp), %eax
movl %eax, 0x10(%rsi)
movups 0x28(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x14, 0x38(%rbx)
jmp 0x17932
addq $0x30, %rbx
leaq 0x28(%rsp), %rdx
movq %rbx, %rdi
callq 0x1fe7c
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x17967
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x17967
movq %rax, %rbx
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1798d
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x1798d
movq %rax, %rbx
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x179ae
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x6260
movq %rbx, %rdi
callq 0x64a0