// File: /workspace/github_cpp_makefile_star2_O2/rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::emit_resources()
void CompilerGLSL::emit_resources()
{
	auto &execution = get_entry_point();

	replace_illegal_names();

	// Legacy GL uses gl_FragData[], redeclare all fragment outputs
	// with builtins.
	if (execution.model == ExecutionModelFragment && is_legacy())
		replace_fragment_outputs();

	// Emit PLS blocks if we have such variables.
	if (!pls_inputs.empty() || !pls_outputs.empty())
		emit_pls();

	// Emit custom gl_PerVertex for SSO compatibility.
	if (options.separate_shader_objects && !options.es && execution.model != ExecutionModelFragment)
	{
		switch (execution.model)
		{
		case ExecutionModelGeometry:
		case ExecutionModelTessellationControl:
		case ExecutionModelTessellationEvaluation:
			emit_declared_builtin_block(StorageClassInput, execution.model);
			emit_declared_builtin_block(StorageClassOutput, execution.model);
			break;

		case ExecutionModelVertex:
			emit_declared_builtin_block(StorageClassOutput, execution.model);
			break;

		default:
			break;
		}
	}
	else
	{
		// Need to redeclare clip/cull distance with explicit size to use them.
		// SPIR-V mandates these builtins have a size declared.
		const char *storage = execution.model == ExecutionModelFragment ? "in" : "out";
		if (clip_distance_count != 0)
			statement(storage, " float gl_ClipDistance[", clip_distance_count, "];");
		if (cull_distance_count != 0)
			statement(storage, " float gl_CullDistance[", cull_distance_count, "];");
		if (clip_distance_count != 0 || cull_distance_count != 0)
			statement("");
	}

	if (position_invariant)
	{
		statement("invariant gl_Position;");
		statement("");
	}

	bool emitted = false;

	// If emitted Vulkan GLSL,
	// emit specialization constants as actual floats,
	// spec op expressions will redirect to the constant name.
	//
	// TODO: If we have the fringe case that we create a spec constant which depends on a struct type,
	// we'll have to deal with that, but there's currently no known way to express that.
	for (auto &id : ir.ids)
	{
		if (id.get_type() == TypeConstant)
		{
			auto &c = id.get<SPIRConstant>();

			bool needs_declaration = (c.specialization && options.vulkan_semantics) || c.is_used_as_lut;

			if (needs_declaration)
			{
				emit_constant(c);
				emitted = true;
			}
		}
		else if (options.vulkan_semantics && id.get_type() == TypeConstantOp)
		{
			emit_specialization_constant_op(id.get<SPIRConstantOp>());
			emitted = true;
		}
	}

	if (emitted)
		statement("");
	emitted = false;

	// Output all basic struct types which are not Block or BufferBlock as these are declared inplace
	// when such variables are instantiated.
	for (auto &id : ir.ids)
	{
		if (id.get_type() == TypeType)
		{
			auto &type = id.get<SPIRType>();
			if (type.basetype == SPIRType::Struct && type.array.empty() && !type.pointer &&
			    (!ir.meta[type.self].decoration.decoration_flags.get(DecorationBlock) &&
			     !ir.meta[type.self].decoration.decoration_flags.get(DecorationBufferBlock)))
			{
				emit_struct(type);
			}
		}
	}

	// Output UBOs and SSBOs
	for (auto &id : ir.ids)
	{
		if (id.get_type() == TypeVariable)
		{
			auto &var = id.get<SPIRVariable>();
			auto &type = get<SPIRType>(var.basetype);

			bool is_block_storage = type.storage == StorageClassStorageBuffer || type.storage == StorageClassUniform;
			bool has_block_flags = ir.meta[type.self].decoration.decoration_flags.get(DecorationBlock) ||
			                       ir.meta[type.self].decoration.decoration_flags.get(DecorationBufferBlock);

			if (var.storage != StorageClassFunction && type.pointer && is_block_storage && !is_hidden_variable(var) &&
			    has_block_flags)
			{
				emit_buffer_block(var);
			}
		}
	}

	// Output push constant blocks
	for (auto &id : ir.ids)
	{
		if (id.get_type() == TypeVariable)
		{
			auto &var = id.get<SPIRVariable>();
			auto &type = get<SPIRType>(var.basetype);
			if (var.storage != StorageClassFunction && type.pointer && type.storage == StorageClassPushConstant &&
			    !is_hidden_variable(var))
			{
				emit_push_constant_block(var);
			}
		}
	}

	bool skip_separate_image_sampler = !combined_image_samplers.empty() || !options.vulkan_semantics;

	// Output Uniform Constants (values, samplers, images, etc).
	for (auto &id : ir.ids)
	{
		if (id.get_type() == TypeVariable)
		{
			auto &var = id.get<SPIRVariable>();
			auto &type = get<SPIRType>(var.basetype);

			// If we're remapping separate samplers and images, only emit the combined samplers.
			if (skip_separate_image_sampler)
			{
				// Sampler buffers are always used without a sampler, and they will also work in regular GL.
				bool sampler_buffer = type.basetype == SPIRType::Image && type.image.dim == DimBuffer;
				bool separate_image = type.basetype == SPIRType::Image && type.image.sampled == 1;
				bool separate_sampler = type.basetype == SPIRType::Sampler;
				if (!sampler_buffer && (separate_image || separate_sampler))
					continue;
			}

			if (var.storage != StorageClassFunction && type.pointer &&
			    (type.storage == StorageClassUniformConstant || type.storage == StorageClassAtomicCounter) &&
			    !is_hidden_variable(var))
			{
				emit_uniform(var);
				emitted = true;
			}
		}
	}

	if (emitted)
		statement("");
	emitted = false;

	// Output in/out interfaces.
	for (auto &id : ir.ids)
	{
		if (id.get_type() == TypeVariable)
		{
			auto &var = id.get<SPIRVariable>();
			auto &type = get<SPIRType>(var.basetype);

			if (var.storage != StorageClassFunction && type.pointer &&
			    (var.storage == StorageClassInput || var.storage == StorageClassOutput) &&
			    interface_variable_exists_in_entry_point(var.self) && !is_hidden_variable(var))
			{
				emit_interface_block(var);
				emitted = true;
			}
			else if (is_builtin_variable(var))
			{
				// For gl_InstanceIndex emulation on GLES, the API user needs to
				// supply this uniform.
				if (options.vertex.support_nonzero_base_instance &&
				    ir.meta[var.self].decoration.builtin_type == BuiltInInstanceIndex && !options.vulkan_semantics)
				{
					statement("uniform int SPIRV_Cross_BaseInstance;");
					emitted = true;
				}
			}
		}
	}

	// Global variables.
	for (auto global : global_variables)
	{
		auto &var = get<SPIRVariable>(global);
		if (var.storage != StorageClassOutput)
		{
			add_resource_name(var.self);
			statement(variable_decl(var), ";");
			emitted = true;
		}
	}

	if (emitted)
		statement("");

	declare_undefined_values();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
callq 0x12fa4
movq %rax, %r14
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x170(%rax)
cmpl $0x4, 0xb8(%r14)
jne 0x216a7
movq %rbx, %rdi
callq 0x41b9c
testb %al, %al
je 0x216a7
movq %rbx, %rdi
callq 0x2a8c2
movq 0x758(%rbx), %rax
cmpq 0x760(%rbx), %rax
jne 0x216c7
movq 0x770(%rbx), %rax
cmpq 0x778(%rbx), %rax
je 0x216cf
movq %rbx, %rdi
callq 0x2ada2
cmpb $0x0, 0x43f(%rbx)
je 0x21711
movl 0xb8(%r14), %edx
cmpb $0x0, 0x43c(%rbx)
jne 0x21718
leal -0x1(%rdx), %eax
cmpl $0x3, %eax
jae 0x217b4
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x2b22e
movl 0xb8(%r14), %edx
pushq $0x3
popq %rsi
movq %rbx, %rdi
jmp 0x217cb
movl 0xb8(%r14), %edx
cmpl $0x4, %edx
jne 0x21726
leaq 0x7cc7e(%rip), %rax     # 0x9e3a2
jmp 0x2172d
leaq 0x717ef(%rip), %rax     # 0x92f1c
movq %rax, 0x8(%rsp)
leaq 0x350(%rbx), %r14
cmpl $0x0, 0x350(%rbx)
je 0x21760
leaq 0x717f6(%rip), %rdx     # 0x92f3f
leaq 0x76322(%rip), %r8      # 0x97a72
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
movq %r14, %rcx
callq 0x42abe
cmpl $0x0, 0x354(%rbx)
je 0x21797
leaq 0x354(%rbx), %rcx
leaq 0x717e0(%rip), %rdx     # 0x92f57
leaq 0x762f4(%rip), %r8      # 0x97a72
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x42abe
cmpl $0x0, 0x354(%rbx)
sete %al
jmp 0x21799
movb $0x1, %al
cmpl $0x0, (%r14)
jne 0x217a3
testb %al, %al
jne 0x217d0
leaq 0x6e0dd(%rip), %rsi     # 0x8f887
movq %rbx, %rdi
callq 0x928e
jmp 0x217d0
testl %edx, %edx
je 0x217c3
cmpl $0x4, %edx
je 0x2171d
jmp 0x217d0
pushq $0x3
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2b22e
cmpb $0x1, 0x358(%rbx)
jne 0x217f7
leaq 0x7178f(%rip), %rsi     # 0x92f6f
movq %rbx, %rdi
callq 0xa61a
leaq 0x6e098(%rip), %rsi     # 0x8f887
movq %rbx, %rdi
callq 0x928e
movq 0x20(%rbx), %r14
movq 0x28(%rbx), %r15
xorl %ebp, %ebp
cmpq %r15, %r14
je 0x21869
movl 0x8(%r14), %eax
cmpl $0x3, %eax
jne 0x2183f
movq %r14, %rdi
callq 0x172b0
cmpb $0x1, 0x108(%rax)
jne 0x21829
cmpb $0x0, 0x43e(%rbx)
jne 0x21832
cmpb $0x1, 0x10a(%rax)
jne 0x21863
movq %rbx, %rdi
movq %rax, %rsi
callq 0x27010
jmp 0x21860
cmpl $0xa, %eax
jne 0x21863
cmpb $0x0, 0x43e(%rbx)
je 0x21863
movq %r14, %rdi
callq 0x20ad0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x264c6
movb $0x1, %bpl
addq $0x10, %r14
jmp 0x21801
testb $0x1, %bpl
je 0x2187e
leaq 0x6e011(%rip), %rsi     # 0x8f887
movq %rbx, %rdi
callq 0x928e
movq 0x20(%rbx), %r14
movq 0x28(%rbx), %r15
cmpq %r15, %r14
je 0x218d6
cmpl $0x1, 0x8(%r14)
jne 0x218d0
movq %r14, %rdi
callq 0x998c
cmpl $0xc, 0xc(%rax)
jne 0x218d0
movq 0x20(%rax), %rcx
cmpq 0x28(%rax), %rcx
jne 0x218d0
cmpb $0x0, 0x60(%rax)
jne 0x218d0
movl 0x8(%rax), %ecx
movq 0x38(%rbx), %rdx
imulq $0x148, %rcx, %rcx      # imm = 0x148
testb $0xc, 0x60(%rdx,%rcx)
jne 0x218d0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x22b86
addq $0x10, %r14
jmp 0x21886
movq 0x20(%rbx), %r14
movq 0x28(%rbx), %r12
cmpq %r12, %r14
je 0x21959
cmpl $0x2, 0x8(%r14)
jne 0x21953
movq %r14, %rdi
callq 0x9b30
movq %rax, %r15
movl 0xc(%rax), %esi
movq %rbx, %rdi
callq 0x90a4
cmpl $0x7, 0x10(%r15)
je 0x21953
cmpb $0x1, 0x60(%rax)
jne 0x21953
movl 0x8(%rax), %ecx
movl 0x64(%rax), %eax
movq 0x38(%rbx), %rdx
imulq $0x148, %rcx, %rcx      # imm = 0x148
movq 0x60(%rdx,%rcx), %r13
cmpl $0xc, %eax
je 0x2192d
cmpl $0x2, %eax
jne 0x21953
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x10b56
testb $0xc, %r13b
je 0x21953
testb %al, %al
jne 0x21953
movq (%rbx), %rax
movq %rbx, %rdi
movq %r15, %rsi
callq *0xe8(%rax)
addq $0x10, %r14
jmp 0x218de
movq 0x20(%rbx), %r14
movq 0x28(%rbx), %r12
cmpq %r12, %r14
je 0x219be
cmpl $0x2, 0x8(%r14)
jne 0x2198a
movq %r14, %rdi
callq 0x9b30
movq %rax, %r15
movl 0xc(%rax), %esi
movq %rbx, %rdi
callq 0x90a4
cmpl $0x7, 0x10(%r15)
jne 0x21990
addq $0x10, %r14
jmp 0x21961
cmpb $0x1, 0x60(%rax)
jne 0x2198a
cmpl $0x9, 0x64(%rax)
jne 0x2198a
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x10b56
testb %al, %al
jne 0x2198a
movq (%rbx), %rax
movq %rbx, %rdi
movq %r15, %rsi
callq *0xf0(%rax)
jmp 0x2198a
movq 0x1d8(%rbx), %rax
cmpq 0x1e0(%rbx), %rax
sete %bpl
andb 0x43e(%rbx), %bpl
movq 0x20(%rbx), %r14
movq 0x28(%rbx), %r12
xorl %r13d, %r13d
cmpq %r12, %r14
je 0x21a88
cmpl $0x2, 0x8(%r14)
jne 0x21a7f
movq %r14, %rdi
callq 0x9b30
movq %rax, %r15
movl 0xc(%rax), %esi
movq %rbx, %rdi
callq 0x90a4
testb %bpl, %bpl
jne 0x21a43
movl 0xc(%rax), %ecx
movl 0x84(%rax), %edx
movl %ecx, %esi
xorl $0xd, %esi
xorl $0x5, %edx
orl %esi, %edx
setne %dl
movl 0x8c(%rax), %edi
xorl $0x1, %edi
orl %esi, %edi
sete %sil
cmpl $0xf, %ecx
sete %cl
orb %sil, %cl
testb %cl, %dl
jne 0x21a7f
cmpl $0x7, 0x10(%r15)
je 0x21a7f
cmpb $0x1, 0x60(%rax)
jne 0x21a7f
movl 0x64(%rax), %eax
cmpl $0xa, %eax
je 0x21a5c
testl %eax, %eax
jne 0x21a7f
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x10b56
testb %al, %al
jne 0x21a7f
movq (%rbx), %rax
movq %rbx, %rdi
movq %r15, %rsi
callq *0xf8(%rax)
movb $0x1, %r13b
addq $0x10, %r14
jmp 0x219e2
testb $0x1, %r13b
je 0x21a9d
leaq 0x6ddf2(%rip), %rsi     # 0x8f887
movq %rbx, %rdi
callq 0x928e
movq 0x20(%rbx), %r14
movq 0x28(%rbx), %r13
xorl %ebp, %ebp
leaq 0x714d8(%rip), %r15     # 0x92f86
cmpq %r13, %r14
je 0x21b71
cmpl $0x2, 0x8(%r14)
jne 0x21b68
movq %r14, %rdi
callq 0x9b30
movq %rax, %r12
movl 0xc(%rax), %esi
movq %rbx, %rdi
callq 0x90a4
movl 0x10(%r12), %ecx
cmpl $0x7, %ecx
je 0x21b12
cmpb $0x1, 0x60(%rax)
jne 0x21b12
orl $0x2, %ecx
cmpl $0x3, %ecx
jne 0x21b12
movl 0x8(%r12), %esi
movq %rbx, %rdi
callq 0x115ea
testb %al, %al
je 0x21b12
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x10b56
testb %al, %al
je 0x21b5a
movq %rbx, %rdi
movq %r12, %rsi
callq 0x10c60
testb %al, %al
je 0x21b68
cmpb $0x1, 0x444(%rbx)
jne 0x21b68
movl 0x8(%r12), %eax
movq 0x38(%rbx), %rcx
imulq $0x148, %rax, %rax      # imm = 0x148
cmpl $0x2b, 0xa0(%rcx,%rax)
jne 0x21b68
cmpb $0x0, 0x43e(%rbx)
jne 0x21b68
movq %rbx, %rdi
movq %r15, %rsi
callq 0x42ba6
jmp 0x21b65
movq %rbx, %rdi
movq %r12, %rsi
callq 0x25d42
movb $0x1, %bpl
addq $0x10, %r14
jmp 0x21aae
movq 0x118(%rbx), %r13
movq 0x120(%rbx), %r15
leaq 0x8(%rsp), %r14
cmpq %r15, %r13
je 0x21bda
movl (%r13), %esi
movq %rbx, %rdi
callq 0x9c0e
cmpl $0x3, 0x10(%rax)
je 0x21bd4
movq %rax, %r12
movl 0x8(%rax), %esi
movq %rbx, %rdi
callq 0x22d1a
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x2619e
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x77ebd(%rip), %rdx     # 0x99a81
callq 0x953a
movq %r14, %rdi
callq 0x6548
movb $0x1, %bpl
addq $0x4, %r13
jmp 0x21b84
testb $0x1, %bpl
je 0x21bef
leaq 0x6dca0(%rip), %rsi     # 0x8f887
movq %rbx, %rdi
callq 0x928e
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x180(%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x6548
movq %rbx, %rdi
callq 0x64b0
nop