// File: rossy[P]crossc/SPIRV-Cross/spirv_msl.cpp
// Function: spirv_cross::CompilerMSL::extract_global_variables_from_functions()
void CompilerMSL::extract_global_variables_from_functions()
{
	// Uniforms
	unordered_set<uint32_t> global_var_ids;
	for (auto &id : ir.ids)
	{
		if (id.get_type() == TypeVariable)
		{
			auto &var = id.get<SPIRVariable>();
			if (var.storage == StorageClassInput || var.storage == StorageClassOutput ||
			    var.storage == StorageClassUniform || var.storage == StorageClassUniformConstant ||
			    var.storage == StorageClassPushConstant || var.storage == StorageClassStorageBuffer)
			{
				global_var_ids.insert(var.self);
			}
		}
	}

	// Local vars that are declared in the main function and accessed directly by a function
	auto &entry_func = get<SPIRFunction>(ir.default_entry_point);
	for (auto &var : entry_func.local_variables)
		if (get<SPIRVariable>(var).storage != StorageClassFunction)
			global_var_ids.insert(var);

	std::set<uint32_t> added_arg_ids;
	unordered_set<uint32_t> processed_func_ids;
	extract_global_variables_from_function(ir.default_entry_point, added_arg_ids, global_var_ids, processed_func_ids);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x130(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x13cb0
movq -0x130(%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 0xf66f6
jmp 0xf67d8
leaq -0x50(%rbp), %rdi
callq 0xf9e0
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
callq 0xfa00
movl %eax, -0x134(%rbp)
jmp 0xf6714
movl -0x134(%rbp), %eax
cmpl $0x2, %eax
jne 0xf67c8
movq -0x60(%rbp), %rdi
callq 0xfd10
movq %rax, -0x140(%rbp)
jmp 0xf6735
movq -0x140(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpl $0x1, 0x10(%rax)
je 0xf677c
movq -0x78(%rbp), %rax
cmpl $0x3, 0x10(%rax)
je 0xf677c
movq -0x78(%rbp), %rax
cmpl $0x2, 0x10(%rax)
je 0xf677c
movq -0x78(%rbp), %rax
cmpl $0x0, 0x10(%rax)
je 0xf677c
movq -0x78(%rbp), %rax
cmpl $0x9, 0x10(%rax)
je 0xf677c
movq -0x78(%rbp), %rax
cmpl $0xc, 0x10(%rax)
jne 0xf67c6
movq -0x78(%rbp), %rsi
addq $0x8, %rsi
leaq -0x40(%rbp), %rdi
callq 0x2e890
movb %dl, -0x149(%rbp)
movq %rax, -0x148(%rbp)
jmp 0xf679c
movb -0x149(%rbp), %al
movq -0x148(%rbp), %rcx
movq %rcx, -0x88(%rbp)
movb %al, -0x80(%rbp)
jmp 0xf67c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xf6979
jmp 0xf67c8
jmp 0xf67ca
leaq -0x50(%rbp), %rdi
callq 0xfbd0
jmp 0xf66e0
movq -0x130(%rbp), %rdi
movl 0x108(%rdi), %esi
callq 0x106d0
movq %rax, -0x158(%rbp)
jmp 0xf67f3
movq -0x158(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
addq $0x48, %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rdi
callq 0x86d0
movq %rax, -0xa0(%rbp)
movq -0x98(%rbp), %rdi
callq 0x8700
movq %rax, -0xa8(%rbp)
leaq -0xa0(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x8730
testb $0x1, %al
jne 0xf6855
jmp 0xf68df
leaq -0xa0(%rbp), %rdi
callq 0x8770
movq -0x130(%rbp), %rdi
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
movl (%rax), %esi
callq 0xfec0
movq %rax, -0x160(%rbp)
jmp 0xf6886
movq -0x160(%rbp), %rax
cmpl $0x7, 0x10(%rax)
je 0xf68cc
movq -0xb0(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x2e890
movb %dl, -0x169(%rbp)
movq %rax, -0x168(%rbp)
jmp 0xf68b2
movb -0x169(%rbp), %al
movq -0x168(%rbp), %rcx
movq %rcx, -0xc0(%rbp)
movb %al, -0xb8(%rbp)
jmp 0xf68ce
leaq -0xa0(%rbp), %rdi
callq 0x8790
jmp 0xf6839
leaq -0xf0(%rbp), %rdi
movq %rdi, -0x180(%rbp)
callq 0x113c30
leaq -0x128(%rbp), %rdi
movq %rdi, -0x178(%rbp)
callq 0x13cb0
movq -0x130(%rbp), %rdi
movq -0x180(%rbp), %rdx
movq -0x178(%rbp), %r8
movl 0x108(%rdi), %esi
leaq -0x40(%rbp), %rcx
callq 0xf92b0
jmp 0xf692b
leaq -0x128(%rbp), %rdi
callq 0x13900
leaq -0xf0(%rbp), %rdi
callq 0x113c50
leaq -0x40(%rbp), %rdi
callq 0x13900
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x13900
leaq -0xf0(%rbp), %rdi
callq 0x113c50
leaq -0x40(%rbp), %rdi
callq 0x13900
movq -0x68(%rbp), %rdi
callq 0x7640
nopl (%rax,%rax)