// File: rossy[P]crossc/SPIRV-Cross/spirv_msl.cpp
// Function: spirv_cross::CompilerMSL::builtin_to_glsl[abi:cxx11](spv::BuiltIn, spv::StorageClass)
string CompilerMSL::builtin_to_glsl(BuiltIn builtin, StorageClass storage)
{
	switch (builtin)
	{

	// Override GLSL compiler strictness
	case BuiltInVertexId:
		return "gl_VertexID";
	case BuiltInInstanceId:
		return "gl_InstanceID";
	case BuiltInVertexIndex:
		return "gl_VertexIndex";
	case BuiltInInstanceIndex:
		return "gl_InstanceIndex";
	case BuiltInBaseVertex:
		return "gl_BaseVertex";
	case BuiltInBaseInstance:
		return "gl_BaseInstance";
	case BuiltInDrawIndex:
		SPIRV_CROSS_THROW("DrawIndex is not supported in MSL.");

	// When used in the entry function, output builtins are qualified with output struct name.
	// Test storage class as NOT Input, as output builtins might be part of generic type.
	case BuiltInViewportIndex:
		if (!msl_options.supports_msl_version(2, 0))
			SPIRV_CROSS_THROW("ViewportIndex requires Metal 2.0.");
		/* fallthrough */
	case BuiltInPosition:
	case BuiltInPointSize:
	case BuiltInClipDistance:
	case BuiltInCullDistance:
	case BuiltInLayer:
	case BuiltInFragDepth:
	case BuiltInSampleMask:
		if (storage != StorageClassInput && current_function && (current_function->self == ir.default_entry_point))
			return stage_out_var_name + "." + CompilerGLSL::builtin_to_glsl(builtin, storage);

		break;

	default:
		break;
	}

	return CompilerGLSL::builtin_to_glsl(builtin, storage);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0xe8(%rbp)
movq %rdi, %rax
movq %rax, -0xe0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xd8(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0xcc(%rbp)
subl $0x2, %eax
jb 0x10d7fe
jmp 0x10d389
movl -0xcc(%rbp), %eax
addl $-0x3, %eax
subl $0x2, %eax
jb 0x10d7fe
jmp 0x10d39d
movl -0xcc(%rbp), %eax
subl $0x5, %eax
je 0x10d461
jmp 0x10d3ae
movl -0xcc(%rbp), %eax
subl $0x6, %eax
je 0x10d4b5
jmp 0x10d3bf
movl -0xcc(%rbp), %eax
subl $0x9, %eax
je 0x10d7fe
jmp 0x10d3d0
movl -0xcc(%rbp), %eax
subl $0xa, %eax
je 0x10d711
jmp 0x10d3e1
movl -0xcc(%rbp), %eax
subl $0x14, %eax
je 0x10d7fe
jmp 0x10d3f2
movl -0xcc(%rbp), %eax
subl $0x16, %eax
je 0x10d7fe
jmp 0x10d403
movl -0xcc(%rbp), %eax
subl $0x2a, %eax
je 0x10d509
jmp 0x10d414
movl -0xcc(%rbp), %eax
subl $0x2b, %eax
je 0x10d55d
jmp 0x10d425
movl -0xcc(%rbp), %eax
subl $0x1148, %eax           # imm = 0x1148
je 0x10d5b1
jmp 0x10d438
movl -0xcc(%rbp), %eax
subl $0x1149, %eax           # imm = 0x1149
je 0x10d605
jmp 0x10d44b
movl -0xcc(%rbp), %eax
subl $0x114a, %eax           # imm = 0x114A
je 0x10d659
jmp 0x10d8e2
leaq -0x19(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x7650
movq -0xe8(%rbp), %rdi
movq -0xf0(%rbp), %rdx
leaq 0x3602b(%rip), %rsi     # 0x1434b1
callq 0x7520
jmp 0x10d48d
leaq -0x19(%rbp), %rdi
callq 0x73d0
jmp 0x10d8fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x19(%rbp), %rdi
callq 0x73d0
jmp 0x10d90d
leaq -0x2d(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x7650
movq -0xe8(%rbp), %rdi
movq -0xf8(%rbp), %rdx
leaq 0x3603d(%rip), %rsi     # 0x143517
callq 0x7520
jmp 0x10d4e1
leaq -0x2d(%rbp), %rdi
callq 0x73d0
jmp 0x10d8fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x2d(%rbp), %rdi
callq 0x73d0
jmp 0x10d90d
leaq -0x2e(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x7650
movq -0xe8(%rbp), %rdi
movq -0x100(%rbp), %rdx
leaq 0x35ff7(%rip), %rsi     # 0x143525
callq 0x7520
jmp 0x10d535
leaq -0x2e(%rbp), %rdi
callq 0x73d0
jmp 0x10d8fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x2e(%rbp), %rdi
callq 0x73d0
jmp 0x10d90d
leaq -0x2f(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x7650
movq -0xe8(%rbp), %rdi
movq -0x108(%rbp), %rdx
leaq 0x35fb2(%rip), %rsi     # 0x143534
callq 0x7520
jmp 0x10d589
leaq -0x2f(%rbp), %rdi
callq 0x73d0
jmp 0x10d8fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x2f(%rbp), %rdi
callq 0x73d0
jmp 0x10d90d
leaq -0x30(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x7650
movq -0xe8(%rbp), %rdi
movq -0x110(%rbp), %rdx
leaq 0x36117(%rip), %rsi     # 0x1436ed
callq 0x7520
jmp 0x10d5dd
leaq -0x30(%rbp), %rdi
callq 0x73d0
jmp 0x10d8fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x73d0
jmp 0x10d90d
leaq -0x31(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x7650
movq -0xe8(%rbp), %rdi
movq -0x118(%rbp), %rdx
leaq 0x3610e(%rip), %rsi     # 0x143738
callq 0x7520
jmp 0x10d631
leaq -0x31(%rbp), %rdi
callq 0x73d0
jmp 0x10d8fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x73d0
jmp 0x10d90d
movb $0x1, -0x5a(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0x128(%rbp)
leaq -0x59(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x7650
movq -0x120(%rbp), %rdx
leaq 0x3fd1e(%rip), %rsi     # 0x14d3aa
leaq -0x58(%rbp), %rdi
callq 0x7520
jmp 0x10d697
movq -0x128(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x9c50
jmp 0x10d6a9
movq -0x128(%rbp), %rdi
movb $0x0, -0x5a(%rbp)
leaq 0xa071d(%rip), %rsi     # 0x1addd8
leaq -0x103a32(%rip), %rdx   # 0x9c90
callq 0x7610
jmp 0x10d916
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x10d6ef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x7708
leaq -0x59(%rbp), %rdi
callq 0x73d0
testb $0x1, -0x5a(%rbp)
jne 0x10d700
jmp 0x10d70c
movq -0x128(%rbp), %rdi
callq 0x72c0
jmp 0x10d90d
movq -0xd8(%rbp), %rdi
addq $0x7cc, %rdi            # imm = 0x7CC
movl $0x2, %esi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0x1160d0
testb $0x1, %al
jne 0x10d7fc
movb $0x1, -0x82(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0x138(%rbp)
leaq -0x81(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x7650
movq -0x130(%rbp), %rdx
leaq 0x3fc71(%rip), %rsi     # 0x14d3df
leaq -0x80(%rbp), %rdi
callq 0x7520
jmp 0x10d779
movq -0x138(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x9c50
jmp 0x10d78b
movq -0x138(%rbp), %rdi
movb $0x0, -0x82(%rbp)
leaq 0xa0638(%rip), %rsi     # 0x1addd8
leaq -0x103b17(%rip), %rdx   # 0x9c90
callq 0x7610
jmp 0x10d916
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x10d7d4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x7708
leaq -0x81(%rbp), %rdi
callq 0x73d0
testb $0x1, -0x82(%rbp)
jne 0x10d7eb
jmp 0x10d7f7
movq -0x138(%rbp), %rdi
callq 0x72c0
jmp 0x10d90d
jmp 0x10d7fe
cmpl $0x1, -0x18(%rbp)
je 0x10d8e0
movq -0xd8(%rbp), %rax
cmpq $0x0, 0x148(%rax)
je 0x10d8e0
movq -0xd8(%rbp), %rcx
movq 0x148(%rcx), %rax
movl 0x8(%rax), %eax
cmpl 0x108(%rcx), %eax
jne 0x10d8e0
movq -0xd8(%rbp), %rsi
addq $0x980, %rsi            # imm = 0x980
leaq 0x374de(%rip), %rdx     # 0x144d2d
leaq -0xa8(%rbp), %rdi
callq 0x2f8c0
movq -0xd8(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
leaq -0xc8(%rbp), %rdi
callq 0x82ba0
jmp 0x10d876
movq -0xe8(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
leaq -0xc8(%rbp), %rdx
callq 0x2f7f0
jmp 0x10d892
leaq -0xc8(%rbp), %rdi
callq 0x7708
leaq -0xa8(%rbp), %rdi
callq 0x7708
jmp 0x10d8fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x10d8d2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x7708
leaq -0xa8(%rbp), %rdi
callq 0x7708
jmp 0x10d90d
jmp 0x10d8e4
jmp 0x10d8e4
movq -0xd8(%rbp), %rsi
movq -0xe8(%rbp), %rdi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
callq 0x82ba0
movq -0xe0(%rbp), %rax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x7640
nopw %cs:(%rax,%rax)