// File: /workspace/github_cpp_makefile_star2_O3/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 0x15f76
movq %rax, %r14
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x170(%rax)
cmpl $0x4, 0xb8(%r14)
jne 0x266f7
cmpb $0x0, 0x43c(%rbx)
movl $0x12b, %eax            # imm = 0x12B
movl $0x81, %ecx
cmovnel %eax, %ecx
cmpl %ecx, 0x438(%rbx)
ja 0x266f7
movq %rbx, %rdi
callq 0x32922
movq 0x758(%rbx), %rax
cmpq 0x760(%rbx), %rax
jne 0x26717
movq 0x770(%rbx), %rax
cmpq 0x778(%rbx), %rax
je 0x2671f
movq %rbx, %rdi
callq 0x32f6c
cmpb $0x0, 0x43f(%rbx)
je 0x26765
movl 0xb8(%r14), %edx
cmpb $0x0, 0x43c(%rbx)
jne 0x2676c
leal -0x1(%rdx), %eax
cmpl $0x3, %eax
jae 0x26808
movq %rbx, %rdi
movl $0x1, %esi
callq 0x33588
movl 0xb8(%r14), %edx
movq %rbx, %rdi
movl $0x3, %esi
jmp 0x26821
movl 0xb8(%r14), %edx
cmpl $0x4, %edx
jne 0x2677a
leaq 0x9cc72(%rip), %rax     # 0xc33ea
jmp 0x26781
leaq 0x917bb(%rip), %rax     # 0xb7f3c
movq %rax, 0x8(%rsp)
leaq 0x350(%rbx), %r14
cmpl $0x0, 0x350(%rbx)
je 0x267b4
leaq 0x917c2(%rip), %rdx     # 0xb7f5f
leaq 0x9633e(%rip), %r8      # 0xbcae2
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
movq %r14, %rcx
callq 0x52cc4
cmpl $0x0, 0x354(%rbx)
je 0x267eb
leaq 0x354(%rbx), %rcx
leaq 0x917ac(%rip), %rdx     # 0xb7f77
leaq 0x96310(%rip), %r8      # 0xbcae2
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x52cc4
cmpl $0x0, 0x354(%rbx)
sete %al
jmp 0x267ed
movb $0x1, %al
cmpl $0x0, (%r14)
jne 0x267f7
testb %al, %al
jne 0x26826
leaq 0x8e0b1(%rip), %rsi     # 0xb48af
movq %rbx, %rdi
callq 0xa6c4
jmp 0x26826
testl %edx, %edx
je 0x26817
cmpl $0x4, %edx
je 0x26771
jmp 0x26826
movq %rbx, %rdi
movl $0x3, %esi
xorl %edx, %edx
callq 0x33588
cmpb $0x1, 0x358(%rbx)
jne 0x2684d
leaq 0x91759(%rip), %rsi     # 0xb7f8f
movq %rbx, %rdi
callq 0xc23a
leaq 0x8e06a(%rip), %rsi     # 0xb48af
movq %rbx, %rdi
callq 0xa6c4
movq 0x20(%rbx), %r14
movq 0x28(%rbx), %r15
cmpq %r15, %r14
je 0x268d7
xorl %ebp, %ebp
movl 0x8(%r14), %eax
cmpl $0x3, %eax
jne 0x26895
movq %r14, %rdi
callq 0x1b808
cmpb $0x1, 0x108(%rax)
jne 0x2687f
cmpb $0x0, 0x43e(%rbx)
jne 0x26888
cmpb $0x1, 0x10a(%rax)
jne 0x268b9
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2dc98
jmp 0x268b6
cmpl $0xa, %eax
jne 0x268b9
cmpb $0x0, 0x43e(%rbx)
je 0x268b9
movq %r14, %rdi
callq 0x2584c
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2cc3e
movb $0x1, %bpl
addq $0x10, %r14
cmpq %r15, %r14
jne 0x2685c
testb $0x1, %bpl
je 0x268d7
leaq 0x8dfe0(%rip), %rsi     # 0xb48af
movq %rbx, %rdi
callq 0xa6c4
movq 0x20(%rbx), %r14
movq 0x28(%rbx), %r15
cmpq %r15, %r14
je 0x26b2a
cmpl $0x1, 0x8(%r14)
jne 0x2692d
movq %r14, %rdi
callq 0xb052
cmpl $0xc, 0xc(%rax)
jne 0x2692d
movq 0x20(%rax), %rcx
cmpq 0x28(%rax), %rcx
jne 0x2692d
cmpb $0x0, 0x60(%rax)
jne 0x2692d
movl 0x8(%rax), %ecx
movq 0x38(%rbx), %rdx
imulq $0x148, %rcx, %rcx      # imm = 0x148
testb $0xc, 0x60(%rdx,%rcx)
jne 0x2692d
movq %rbx, %rdi
movq %rax, %rsi
callq 0x27fa4
addq $0x10, %r14
cmpq %r15, %r14
jne 0x268e8
movq 0x20(%rbx), %r14
movq 0x28(%rbx), %r12
cmpq %r12, %r14
je 0x269c8
cmpl $0x2, 0x8(%r14)
jne 0x269b7
movq %r14, %rdi
callq 0xb2a4
movq %rax, %r15
movl 0xc(%rax), %esi
movq %rbx, %rdi
callq 0xa3ea
cmpl $0x7, 0x10(%r15)
je 0x269b7
cmpb $0x1, 0x60(%rax)
jne 0x269b7
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 0x26991
cmpl $0x2, %eax
jne 0x269b7
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x13202
testb $0xc, %r13b
je 0x269b7
testb %al, %al
jne 0x269b7
movq (%rbx), %rax
movq %rbx, %rdi
movq %r15, %rsi
callq *0xe8(%rax)
addq $0x10, %r14
cmpq %r12, %r14
jne 0x26947
movq 0x20(%rbx), %r14
movq 0x28(%rbx), %r12
cmpq %r12, %r14
je 0x26a32
cmpl $0x2, 0x8(%r14)
jne 0x269f1
movq %r14, %rdi
callq 0xb2a4
movq %rax, %r15
movl 0xc(%rax), %esi
movq %rbx, %rdi
callq 0xa3ea
cmpl $0x7, 0x10(%r15)
jne 0x269fc
addq $0x10, %r14
cmpq %r12, %r14
jne 0x269cd
jmp 0x26a2a
cmpb $0x1, 0x60(%rax)
jne 0x269f1
cmpl $0x9, 0x64(%rax)
jne 0x269f1
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x13202
testb %al, %al
jne 0x269f1
movq (%rbx), %rax
movq %rbx, %rdi
movq %r15, %rsi
callq *0xf0(%rax)
jmp 0x269f1
movq 0x20(%rbx), %r14
movq 0x28(%rbx), %r12
movq 0x1d8(%rbx), %rax
cmpq 0x1e0(%rbx), %rax
sete %bpl
leaq 0x43e(%rbx), %r13
cmpq %r12, %r14
je 0x26b31
andb 0x43e(%rbx), %bpl
xorl %eax, %eax
movl %eax, 0x4(%rsp)
addq $0x10, %r14
cmpl $0x2, -0x8(%r14)
jne 0x26ae4
leaq -0x10(%r14), %rdi
callq 0xb2a4
movq %rax, %r15
movl 0xc(%rax), %esi
movq %rbx, %rdi
callq 0xa3ea
testb %bpl, %bpl
jne 0x26aba
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 0x26ae4
cmpl $0x7, 0x10(%r15)
je 0x26ae4
cmpb $0x1, 0x60(%rax)
jne 0x26ae4
movl 0x64(%rax), %eax
cmpl $0xa, %eax
je 0x26ad3
testl %eax, %eax
jne 0x26ae4
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x13202
testb %al, %al
je 0x26af6
leaq 0x10(%r14), %rax
cmpq %r12, %r14
movq %rax, %r14
jne 0x26a65
jmp 0x26b12
movq (%rbx), %rax
movq %rbx, %rdi
movq %r15, %rsi
callq *0xf8(%rax)
movb $0x1, %al
cmpq %r12, %r14
jne 0x26a5d
jmp 0x26b19
testb $0x1, 0x4(%rsp)
je 0x26b31
leaq 0x8dd8f(%rip), %rsi     # 0xb48af
movq %rbx, %rdi
callq 0xa6c4
jmp 0x26b31
leaq 0x43e(%rbx), %r13
movq 0x20(%rbx), %r14
movq 0x28(%rbx), %r15
xorl %ebp, %ebp
cmpq %r15, %r14
je 0x26c00
cmpl $0x2, 0x8(%r14)
jne 0x26bf7
movq %r14, %rdi
callq 0xb2a4
movq %rax, %r12
movl 0xc(%rax), %esi
movq %rbx, %rdi
callq 0xa3ea
movl 0x10(%r12), %ecx
cmpl $0x7, %ecx
je 0x26b9f
cmpb $0x1, 0x60(%rax)
jne 0x26b9f
orl $0x2, %ecx
cmpl $0x3, %ecx
jne 0x26b9f
movl 0x8(%r12), %esi
movq %rbx, %rdi
callq 0x13e3a
testb %al, %al
je 0x26b9f
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x13202
testb %al, %al
je 0x26be9
movq %rbx, %rdi
movq %r12, %rsi
callq 0x13330
testb %al, %al
je 0x26bf7
cmpb $0x1, 0x444(%rbx)
jne 0x26bf7
movl 0x8(%r12), %eax
movq 0x38(%rbx), %rcx
imulq $0x148, %rax, %rax      # imm = 0x148
cmpl $0x2b, 0xa0(%rcx,%rax)
jne 0x26bf7
cmpb $0x0, (%r13)
jne 0x26bf7
movq %rbx, %rdi
leaq 0x913c4(%rip), %rsi     # 0xb7fa6
callq 0x52ddc
jmp 0x26bf4
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2c116
movb $0x1, %bpl
addq $0x10, %r14
jmp 0x26b3b
movl %ebp, %r15d
movq 0x118(%rbx), %r12
movq 0x120(%rbx), %rbp
cmpq %rbp, %r12
je 0x26c9c
leaq 0x488(%rbx), %r14
movl (%r12), %esi
movq %rbx, %rdi
callq 0xb3ca
cmpl $0x3, 0x10(%rax)
je 0x26c93
movq %rax, %r13
movl 0x8(%rax), %eax
imulq $0x148, %rax, %rdx      # imm = 0x148
addq 0x38(%rbx), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2b3ee
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x2c7ac
movq %rbx, %rdi
movq %r15, %rsi
leaq 0x97e82(%rip), %rdx     # 0xbeaf1
callq 0xaa14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x26c90
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
movb $0x1, %r15b
addq $0x4, %r12
cmpq %rbp, %r12
jne 0x26c21
testb $0x1, %r15b
je 0x26cb1
leaq 0x8dc06(%rip), %rsi     # 0xb48af
movq %rbx, %rdi
callq 0xa6c4
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 0x26ceb
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
movq %rbx, %rdi
callq 0x64a0
nop