// File: /workspace/github_cpp_makefile_star2_O1/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 0x16254
movq %rax, %r14
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x170(%rax)
cmpl $0x4, 0xb8(%r14)
jne 0x26db3
cmpb $0x0, 0x43c(%rbx)
movl $0x12b, %eax            # imm = 0x12B
movl $0x81, %ecx
cmovnel %eax, %ecx
cmpl %ecx, 0x438(%rbx)
ja 0x26db3
movq %rbx, %rdi
callq 0x32fcc
movq 0x758(%rbx), %rax
cmpq 0x760(%rbx), %rax
jne 0x26dd3
movq 0x770(%rbx), %rax
cmpq 0x778(%rbx), %rax
je 0x26ddb
movq %rbx, %rdi
callq 0x33664
cmpb $0x1, 0x43f(%rbx)
jne 0x26df1
cmpb $0x0, 0x43c(%rbx)
je 0x26e85
cmpl $0x4, 0xb8(%r14)
leaq 0x9d61a(%rip), %rax     # 0xc441a
leaq 0x92145(%rip), %rcx     # 0xb8f4c
cmoveq %rax, %rcx
movq %rcx, 0x8(%rsp)
leaq 0x350(%rbx), %r14
cmpl $0x0, 0x350(%rbx)
je 0x26e3e
leaq 0x92148(%rip), %rdx     # 0xb8f6f
leaq 0x96cac(%rip), %r8      # 0xbdada
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
movq %r14, %rcx
callq 0x534be
leaq 0x354(%rbx), %r15
cmpl $0x0, 0x354(%rbx)
je 0x26e6c
leaq 0x92132(%rip), %rdx     # 0xb8f87
leaq 0x96c7e(%rip), %r8      # 0xbdada
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
movq %r15, %rcx
callq 0x534be
movl (%r15), %eax
orl (%r14), %eax
je 0x26ece
leaq 0x8ea34(%rip), %rsi     # 0xb58af
movq %rbx, %rdi
callq 0xa700
jmp 0x26ece
movl 0xb8(%r14), %edx
leal -0x1(%rdx), %eax
cmpl $0x3, %eax
jae 0x26eb2
movq %rbx, %rdi
movl $0x1, %esi
callq 0x33c46
movl 0xb8(%r14), %edx
movq %rbx, %rdi
movl $0x3, %esi
jmp 0x26ec9
testl %edx, %edx
je 0x26ec1
cmpl $0x4, %edx
je 0x26df1
jmp 0x26ece
movq %rbx, %rdi
movl $0x3, %esi
callq 0x33c46
cmpb $0x1, 0x358(%rbx)
jne 0x26ef5
leaq 0x920c1(%rip), %rsi     # 0xb8f9f
movq %rbx, %rdi
callq 0xc27a
leaq 0x8e9c2(%rip), %rsi     # 0xb58af
movq %rbx, %rdi
callq 0xa700
movq 0x20(%rbx), %r14
movq 0x28(%rbx), %r15
cmpq %r15, %r14
je 0x26f7f
xorl %ebp, %ebp
movl 0x8(%r14), %eax
cmpl $0x3, %eax
jne 0x26f3d
movq %r14, %rdi
callq 0x1be66
cmpb $0x1, 0x108(%rax)
jne 0x26f27
cmpb $0x0, 0x43e(%rbx)
jne 0x26f30
cmpb $0x1, 0x10a(%rax)
jne 0x26f61
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2e318
jmp 0x26f5e
cmpl $0xa, %eax
jne 0x26f61
cmpb $0x0, 0x43e(%rbx)
je 0x26f61
movq %r14, %rdi
callq 0x25f0e
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2d2ac
movb $0x1, %bpl
addq $0x10, %r14
cmpq %r15, %r14
jne 0x26f04
testb $0x1, %bpl
je 0x26f7f
leaq 0x8e938(%rip), %rsi     # 0xb58af
movq %rbx, %rdi
callq 0xa700
movq 0x20(%rbx), %r14
movq 0x28(%rbx), %r15
cmpq %r15, %r14
je 0x26fd7
cmpl $0x1, 0x8(%r14)
jne 0x26fd1
movq %r14, %rdi
callq 0xb08e
cmpl $0xc, 0xc(%rax)
jne 0x26fd1
movq 0x20(%rax), %rcx
cmpq 0x28(%rax), %rcx
jne 0x26fd1
cmpb $0x0, 0x60(%rax)
jne 0x26fd1
movl 0x8(%rax), %ecx
movq 0x38(%rbx), %rdx
imulq $0x148, %rcx, %rcx      # imm = 0x148
testb $0xc, 0x60(%rdx,%rcx)
jne 0x26fd1
movq %rbx, %rdi
movq %rax, %rsi
callq 0x285ee
addq $0x10, %r14
jmp 0x26f87
movq 0x20(%rbx), %r14
movq 0x28(%rbx), %r12
cmpq %r12, %r14
je 0x2705a
cmpl $0x2, 0x8(%r14)
jne 0x27054
movq %r14, %rdi
callq 0xb2e2
movq %rax, %r15
movl 0xc(%rax), %esi
movq %rbx, %rdi
callq 0xa426
cmpl $0x7, 0x10(%r15)
je 0x27054
cmpb $0x1, 0x60(%rax)
jne 0x27054
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 0x2702e
cmpl $0x2, %eax
jne 0x27054
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x1324c
testb $0xc, %r13b
je 0x27054
testb %al, %al
jne 0x27054
movq (%rbx), %rax
movq %rbx, %rdi
movq %r15, %rsi
callq *0xe8(%rax)
addq $0x10, %r14
jmp 0x26fdf
movq 0x20(%rbx), %r14
movq 0x28(%rbx), %r12
cmpq %r12, %r14
je 0x270bf
cmpl $0x2, 0x8(%r14)
jne 0x2708b
movq %r14, %rdi
callq 0xb2e2
movq %rax, %r15
movl 0xc(%rax), %esi
movq %rbx, %rdi
callq 0xa426
cmpl $0x7, 0x10(%r15)
jne 0x27091
addq $0x10, %r14
jmp 0x27062
cmpb $0x1, 0x60(%rax)
jne 0x2708b
cmpl $0x9, 0x64(%rax)
jne 0x2708b
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x1324c
testb %al, %al
jne 0x2708b
movq (%rbx), %rax
movq %rbx, %rdi
movq %r15, %rsi
callq *0xf0(%rax)
jmp 0x2708b
movq 0x1d8(%rbx), %rax
cmpq 0x1e0(%rbx), %rax
sete %bpl
movq 0x20(%rbx), %r14
movq 0x28(%rbx), %r12
cmpq %r12, %r14
je 0x271a2
andb 0x43e(%rbx), %bpl
xorl %r13d, %r13d
cmpl $0x2, 0x8(%r14)
jne 0x27180
movq %r14, %rdi
callq 0xb2e2
movq %rax, %r15
movl 0xc(%rax), %esi
movq %rbx, %rdi
callq 0xa426
testb %bpl, %bpl
jne 0x27144
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 0x27180
cmpl $0x7, 0x10(%r15)
je 0x27180
cmpb $0x1, 0x60(%rax)
jne 0x27180
movl 0x64(%rax), %eax
cmpl $0xa, %eax
je 0x2715d
testl %eax, %eax
jne 0x27180
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x1324c
testb %al, %al
jne 0x27180
movq (%rbx), %rax
movq %rbx, %rdi
movq %r15, %rsi
callq *0xf8(%rax)
movb $0x1, %r13b
addq $0x10, %r14
cmpq %r12, %r14
jne 0x270ec
testb $0x1, %r13b
je 0x271a2
leaq 0x8e715(%rip), %rsi     # 0xb58af
movq %rbx, %rdi
callq 0xa700
movq 0x20(%rbx), %r14
movq 0x28(%rbx), %r13
xorl %ebp, %ebp
cmpq %r13, %r14
je 0x2727a
leaq 0x91dfa(%rip), %r15     # 0xb8fb6
cmpl $0x2, 0x8(%r14)
jne 0x2726d
movq %r14, %rdi
callq 0xb2e2
movq %rax, %r12
movl 0xc(%rax), %esi
movq %rbx, %rdi
callq 0xa426
movl 0x10(%r12), %ecx
cmpl $0x7, %ecx
je 0x27217
cmpb $0x1, 0x60(%rax)
jne 0x27217
orl $0x2, %ecx
cmpl $0x3, %ecx
jne 0x27217
movl 0x8(%r12), %esi
movq %rbx, %rdi
callq 0x13f62
testb %al, %al
je 0x27217
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x1324c
testb %al, %al
je 0x2725f
movq %rbx, %rdi
movq %r12, %rsi
callq 0x133a2
testb %al, %al
je 0x2726d
cmpb $0x1, 0x444(%rbx)
jne 0x2726d
movl 0x8(%r12), %eax
movq 0x38(%rbx), %rcx
imulq $0x148, %rax, %rax      # imm = 0x148
cmpl $0x2b, 0xa0(%rcx,%rax)
jne 0x2726d
cmpb $0x0, 0x43e(%rbx)
jne 0x2726d
movq %rbx, %rdi
movq %r15, %rsi
callq 0x535d6
jmp 0x2726a
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2c72a
movb $0x1, %bpl
addq $0x10, %r14
cmpq %r13, %r14
jne 0x271bc
movl %ebp, %r15d
movq 0x118(%rbx), %r12
movq 0x120(%rbx), %rbp
cmpq %rbp, %r12
je 0x27316
leaq 0x488(%rbx), %r14
movl (%r12), %esi
movq %rbx, %rdi
callq 0xb40a
cmpl $0x3, 0x10(%rax)
je 0x2730d
movq %rax, %r13
movl 0x8(%rax), %eax
imulq $0x148, %rax, %rdx      # imm = 0x148
addq 0x38(%rbx), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2b9f6
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x2ce16
movq %rbx, %rdi
movq %r15, %rsi
leaq 0x98800(%rip), %rdx     # 0xbfae9
callq 0xaa50
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x2730a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
movb $0x1, %r15b
addq $0x4, %r12
cmpq %rbp, %r12
jne 0x2729b
testb $0x1, %r15b
je 0x2732b
leaq 0x8e58c(%rip), %rsi     # 0xb58af
movq %rbx, %rdi
callq 0xa700
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
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x27365
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
movq %rbx, %rdi
callq 0x64a0
nop