// File: rossy[P]crossc/SPIRV-Cross/spirv_cross.cpp
// Function: spirv_cross::Compiler::parse_fixup()
void Compiler::parse_fixup()
{
	// Figure out specialization constants for work group sizes.
	for (auto &id : ir.ids)
	{
		if (id.get_type() == TypeConstant)
		{
			auto &c = id.get<SPIRConstant>();
			if (ir.meta[c.self].decoration.builtin && ir.meta[c.self].decoration.builtin_type == BuiltInWorkgroupSize)
			{
				// In current SPIR-V, there can be just one constant like this.
				// All entry points will receive the constant value.
				for (auto &entry : ir.entry_points)
				{
					entry.second.workgroup_size.constant = c.self;
					entry.second.workgroup_size.x = c.scalar(0, 0);
					entry.second.workgroup_size.y = c.scalar(0, 1);
					entry.second.workgroup_size.z = c.scalar(0, 2);
				}
			}
		}
		else if (id.get_type() == TypeVariable)
		{
			auto &var = id.get<SPIRVariable>();
			if (var.storage == StorageClassPrivate || var.storage == StorageClassWorkgroup ||
			    var.storage == StorageClassOutput)
				global_variables.push_back(var.self);
			if (variable_storage_is_aliased(var))
				aliased_variables.push_back(var.self);
		}
	}

	fixup_type_alias();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
addq $0x8, %rax
addq $0x18, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0xf940
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0xf970
movq %rax, -0x20(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0xf9a0
testb $0x1, %al
jne 0x1f180
jmp 0x1f34d
leaq -0x18(%rbp), %rdi
callq 0xf9e0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0xfa00
cmpl $0x3, %eax
jne 0x1f2bd
movq -0x28(%rbp), %rdi
callq 0x2f2f0
movq -0x60(%rbp), %rdi
movq %rax, -0x30(%rbp)
addq $0x8, %rdi
addq $0x30, %rdi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %esi
callq 0xead0
testb $0x1, 0xcc(%rax)
je 0x1f2b8
movq -0x60(%rbp), %rdi
addq $0x8, %rdi
addq $0x30, %rdi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %esi
callq 0xead0
cmpl $0x19, 0xa0(%rax)
jne 0x1f2b8
movq -0x60(%rbp), %rax
addq $0x8, %rax
addq $0xc8, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x2f4a0
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
callq 0x2f4d0
movq %rax, -0x48(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2f500
testb $0x1, %al
jne 0x1f239
jmp 0x1f2b6
leaq -0x40(%rbp), %rdi
callq 0x2f530
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0xb4(%rax)
movq -0x30(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x2f560
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0xa8(%rax)
movq -0x30(%rbp), %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x2f560
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0xac(%rax)
movq -0x30(%rbp), %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2f560
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0xb0(%rax)
leaq -0x40(%rbp), %rdi
callq 0x2f590
jmp 0x1f226
jmp 0x1f2b8
jmp 0x1f33d
movq -0x28(%rbp), %rdi
callq 0xfa00
cmpl $0x2, %eax
jne 0x1f33b
movq -0x28(%rbp), %rdi
callq 0xfd10
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpl $0x6, 0x10(%rax)
je 0x1f2f6
movq -0x58(%rbp), %rax
cmpl $0x4, 0x10(%rax)
je 0x1f2f6
movq -0x58(%rbp), %rax
cmpl $0x3, 0x10(%rax)
jne 0x1f30e
movq -0x60(%rbp), %rdi
addq $0x118, %rdi            # imm = 0x118
movq -0x58(%rbp), %rsi
addq $0x8, %rsi
callq 0x88f0
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x1f3f0
testb $0x1, %al
jne 0x1f321
jmp 0x1f339
movq -0x60(%rbp), %rdi
addq $0x130, %rdi            # imm = 0x130
movq -0x58(%rbp), %rsi
addq $0x8, %rsi
callq 0x88f0
jmp 0x1f33b
jmp 0x1f33d
jmp 0x1f33f
leaq -0x18(%rbp), %rdi
callq 0xfbd0
jmp 0x1f16a
movq -0x60(%rbp), %rdi
callq 0x21fd0
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)