// File: rossy[P]crossc/SPIRV-Cross/spirv_cpp.cpp
// Function: spirv_cross::CompilerCPP::emit_uniform(spirv_cross::SPIRVariable const&)
void CompilerCPP::emit_uniform(const SPIRVariable &var)
{
	add_resource_name(var.self);

	auto &type = get<SPIRType>(var.basetype);
	auto instance_name = to_name(var.self);

	uint32_t descriptor_set = ir.meta[var.self].decoration.set;
	uint32_t binding = ir.meta[var.self].decoration.binding;
	uint32_t location = ir.meta[var.self].decoration.location;

	string type_name = type_to_glsl(type);
	remap_variable_type_name(type, instance_name, type_name);

	if (type.basetype == SPIRType::Image || type.basetype == SPIRType::SampledImage ||
	    type.basetype == SPIRType::AtomicCounter)
	{
		statement("internal::Resource<", type_name, type_to_array_glsl(type), "> ", instance_name, "__;");
		statement_no_indent("#define ", instance_name, " __res->", instance_name, "__.get()");
		resource_registrations.push_back(
		    join("s.register_resource(", instance_name, "__", ", ", descriptor_set, ", ", binding, ");"));
	}
	else
	{
		statement("internal::UniformConstant<", type_name, type_to_array_glsl(type), "> ", instance_name, "__;");
		statement_no_indent("#define ", instance_name, " __res->", instance_name, "__.get()");
		resource_registrations.push_back(
		    join("s.register_uniform_constant(", instance_name, "__", ", ", location, ");"));
	}

	statement("");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x100(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x5c1d0
movq -0x100(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0xc(%rax), %esi
callq 0xea90
movq -0x100(%rbp), %rsi
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edx
movq (%rsi), %rax
movq 0x38(%rax), %rax
leaq -0x38(%rbp), %rdi
movl $0x1, %ecx
callq *%rax
movq -0x100(%rbp), %rdi
addq $0x38, %rdi
movq %rdi, -0x108(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %esi
callq 0xead0
movq -0x108(%rbp), %rdi
movl 0xac(%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %esi
callq 0xead0
movq -0x108(%rbp), %rdi
movl 0xb0(%rax), %eax
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %esi
callq 0xead0
movq -0x100(%rbp), %rsi
movl 0xa4(%rax), %eax
movl %eax, -0x44(%rbp)
movq -0x18(%rbp), %rdx
movq (%rsi), %rax
movq 0x98(%rax), %rax
leaq -0x68(%rbp), %rdi
xorl %ecx, %ecx
callq *%rax
jmp 0xc795
movq -0x100(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x38(%rbp), %rdx
leaq -0x68(%rbp), %rcx
callq 0xf3f0
jmp 0xc7af
movq -0x18(%rbp), %rax
cmpl $0xd, 0xc(%rax)
je 0xc7d1
movq -0x18(%rbp), %rax
cmpl $0xe, 0xc(%rax)
je 0xc7d1
movq -0x18(%rbp), %rax
cmpl $0x8, 0xc(%rax)
jne 0xc932
movq -0x100(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x98(%rbp), %rdi
callq 0x61340
jmp 0xc7ea
movq -0x100(%rbp), %rdi
leaq 0x1319df(%rip), %rcx    # 0x13e1d7
movq %rsp, %rax
movq %rcx, (%rax)
leaq 0x1319bb(%rip), %rsi    # 0x13e1c0
leaq 0x1319c8(%rip), %r8     # 0x13e1d4
leaq -0x68(%rbp), %rdx
leaq -0x98(%rbp), %rcx
leaq -0x38(%rbp), %r9
callq 0xeaf0
jmp 0xc822
leaq -0x98(%rbp), %rdi
callq 0x7708
movq -0x100(%rbp), %rdi
leaq 0x13199f(%rip), %rsi    # 0x13e1db
leaq 0x1319a1(%rip), %rcx    # 0x13e1e4
leaq 0x1319a3(%rip), %r9     # 0x13e1ed
leaq -0x38(%rbp), %r8
movq %r8, %rdx
callq 0xec60
jmp 0xc858
movq -0x100(%rbp), %rax
addq $0x788, %rax            # imm = 0x788
movq %rax, -0x110(%rbp)
leaq 0x13c832(%rip), %rcx    # 0x1490a5
movq %rsp, %rax
movq %rcx, 0x10(%rax)
leaq -0x40(%rbp), %rcx
movq %rcx, 0x8(%rax)
leaq 0x137d06(%rip), %r8     # 0x14458f
movq %r8, (%rax)
leaq 0x131963(%rip), %rsi    # 0x13e1f6
leaq 0x131971(%rip), %rcx    # 0x13e20b
leaq -0xb8(%rbp), %rdi
leaq -0x38(%rbp), %rdx
leaq -0x3c(%rbp), %r9
callq 0xed00
jmp 0xc8b0
movq -0x110(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0xecd0
jmp 0xc8c5
leaq -0xb8(%rbp), %rdi
callq 0x7708
jmp 0xca5c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xca95
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xca8c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x7708
jmp 0xca8c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x7708
jmp 0xca8c
movq -0x100(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0xd8(%rbp), %rdi
callq 0x61340
jmp 0xc94b
movq -0x100(%rbp), %rdi
leaq 0x13187e(%rip), %rcx    # 0x13e1d7
movq %rsp, %rax
movq %rcx, (%rax)
leaq 0x1318e3(%rip), %rsi    # 0x13e249
leaq 0x131867(%rip), %r8     # 0x13e1d4
leaq -0x68(%rbp), %rdx
leaq -0xd8(%rbp), %rcx
leaq -0x38(%rbp), %r9
callq 0xf450
jmp 0xc983
leaq -0xd8(%rbp), %rdi
callq 0x7708
movq -0x100(%rbp), %rdi
leaq 0x13183e(%rip), %rsi    # 0x13e1db
leaq 0x131840(%rip), %rcx    # 0x13e1e4
leaq 0x131842(%rip), %r9     # 0x13e1ed
leaq -0x38(%rbp), %r8
movq %r8, %rdx
callq 0xec60
jmp 0xc9b9
movq -0x100(%rbp), %rax
addq $0x788, %rax            # imm = 0x788
movq %rax, -0x118(%rbp)
leaq 0x13c6d1(%rip), %rcx    # 0x1490a5
movq %rsp, %rax
movq %rcx, (%rax)
leaq 0x131883(%rip), %rsi    # 0x13e264
leaq 0x131823(%rip), %rcx    # 0x13e20b
leaq 0x137ba0(%rip), %r8     # 0x14458f
leaq -0xf8(%rbp), %rdi
leaq -0x38(%rbp), %rdx
leaq -0x44(%rbp), %r9
callq 0xf5c0
jmp 0xca05
movq -0x118(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0xecd0
jmp 0xca1a
leaq -0xf8(%rbp), %rdi
callq 0x7708
jmp 0xca5c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x7708
jmp 0xca8c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x7708
jmp 0xca8c
movq -0x100(%rbp), %rdi
leaq 0x131e34(%rip), %rsi    # 0x13e89e
callq 0xedf0
jmp 0xca71
leaq -0x68(%rbp), %rdi
callq 0x7708
leaq -0x38(%rbp), %rdi
callq 0x7708
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
leaq -0x68(%rbp), %rdi
callq 0x7708
leaq -0x38(%rbp), %rdi
callq 0x7708
movq -0x70(%rbp), %rdi
callq 0x7640
nopw (%rax,%rax)