// File: rossy[P]crossc/SPIRV-Cross/spirv_hlsl.cpp
// Function: spirv_cross::CompilerHLSL::emit_modern_uniform(spirv_cross::SPIRVariable const&)
void CompilerHLSL::emit_modern_uniform(const SPIRVariable &var)
{
	auto &type = get<SPIRType>(var.basetype);
	switch (type.basetype)
	{
	case SPIRType::SampledImage:
	case SPIRType::Image:
	{
		bool is_coherent = false;
		if (type.basetype == SPIRType::Image && type.image.sampled == 2)
			is_coherent = has_decoration(var.self, DecorationCoherent);

		statement(is_coherent ? "globallycoherent " : "", image_type_hlsl_modern(type, var.self), " ",
		          to_name(var.self), type_to_array_glsl(type), to_resource_binding(var), ";");

		if (type.basetype == SPIRType::SampledImage && type.image.dim != DimBuffer)
		{
			// For combined image samplers, also emit a combined image sampler.
			if (image_is_comparison(type, var.self))
				statement("SamplerComparisonState ", to_sampler_expression(var.self), type_to_array_glsl(type),
				          to_resource_binding_sampler(var), ";");
			else
				statement("SamplerState ", to_sampler_expression(var.self), type_to_array_glsl(type),
				          to_resource_binding_sampler(var), ";");
		}
		break;
	}

	case SPIRType::Sampler:
		if (comparison_ids.count(var.self))
			statement("SamplerComparisonState ", to_name(var.self), type_to_array_glsl(type), to_resource_binding(var),
			          ";");
		else
			statement("SamplerState ", to_name(var.self), type_to_array_glsl(type), to_resource_binding(var), ";");
		break;

	default:
		statement(variable_decl(var), to_resource_binding(var), ";");
		break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2a0, %rsp            # imm = 0x2A0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x288(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %esi
callq 0xea90
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x27c(%rbp)
addl $-0xd, %eax
subl $0x2, %eax
jb 0xc85b9
jmp 0xc85a5
movl -0x27c(%rbp), %eax
subl $0xf, %eax
je 0xc897c
jmp 0xc8ba3
movb $0x0, -0x19(%rbp)
movq -0x18(%rbp), %rax
cmpl $0xd, 0xc(%rax)
jne 0xc85f1
movq -0x18(%rbp), %rax
cmpl $0x2, 0x8c(%rax)
jne 0xc85f1
movq -0x288(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %esi
movl $0x17, %edx
callq 0x1f560
andb $0x1, %al
movb %al, -0x19(%rbp)
movq -0x288(%rbp), %rsi
movb -0x19(%rbp), %dl
leaq 0x7f8ca(%rip), %rcx     # 0x147ecc
leaq 0x76295(%rip), %rax     # 0x13e89e
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rdx
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
leaq -0x48(%rbp), %rdi
callq 0xb9cd0
movq -0x288(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edx
movq (%rsi), %rax
movq 0x38(%rax), %rax
leaq -0x68(%rbp), %rdi
movl $0x1, %ecx
callq *%rax
jmp 0xc864a
movq -0x288(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x98(%rbp), %rdi
callq 0x61340
jmp 0xc8663
movq -0x288(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq -0xb8(%rbp), %rdi
callq 0xc3370
jmp 0xc867c
movq -0x288(%rbp), %rdi
leaq 0x80a1c(%rip), %rcx     # 0x1490a6
movq %rsp, %rax
movq %rcx, 0x8(%rax)
leaq -0xb8(%rbp), %rcx
movq %rcx, (%rax)
leaq 0x761fb(%rip), %rcx     # 0x13e89d
leaq -0x28(%rbp), %rsi
leaq -0x48(%rbp), %rdx
leaq -0x68(%rbp), %r8
leaq -0x98(%rbp), %r9
callq 0xdcd10
jmp 0xc86bc
leaq -0xb8(%rbp), %rdi
callq 0x7708
leaq -0x98(%rbp), %rdi
callq 0x7708
leaq -0x68(%rbp), %rdi
callq 0x7708
leaq -0x48(%rbp), %rdi
callq 0x7708
movq -0x18(%rbp), %rax
cmpl $0xe, 0xc(%rax)
jne 0xc8977
movq -0x18(%rbp), %rax
cmpl $0x5, 0x84(%rax)
je 0xc8977
movq -0x288(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x2c890
testb $0x1, %al
jne 0xc8725
jmp 0xc8881
movq -0x288(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edx
leaq -0xd8(%rbp), %rdi
callq 0xc3db0
movq -0x288(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0xf8(%rbp), %rdi
callq 0x61340
jmp 0xc8758
movq -0x288(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq -0x118(%rbp), %rdi
callq 0xc8480
jmp 0xc8771
movq -0x288(%rbp), %rdi
leaq 0x7f8d4(%rip), %rsi     # 0x148053
leaq 0x80920(%rip), %r9      # 0x1490a6
leaq -0xd8(%rbp), %rdx
leaq -0xf8(%rbp), %rcx
leaq -0x118(%rbp), %r8
callq 0xdce90
jmp 0xc87a2
leaq -0x118(%rbp), %rdi
callq 0x7708
leaq -0xf8(%rbp), %rdi
callq 0x7708
leaq -0xd8(%rbp), %rdi
callq 0x7708
jmp 0xc8975
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xc8822
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xc8819
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xc880d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x7708
leaq -0x98(%rbp), %rdi
callq 0x7708
leaq -0x68(%rbp), %rdi
callq 0x7708
leaq -0x48(%rbp), %rdi
callq 0x7708
jmp 0xc8c4d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xc8870
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xc8864
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x7708
leaq -0xf8(%rbp), %rdi
callq 0x7708
leaq -0xd8(%rbp), %rdi
callq 0x7708
jmp 0xc8c4d
movq -0x288(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edx
leaq -0x138(%rbp), %rdi
callq 0xc3db0
movq -0x288(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x158(%rbp), %rdi
callq 0x61340
jmp 0xc88b4
movq -0x288(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq -0x178(%rbp), %rdi
callq 0xc8480
jmp 0xc88cd
movq -0x288(%rbp), %rdi
leaq 0x7f790(%rip), %rsi     # 0x14806b
leaq 0x807c4(%rip), %r9      # 0x1490a6
leaq -0x138(%rbp), %rdx
leaq -0x158(%rbp), %rcx
leaq -0x178(%rbp), %r8
callq 0xdcfe0
jmp 0xc88fe
leaq -0x178(%rbp), %rdi
callq 0x7708
leaq -0x158(%rbp), %rdi
callq 0x7708
leaq -0x138(%rbp), %rdi
callq 0x7708
jmp 0xc8975
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xc8964
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xc8958
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x7708
leaq -0x158(%rbp), %rdi
callq 0x7708
leaq -0x138(%rbp), %rdi
callq 0x7708
jmp 0xc8c4d
jmp 0xc8977
jmp 0xc8c44
movq -0x288(%rbp), %rdi
addq $0x360, %rdi            # imm = 0x360
movq -0x10(%rbp), %rsi
addq $0x8, %rsi
callq 0x13520
cmpq $0x0, %rax
je 0xc8aa1
movq -0x288(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edx
movq (%rsi), %rax
movq 0x38(%rax), %rax
leaq -0x198(%rbp), %rdi
movl $0x1, %ecx
callq *%rax
movq -0x288(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x1b8(%rbp), %rdi
callq 0x61340
jmp 0xc89dd
movq -0x288(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq -0x1d8(%rbp), %rdi
callq 0xc3370
jmp 0xc89f6
movq -0x288(%rbp), %rdi
leaq 0x7f64f(%rip), %rsi     # 0x148053
leaq 0x8069b(%rip), %r9      # 0x1490a6
leaq -0x198(%rbp), %rdx
leaq -0x1b8(%rbp), %rcx
leaq -0x1d8(%rbp), %r8
callq 0xdce90
jmp 0xc8a27
leaq -0x1d8(%rbp), %rdi
callq 0x7708
leaq -0x1b8(%rbp), %rdi
callq 0x7708
leaq -0x198(%rbp), %rdi
callq 0x7708
jmp 0xc8b9e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xc8a90
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xc8a84
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x7708
leaq -0x1b8(%rbp), %rdi
callq 0x7708
leaq -0x198(%rbp), %rdi
callq 0x7708
jmp 0xc8c4d
movq -0x288(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edx
movq (%rsi), %rax
movq 0x38(%rax), %rax
leaq -0x1f8(%rbp), %rdi
movl $0x1, %ecx
callq *%rax
movq -0x288(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x218(%rbp), %rdi
callq 0x61340
jmp 0xc8add
movq -0x288(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq -0x238(%rbp), %rdi
callq 0xc3370
jmp 0xc8af6
movq -0x288(%rbp), %rdi
leaq 0x7f567(%rip), %rsi     # 0x14806b
leaq 0x8059b(%rip), %r9      # 0x1490a6
leaq -0x1f8(%rbp), %rdx
leaq -0x218(%rbp), %rcx
leaq -0x238(%rbp), %r8
callq 0xdcfe0
jmp 0xc8b27
leaq -0x238(%rbp), %rdi
callq 0x7708
leaq -0x218(%rbp), %rdi
callq 0x7708
leaq -0x1f8(%rbp), %rdi
callq 0x7708
jmp 0xc8b9e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xc8b8d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xc8b81
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x7708
leaq -0x218(%rbp), %rdi
callq 0x7708
leaq -0x1f8(%rbp), %rdi
callq 0x7708
jmp 0xc8c4d
jmp 0xc8c44
movq -0x288(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq -0x258(%rbp), %rdi
callq 0x62d60
movq -0x288(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq -0x278(%rbp), %rdi
callq 0xc3370
jmp 0xc8bd3
movq -0x288(%rbp), %rdi
leaq 0x804c5(%rip), %rcx     # 0x1490a6
leaq -0x258(%rbp), %rsi
leaq -0x278(%rbp), %rdx
callq 0xa01d0
jmp 0xc8bf6
leaq -0x278(%rbp), %rdi
callq 0x7708
leaq -0x258(%rbp), %rdi
callq 0x7708
jmp 0xc8c44
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xc8c36
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x278(%rbp), %rdi
callq 0x7708
leaq -0x258(%rbp), %rdi
callq 0x7708
jmp 0xc8c4d
addq $0x2a0, %rsp            # imm = 0x2A0
popq %rbp
retq
movq -0x70(%rbp), %rdi
callq 0x7640
nopw %cs:(%rax,%rax)