// File: /workspace/github_cpp_makefile_star2_O2/rossy[P]crossc/SPIRV-Cross/spirv_cpp.cpp
// Function: spirv_cross::CompilerCPP::emit_resources()
void CompilerCPP::emit_resources()
{
	// 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);
			}
		}
	}

	statement("struct Resources : ", resource_type);
	begin_scope();

	// 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);

			if (var.storage != StorageClassFunction && type.pointer && type.storage == StorageClassUniform &&
			    !is_hidden_variable(var) &&
			    (ir.meta[type.self].decoration.decoration_flags.get(DecorationBlock) ||
			     ir.meta[type.self].decoration.decoration_flags.get(DecorationBufferBlock)))
			{
				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 (!is_hidden_variable(var) && var.storage != StorageClassFunction && type.pointer &&
			    type.storage == StorageClassPushConstant)
			{
				emit_push_constant_block(var);
			}
		}
	}

	// 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 && !is_hidden_variable(var) && type.pointer &&
			    (var.storage == StorageClassInput || var.storage == StorageClassOutput) &&
			    interface_variable_exists_in_entry_point(var.self))
			{
				emit_interface_block(var);
			}
		}
	}

	// 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 (var.storage != StorageClassFunction && !is_hidden_variable(var) && type.pointer &&
			    (type.storage == StorageClassUniformConstant || type.storage == StorageClassAtomicCounter))
			{
				emit_uniform(var);
			}
		}
	}

	// Global variables.
	bool emitted = false;
	for (auto global : global_variables)
	{
		auto &var = get<SPIRVariable>(global);
		if (var.storage == StorageClassWorkgroup)
		{
			emit_shared(var);
			emitted = true;
		}
	}

	if (emitted)
		statement("");

	declare_undefined_values();

	statement("inline void init(spirv_cross_shader& s)");
	begin_scope();
	statement(resource_type, "::init(s);");
	for (auto &reg : resource_registrations)
		statement(reg);
	end_scope();
	resource_registrations.clear();

	end_scope_decl();

	statement("");
	statement("Resources* __res;");
	if (get_entry_point().model == ExecutionModelGLCompute)
		statement("ComputePrivateResources __priv_res;");
	statement("");

	// Emit regular globals which are allocated per invocation.
	emitted = false;
	for (auto global : global_variables)
	{
		auto &var = get<SPIRVariable>(global);
		if (var.storage == StorageClassPrivate)
		{
			if (var.storage == StorageClassWorkgroup)
				emit_shared(var);
			else
				statement(CompilerGLSL::variable_decl(var), ";");
			emitted = true;
		}
	}

	if (emitted)
		statement("");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq 0x20(%rdi), %r14
movq 0x28(%rdi), %r15
cmpq %r15, %r14
je 0x809d
cmpl $0x1, 0x8(%r14)
jne 0x8097
movq %r14, %rdi
callq 0x998c
cmpl $0xc, 0xc(%rax)
jne 0x8097
movq 0x20(%rax), %rcx
cmpq 0x28(%rax), %rcx
jne 0x8097
cmpb $0x0, 0x60(%rax)
jne 0x8097
movl 0x8(%rax), %ecx
movq 0x38(%rbx), %rdx
imulq $0x148, %rcx, %rcx      # imm = 0x148
testb $0xc, 0x60(%rdx,%rcx)
jne 0x8097
movq %rbx, %rdi
movq %rax, %rsi
callq 0x22b86
addq $0x10, %r14
jmp 0x804d
leaq 0x7c0(%rbx), %r14
leaq 0x87287(%rip), %rsi     # 0x8f332
movq %rbx, %rdi
movq %r14, %rdx
callq 0x9a6a
movq %rbx, %rdi
callq 0x22d28
movq 0x20(%rbx), %r15
movq 0x28(%rbx), %rbp
cmpq %rbp, %r15
je 0x813e
cmpl $0x2, 0x8(%r15)
jne 0x80f0
movq %r15, %rdi
callq 0x9b30
movq %rax, %r12
movl 0xc(%rax), %esi
movq %rbx, %rdi
callq 0x90a4
cmpl $0x7, 0x10(%r12)
jne 0x80f6
addq $0x10, %r15
jmp 0x80c6
movq %rax, %r13
cmpb $0x1, 0x60(%rax)
jne 0x80f0
cmpl $0x2, 0x64(%r13)
jne 0x80f0
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x10b56
testb %al, %al
jne 0x80f0
movl 0x8(%r13), %eax
movq 0x38(%rbx), %rcx
imulq $0x148, %rax, %rax      # imm = 0x148
testb $0xc, 0x60(%rcx,%rax)
je 0x80f0
movq (%rbx), %rax
movq %rbx, %rdi
movq %r12, %rsi
callq *0xe8(%rax)
jmp 0x80f0
movq 0x20(%rbx), %r15
movq 0x28(%rbx), %rbp
cmpq %rbp, %r15
je 0x81a7
cmpl $0x2, 0x8(%r15)
jne 0x81a1
movq %r15, %rdi
callq 0x9b30
movq %rax, %r12
movl 0xc(%rax), %esi
movq %rbx, %rdi
callq 0x90a4
movq %rax, %r13
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x10b56
testb %al, %al
jne 0x81a1
cmpl $0x7, 0x10(%r12)
je 0x81a1
cmpb $0x1, 0x60(%r13)
jne 0x81a1
cmpl $0x9, 0x64(%r13)
jne 0x81a1
movq (%rbx), %rax
movq %rbx, %rdi
movq %r12, %rsi
callq *0xf0(%rax)
addq $0x10, %r15
jmp 0x8146
movq 0x20(%rbx), %r15
movq 0x28(%rbx), %rbp
cmpq %rbp, %r15
je 0x8223
cmpl $0x2, 0x8(%r15)
jne 0x821d
movq %r15, %rdi
callq 0x9b30
movq %rax, %r12
movl 0xc(%rax), %esi
movq %rbx, %rdi
callq 0x90a4
cmpl $0x7, 0x10(%r12)
je 0x821d
movq %rax, %r13
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x10b56
testb %al, %al
jne 0x821d
cmpb $0x1, 0x60(%r13)
jne 0x821d
movl 0x10(%r12), %eax
orl $0x2, %eax
cmpl $0x3, %eax
jne 0x821d
movl 0x8(%r12), %esi
movq %rbx, %rdi
callq 0x115ea
testb %al, %al
je 0x821d
movq %rbx, %rdi
movq %r12, %rsi
callq 0x785c
addq $0x10, %r15
jmp 0x81af
movq 0x20(%rbx), %r15
movq 0x28(%rbx), %rbp
cmpq %rbp, %r15
je 0x8292
cmpl $0x2, 0x8(%r15)
jne 0x828c
movq %r15, %rdi
callq 0x9b30
movq %rax, %r12
movl 0xc(%rax), %esi
movq %rbx, %rdi
callq 0x90a4
cmpl $0x7, 0x10(%r12)
je 0x828c
movq %rax, %r13
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x10b56
testb %al, %al
jne 0x828c
cmpb $0x1, 0x60(%r13)
jne 0x828c
movl 0x64(%r13), %eax
cmpl $0xa, %eax
je 0x827d
testl %eax, %eax
jne 0x828c
movq (%rbx), %rax
movq %rbx, %rdi
movq %r12, %rsi
callq *0xf8(%rax)
addq $0x10, %r15
jmp 0x822b
movq 0x118(%rbx), %r15
movq 0x120(%rbx), %r12
xorl %ebp, %ebp
cmpq %r12, %r15
je 0x82cc
movl (%r15), %esi
movq %rbx, %rdi
callq 0x9c0e
cmpl $0x4, 0x10(%rax)
jne 0x82c6
movq %rbx, %rdi
movq %rax, %rsi
callq 0x7ae4
movb $0x1, %bpl
addq $0x4, %r15
jmp 0x82a2
testb $0x1, %bpl
je 0x82e1
leaq 0x875ae(%rip), %rsi     # 0x8f887
movq %rbx, %rdi
callq 0x928e
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x180(%rax)
leaq 0x87052(%rip), %rsi     # 0x8f346
movq %rbx, %rdi
callq 0x9c24
movq %rbx, %rdi
callq 0x22d28
leaq 0x87063(%rip), %rdx     # 0x8f36e
movq %rbx, %rdi
movq %r14, %rsi
callq 0x9ce0
leaq 0x788(%rbx), %r14
movq 0x788(%rbx), %r15
movq 0x790(%rbx), %r12
movq %rbx, %rdi
cmpq %r12, %r15
je 0x8341
movq %r15, %rsi
callq 0x9da6
addq $0x20, %r15
jmp 0x832b
callq 0x3650a
movq %r14, %rdi
callq 0x9e62
movq %rbx, %rdi
callq 0x22dba
leaq 0x8752a(%rip), %rsi     # 0x8f887
movq %rbx, %rdi
callq 0x928e
leaq 0x8700d(%rip), %rsi     # 0x8f379
movq %rbx, %rdi
callq 0x9e6a
movq %rbx, %rdi
callq 0x12fa4
cmpl $0x5, 0xb8(%rax)
jne 0x8394
leaq 0x86fff(%rip), %rsi     # 0x8f38b
movq %rbx, %rdi
callq 0x9f26
leaq 0x874ec(%rip), %rsi     # 0x8f887
movq %rbx, %rdi
callq 0x928e
movq 0x118(%rbx), %r12
movq 0x120(%rbx), %r13
xorl %ebp, %ebp
leaq 0x8(%rsp), %r14
leaq 0x916c2(%rip), %r15     # 0x99a81
cmpq %r13, %r12
je 0x8403
movl (%r12), %esi
movq %rbx, %rdi
callq 0x9c0e
cmpl $0x6, 0x10(%rax)
jne 0x83fd
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x2619e
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x953a
movq %r14, %rdi
callq 0x6548
movb $0x1, %bpl
addq $0x4, %r12
jmp 0x83bf
testb $0x1, %bpl
je 0x8418
leaq 0x87477(%rip), %rsi     # 0x8f887
movq %rbx, %rdi
callq 0x928e
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