// File: /workspace/github_cpp_makefile_star2_O3/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 %edx, %r15d
movq %rdi, 0x20(%rsp)
movl $0x0, 0x10(%rsp)
movl %edx, 0x14(%rsp)
movl %ecx, 0x18(%rsp)
movw $0x101, 0x1c(%rsp)      # imm = 0x101
movb %r8b, 0x1e(%rsp)
movq 0x18(%rsi), %rax
movq 0x20(%rsi), %r14
movq %r14, %rdi
subq %rax, %rdi
movq %rdi, %rbx
sarq $0x2, %rbx
movabsq $-0x3333333333333333, %rdx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rdx, %rbx
sarq $0x2, %rbx
leaq (%rbx,%rbx,4), %r9
movq %rdi, %r11
movq %rax, %r10
testq %rbx, %rbx
jle 0x16e9c
movq %r9, %r10
shlq $0x4, %r10
addq %rax, %r10
leaq 0x1(%rbx), %r11
leaq 0x28(%rax), %r12
cmpl %r15d, -0x24(%r12)
je 0x16eda
cmpl %r15d, -0x10(%r12)
je 0x16ee0
cmpl %r15d, 0x4(%r12)
je 0x16eea
cmpl %r15d, 0x18(%r12)
je 0x16ee6
decq %r11
addq $0x50, %r12
cmpq $0x1, %r11
jg 0x16e6d
movq %r14, %r11
subq %r10, %r11
sarq $0x2, %r11
imulq %rdx, %r11
cmpq $0x1, %r11
je 0x16ecd
cmpq $0x2, %r11
je 0x16ec3
movq %r14, %r12
cmpq $0x3, %r11
jne 0x16eea
cmpl %r15d, 0x4(%r10)
je 0x16ed5
addq $0x14, %r10
cmpl %r15d, 0x4(%r10)
je 0x16ed5
addq $0x14, %r10
cmpl %r15d, 0x4(%r10)
cmovneq %r14, %r10
movq %r10, %r12
jmp 0x16eea
addq $-0x28, %r12
jmp 0x16eea
addq $-0x14, %r12
jmp 0x16eea
addq $0x14, %r12
movq %rax, %r10
testq %rbx, %rbx
jle 0x16f2e
shlq $0x4, %r9
movq %r9, %r10
addq %rax, %r10
incq %rbx
leaq 0x28(%rax), %r9
cmpl %ecx, -0x24(%r9)
je 0x16f6c
cmpl %ecx, -0x10(%r9)
je 0x16f72
cmpl %ecx, 0x4(%r9)
je 0x16f7c
cmpl %ecx, 0x18(%r9)
je 0x16f78
decq %rbx
addq $0x50, %r9
cmpq $0x1, %rbx
jg 0x16f03
movq %r14, %rdi
subq %r10, %rdi
sarq $0x2, %rdi
imulq %rdx, %rdi
cmpq $0x1, %rdi
je 0x16f5f
cmpq $0x2, %rdi
je 0x16f55
movq %r14, %r9
cmpq $0x3, %rdi
jne 0x16f7c
cmpl %ecx, 0x4(%r10)
je 0x16f67
addq $0x14, %r10
cmpl %ecx, 0x4(%r10)
je 0x16f67
addq $0x14, %r10
cmpl %ecx, 0x4(%r10)
cmovneq %r14, %r10
movq %r10, %r9
jmp 0x16f7c
addq $-0x28, %r9
jmp 0x16f7c
addq $-0x14, %r9
jmp 0x16f7c
addq $0x14, %r9
movb $0x1, %dl
movl %r15d, %edi
movb $0x1, %bl
cmpq %r14, %r12
je 0x16fa1
movb $0x0, 0x1c(%rsp)
subq %rax, %r12
shrq $0x2, %r12
imull $0xcccccccd, %r12d, %edi # imm = 0xCCCCCCCD
movl %edi, 0x14(%rsp)
xorl %ebx, %ebx
movl %ecx, %ebp
cmpq %r14, %r9
je 0x16fc1
movb $0x0, 0x1d(%rsp)
subq %rax, %r9
shrq $0x2, %r9
imull $0xcccccccd, %r9d, %ebp # imm = 0xCCCCCCCD
movl %ebp, 0x18(%rsp)
xorl %edx, %edx
testb %bl, %bl
je 0x16fcd
testb %dl, %dl
jne 0x17491
movq 0x80(%rsi), %r9
movq 0x88(%rsi), %rax
movq %rax, %r11
subq %r9, %r11
movq %r11, %r10
sarq $0x6, %r10
testq %r10, %r10
jle 0x17087
andq $-0x40, %r11
movq %r11, %r14
addq %r9, %r14
incq %r10
addq $0x20, %r9
cmpl -0x1c(%r9), %edi
jne 0x1701e
cmpl -0x18(%r9), %ebp
jne 0x1701e
cmpb -0x14(%r9), %bl
jne 0x1701e
cmpb -0x13(%r9), %dl
je 0x170f2
cmpl -0xc(%r9), %edi
jne 0x1703a
cmpl -0x8(%r9), %ebp
jne 0x1703a
cmpb -0x4(%r9), %bl
jne 0x1703a
cmpb -0x3(%r9), %dl
je 0x170f8
cmpl 0x4(%r9), %edi
jne 0x17056
cmpl 0x8(%r9), %ebp
jne 0x17056
cmpb 0xc(%r9), %bl
jne 0x17056
cmpb 0xd(%r9), %dl
je 0x17102
cmpl 0x14(%r9), %edi
jne 0x17072
cmpl 0x18(%r9), %ebp
jne 0x17072
cmpb 0x1c(%r9), %bl
jne 0x17072
cmpb 0x1d(%r9), %dl
je 0x170fe
decq %r10
addq $0x40, %r9
cmpq $0x1, %r10
jg 0x17002
movq %rax, %r11
subq %r14, %r11
jmp 0x1708a
movq %r9, %r14
sarq $0x4, %r11
cmpq $0x1, %r11
je 0x170d8
cmpq $0x2, %r11
je 0x170bc
cmpq $0x3, %r11
jne 0x1710e
cmpl 0x4(%r14), %edi
jne 0x170b8
cmpl 0x8(%r14), %ebp
jne 0x170b8
cmpb 0xc(%r14), %bl
jne 0x170b8
cmpb 0xd(%r14), %dl
je 0x17105
addq $0x10, %r14
cmpl 0x4(%r14), %edi
jne 0x170d4
cmpl 0x8(%r14), %ebp
jne 0x170d4
cmpb 0xc(%r14), %bl
jne 0x170d4
cmpb 0xd(%r14), %dl
je 0x17105
addq $0x10, %r14
cmpl 0x4(%r14), %edi
jne 0x1710e
cmpl 0x8(%r14), %ebp
jne 0x1710e
cmpb 0xc(%r14), %bl
jne 0x1710e
cmpb 0xd(%r14), %dl
je 0x17105
jmp 0x1710e
addq $-0x20, %r9
jmp 0x17102
addq $-0x10, %r9
jmp 0x17102
addq $0x10, %r9
movq %r9, %r14
cmpq %rax, %r14
jne 0x17491
movl %r8d, 0x28(%rsp)
movl %ecx, 0x2c(%rsp)
movq %rsi, 0x50(%rsp)
movq 0x20(%rsp), %rbp
movq 0x8(%rbp), %rdi
addq $0x8, %rdi
movl $0x3, %esi
callq 0x24f8a
movl %eax, %ebx
leal 0x1(%rbx), %r14d
movl %r14d, 0xc(%rsp)
movq 0x8(%rbp), %r12
movq %r12, %rdi
movl %r15d, %esi
callq 0x130d0
movq %r12, %rdi
movl %eax, %esi
callq 0x1b382
movq %rax, %r13
movq 0x8(%rbp), %rdi
movl %ebx, %esi
callq 0x1bafc
movq %rax, %r12
movq 0x8(%rbp), %rdi
movl %r14d, %esi
callq 0x1bafc
movq %rax, %r14
movl 0x8(%r13), %eax
movl %eax, 0x8(%r12)
leaq 0xc(%r12), %rax
movq %rax, 0x68(%rsp)
movups 0xc(%r13), %xmm0
movups %xmm0, 0xc(%r12)
leaq 0x20(%r12), %rbp
leaq 0x20(%r13), %rsi
movq %rbp, %rdi
callq 0x1bc64
leaq 0x38(%r12), %rdi
leaq 0x38(%r13), %rsi
movq %rdi, 0x70(%rsp)
callq 0x1bd48
movq 0x60(%r13), %rax
movq %rax, 0x60(%r12)
leaq 0x68(%r12), %rdi
leaq 0x68(%r13), %rsi
movq %rdi, 0x60(%rsp)
callq 0x1bc64
leaq 0x80(%r12), %rax
movq %rax, 0x58(%rsp)
movups 0x80(%r13), %xmm0
movups 0x90(%r13), %xmm1
movups %xmm0, 0x80(%r12)
movups %xmm1, 0x90(%r12)
cmpq %r12, %r13
je 0x1721d
movl $0xa0, %eax
leaq (%r12,%rax), %rdi
addq %rax, %r13
movq %r13, %rsi
callq 0xd596
movl %ebx, %r13d
addl $0x2, %r13d
movl %ebx, 0x8(%r12)
movl $0xe, 0xc(%r12)
movb $0x0, 0x60(%r12)
movl $0x8, 0x64(%r12)
movl 0x28(%rsp), %eax
movb %al, 0x88(%r12)
movl %ebx, 0x8(%r14)
movq 0x68(%rsp), %rax
movups (%rax), %xmm0
movups %xmm0, 0xc(%r14)
leaq 0x20(%r14), %rdi
movq %rbp, %rsi
callq 0x1bc64
leaq 0x38(%r14), %rdi
movq 0x70(%rsp), %rsi
callq 0x1bd48
movq 0x60(%r12), %rax
movq %rax, 0x60(%r14)
leaq 0x68(%r14), %rdi
movq 0x60(%rsp), %rsi
callq 0x1bc64
movq 0x58(%rsp), %rax
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm0, 0x80(%r14)
movups %xmm1, 0x90(%r14)
cmpq %r14, %r12
movl 0x2c(%rsp), %ebp
je 0x172ca
movl $0xa0, %eax
movq %r14, %rdi
addq %rax, %rdi
addq %rax, %r12
movq %r12, %rsi
callq 0xd596
movb $0x1, 0x60(%r14)
xorl %eax, %eax
movl %eax, 0x64(%r14)
movq 0x20(%rsp), %rbx
movq 0x8(%rbx), %rdi
leaq 0x30(%rsp), %rcx
movl $0x7, (%rcx)
leaq 0x78(%rsp), %r8
movl %eax, (%r8)
leaq 0xc(%rsp), %rdx
movl %r13d, %esi
callq 0x1bb38
movq 0x8(%rbx), %rax
movl %r13d, %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 0xd500
testb $0x1, 0x60(%rbx,%r12)
je 0x17341
leaq (%rbx,%r14), %rax
addq $0x60, %rax
orb $0x1, (%rax)
movl %r13d, 0x10(%rsp)
movq 0x20(%rsp), %r14
movq 0x8(%r14), %rbx
movq (%rbx), %rax
leaq 0x78(%rsp), %rdi
movq %rbx, %rsi
movl %r15d, %edx
movl $0x1, %ecx
callq *0x38(%rax)
movq 0x8(%r14), %rsi
movq (%rsi), %rax
leaq 0x98(%rsp), %rdi
movl %ebp, %edx
movl $0x1, %ecx
callq *0x38(%rax)
leaq 0x9dbc8(%rip), %rsi     # 0xb4f4d
leaq 0x30(%rsp), %rdi
leaq 0x78(%rsp), %rdx
leaq 0x98(%rsp), %rcx
callq 0x1bb7f
addq $0x8, %rbx
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
movl %r13d, %esi
callq 0x23fbc
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
movq 0x50(%rsp), %rbx
je 0x173d0
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x173f1
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x17412
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x88(%rbx), %rsi
cmpq 0x90(%rbx), %rsi
je 0x17434
movups 0x10(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x10, 0x88(%rbx)
jmp 0x17445
leaq 0x80(%rbx), %rdi
leaq 0x10(%rsp), %rdx
callq 0x22a60
movl 0xc(%rsp), %eax
movl %eax, 0x30(%rsp)
movl %r13d, 0x34(%rsp)
movq $0x0, 0x38(%rsp)
movb $0x1, 0x40(%rsp)
movq 0x38(%rbx), %rsi
cmpq 0x40(%rbx), %rsi
je 0x17480
movl 0x40(%rsp), %eax
movl %eax, 0x10(%rsi)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x14, 0x38(%rbx)
jmp 0x17491
addq $0x30, %rbx
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
callq 0x1f798
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x174c6
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x174c6
movq %rax, %rbx
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x174ec
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x174ec
movq %rax, %rbx
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1750d
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x6260
movq %rbx, %rdi
callq 0x64a0
nop