// File: rossy[P]crossc/SPIRV-Cross/spirv_msl.cpp
// Function: spirv_cross::CompilerMSL::emit_resources()
void CompilerMSL::emit_resources()
{
	// Output non-builtin interface structs. These include local function structs
	// and structs nested within uniform and read-write buffers.
	unordered_set<uint32_t> declared_structs;
	for (auto &id : ir.ids)
	{
		if (id.get_type() == TypeType)
		{
			auto &type = id.get<SPIRType>();
			uint32_t type_id = type.self;

			bool is_struct = (type.basetype == SPIRType::Struct) && type.array.empty();
			bool is_block =
			    has_decoration(type.self, DecorationBlock) || has_decoration(type.self, DecorationBufferBlock);

			bool is_builtin_block = is_block && is_builtin_type(type);
			bool is_declarable_struct = is_struct && !is_builtin_block;

			// We'll declare this later.
			if (stage_out_var_id && get<SPIRVariable>(stage_out_var_id).basetype == type_id)
				is_declarable_struct = false;
			if (stage_in_var_id && get<SPIRVariable>(stage_in_var_id).basetype == type_id)
				is_declarable_struct = false;

			// Align and emit declarable structs...but avoid declaring each more than once.
			if (is_declarable_struct && declared_structs.count(type_id) == 0)
			{
				declared_structs.insert(type_id);

				if (has_decoration(type_id, DecorationCPacked))
					align_struct(type);

				emit_struct(type);
			}
		}
	}

	declare_constant_arrays();
	declare_undefined_values();

	// Emit the special [[stage_in]] and [[stage_out]] interface blocks which we created.
	emit_interface_block(stage_out_var_id);
	emit_interface_block(stage_in_var_id);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x13cb0
movq -0x98(%rbp), %rax
addq $0x8, %rax
addq $0x18, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0xf940
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rdi
callq 0xf970
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0xf9a0
testb $0x1, %al
jne 0xf7276
jmp 0xf752d
leaq -0x50(%rbp), %rdi
callq 0xf9e0
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
callq 0xfa00
movl %eax, -0x9c(%rbp)
jmp 0xf7294
movl -0x9c(%rbp), %eax
cmpl $0x1, %eax
jne 0xf751d
movq -0x60(%rbp), %rdi
callq 0xfa20
movq %rax, -0xa8(%rbp)
jmp 0xf72b5
movq -0xa8(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x7c(%rbp)
movq -0x78(%rbp), %rcx
xorl %eax, %eax
cmpl $0xc, 0xc(%rcx)
movb %al, -0xa9(%rbp)
jne 0xf72ef
movq -0x78(%rbp), %rdi
addq $0x20, %rdi
callq 0x8690
movb %al, -0xa9(%rbp)
movq -0x98(%rbp), %rdi
movb -0xa9(%rbp), %al
andb $0x1, %al
movb %al, -0x7d(%rbp)
movq -0x78(%rbp), %rax
movl 0x8(%rax), %esi
movl $0x2, %edx
callq 0x1f560
movb %al, -0xaa(%rbp)
jmp 0xf731a
movb -0xaa(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0xab(%rbp)
jne 0xf735d
jmp 0xf732f
movq -0x98(%rbp), %rdi
movq -0x78(%rbp), %rax
movl 0x8(%rax), %esi
movl $0x3, %edx
callq 0x1f560
movb %al, -0xac(%rbp)
jmp 0xf734f
movb -0xac(%rbp), %al
movb %al, -0xab(%rbp)
jmp 0xf735d
movb -0xab(%rbp), %al
andb $0x1, %al
movb %al, -0x7e(%rbp)
xorl %eax, %eax
testb $0x1, -0x7e(%rbp)
movb %al, -0xad(%rbp)
je 0xf739c
movq -0x98(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x206c0
movb %al, -0xae(%rbp)
jmp 0xf738e
movb -0xae(%rbp), %al
movb %al, -0xad(%rbp)
jmp 0xf739c
movb -0xad(%rbp), %al
andb $0x1, %al
movb %al, -0x7f(%rbp)
xorl %eax, %eax
testb $0x1, -0x7d(%rbp)
movb %al, -0xaf(%rbp)
je 0xf73c0
movb -0x7f(%rbp), %al
xorb $-0x1, %al
movb %al, -0xaf(%rbp)
movq -0x98(%rbp), %rax
movb -0xaf(%rbp), %cl
andb $0x1, %cl
movb %cl, -0x80(%rbp)
cmpl $0x0, 0x930(%rax)
je 0xf7426
movq -0x98(%rbp), %rdi
movl 0x930(%rdi), %esi
callq 0xfec0
movq %rax, -0xb8(%rbp)
jmp 0xf73f7
movq -0xb8(%rbp), %rax
movl 0xc(%rax), %eax
cmpl -0x7c(%rbp), %eax
jne 0xf7426
movb $0x0, -0x80(%rbp)
jmp 0xf7426
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x13900
jmp 0xf758a
movq -0x98(%rbp), %rax
cmpl $0x0, 0x92c(%rax)
je 0xf7464
movq -0x98(%rbp), %rdi
movl 0x92c(%rdi), %esi
callq 0xfec0
movq %rax, -0xc0(%rbp)
jmp 0xf7451
movq -0xc0(%rbp), %rax
movl 0xc(%rax), %eax
cmpl -0x7c(%rbp), %eax
jne 0xf7464
movb $0x0, -0x80(%rbp)
testb $0x1, -0x80(%rbp)
je 0xf751b
leaq -0x40(%rbp), %rdi
leaq -0x7c(%rbp), %rsi
callq 0x13520
movq %rax, -0xc8(%rbp)
jmp 0xf7484
movq -0xc8(%rbp), %rax
cmpq $0x0, %rax
jne 0xf751b
leaq -0x40(%rbp), %rdi
leaq -0x7c(%rbp), %rsi
callq 0x2e890
movb %dl, -0xd1(%rbp)
movq %rax, -0xd0(%rbp)
jmp 0xf74b1
movq -0x98(%rbp), %rdi
movb -0xd1(%rbp), %al
movq -0xd0(%rbp), %rcx
movq %rcx, -0x90(%rbp)
movb %al, -0x88(%rbp)
movl -0x7c(%rbp), %esi
movl $0xa, %edx
callq 0x1f560
movb %al, -0xd2(%rbp)
jmp 0xf74e7
movb -0xd2(%rbp), %al
testb $0x1, %al
jne 0xf74f3
jmp 0xf7507
movq -0x98(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0xfa930
jmp 0xf7505
jmp 0xf7507
movq -0x98(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x5bf00
jmp 0xf7519
jmp 0xf751b
jmp 0xf751d
jmp 0xf751f
leaq -0x50(%rbp), %rdi
callq 0xfbd0
jmp 0xf7260
movq -0x98(%rbp), %rdi
callq 0xfb370
jmp 0xf753b
movq -0x98(%rbp), %rdi
movq (%rdi), %rax
movq 0x180(%rax), %rax
callq *%rax
jmp 0xf7550
movq -0x98(%rbp), %rdi
movl 0x930(%rdi), %esi
callq 0xfb590
jmp 0xf7564
movq -0x98(%rbp), %rdi
movl 0x92c(%rdi), %esi
callq 0xfb590
jmp 0xf7578
leaq -0x40(%rbp), %rdi
callq 0x13900
addq $0xe0, %rsp
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x7640
nopw %cs:(%rax,%rax)