// File: /workspace/github_cpp_makefile_star2_O2/rossy[P]crossc/SPIRV-Cross/spirv_msl.cpp
// Function: spirv_cross::CompilerMSL::build_implicit_builtins()
void CompilerMSL::build_implicit_builtins()
{
	bool need_sample_pos = active_input_builtins.get(BuiltInSamplePosition);
	if (need_subpass_input || need_sample_pos)
	{
		bool has_frag_coord = false;
		bool has_sample_id = false;

		for (auto &id : ir.ids)
		{
			if (id.get_type() != TypeVariable)
				continue;

			auto &var = id.get<SPIRVariable>();

			if (need_subpass_input && var.storage == StorageClassInput && ir.meta[var.self].decoration.builtin &&
			    ir.meta[var.self].decoration.builtin_type == BuiltInFragCoord)
			{
				builtin_frag_coord_id = var.self;
				has_frag_coord = true;
				break;
			}

			if (need_sample_pos && var.storage == StorageClassInput && ir.meta[var.self].decoration.builtin &&
			    ir.meta[var.self].decoration.builtin_type == BuiltInSampleId)
			{
				builtin_sample_id_id = var.self;
				has_sample_id = true;
				break;
			}
		}

		if (!has_frag_coord && need_subpass_input)
		{
			uint32_t offset = ir.increase_bound_by(3);
			uint32_t type_id = offset;
			uint32_t type_ptr_id = offset + 1;
			uint32_t var_id = offset + 2;

			// Create gl_FragCoord.
			SPIRType vec4_type;
			vec4_type.basetype = SPIRType::Float;
			vec4_type.width = 32;
			vec4_type.vecsize = 4;
			set<SPIRType>(type_id, vec4_type);

			SPIRType vec4_type_ptr;
			vec4_type_ptr = vec4_type;
			vec4_type_ptr.pointer = true;
			vec4_type_ptr.parent_type = type_id;
			vec4_type_ptr.storage = StorageClassInput;
			auto &ptr_type = set<SPIRType>(type_ptr_id, vec4_type_ptr);
			ptr_type.self = type_id;

			set<SPIRVariable>(var_id, type_ptr_id, StorageClassInput);
			set_decoration(var_id, DecorationBuiltIn, BuiltInFragCoord);
			builtin_frag_coord_id = var_id;
		}

		if (!has_sample_id && need_sample_pos)
		{
			uint32_t offset = ir.increase_bound_by(3);
			uint32_t type_id = offset;
			uint32_t type_ptr_id = offset + 1;
			uint32_t var_id = offset + 2;

			// Create gl_SampleID.
			SPIRType uint_type;
			uint_type.basetype = SPIRType::UInt;
			uint_type.width = 32;
			set<SPIRType>(type_id, uint_type);

			SPIRType uint_type_ptr;
			uint_type_ptr = uint_type;
			uint_type_ptr.pointer = true;
			uint_type_ptr.parent_type = type_id;
			uint_type_ptr.storage = StorageClassInput;
			auto &ptr_type = set<SPIRType>(type_ptr_id, uint_type_ptr);
			ptr_type.self = type_id;

			set<SPIRVariable>(var_id, type_ptr_id, StorageClassInput);
			set_decoration(var_id, DecorationBuiltIn, BuiltInSampleId);
			builtin_sample_id_id = var_id;
		}
	}

	if (msl_options.swizzle_texture_samples && has_sampled_images)
	{
		uint32_t offset = ir.increase_bound_by(5);
		uint32_t type_id = offset;
		uint32_t type_arr_id = offset + 1;
		uint32_t struct_id = offset + 2;
		uint32_t struct_ptr_id = offset + 3;
		uint32_t var_id = offset + 4;

		// Create a buffer to hold the swizzle constants.
		SPIRType uint_type;
		uint_type.basetype = SPIRType::UInt;
		uint_type.width = 32;
		set<SPIRType>(type_id, uint_type);

		SPIRType uint_type_arr = uint_type;
		uint_type_arr.array.push_back(0);
		uint_type_arr.array_size_literal.push_back(true);
		uint_type_arr.parent_type = type_id;
		set<SPIRType>(type_arr_id, uint_type_arr);
		set_decoration(type_arr_id, DecorationArrayStride, 4);

		SPIRType struct_type;
		struct_type.basetype = SPIRType::Struct;
		struct_type.member_types.push_back(type_arr_id);
		auto &type = set<SPIRType>(struct_id, struct_type);
		type.self = struct_id;
		set_decoration(struct_id, DecorationBlock);
		set_name(struct_id, "spvAux");
		set_member_name(struct_id, 0, "swizzleConst");
		set_member_decoration(struct_id, 0, DecorationOffset, 0);

		SPIRType struct_type_ptr = struct_type;
		struct_type_ptr.pointer = true;
		struct_type_ptr.parent_type = struct_id;
		struct_type_ptr.storage = StorageClassUniform;
		auto &ptr_type = set<SPIRType>(struct_ptr_id, struct_type_ptr);
		ptr_type.self = struct_id;

		set<SPIRVariable>(var_id, struct_ptr_id, StorageClassUniform);
		set_name(var_id, "spvAuxBuffer");
		// This should never match anything.
		set_decoration(var_id, DecorationDescriptorSet, 0xFFFFFFFE);
		set_decoration(var_id, DecorationBinding, msl_options.aux_buffer_index);
		aux_buffer_id = var_id;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x398, %rsp            # imm = 0x398
movq %rdi, %rbx
movq 0x2d0(%rdi), %r12
btl $0x13, %r12d
setae %al
movb 0x398(%rdi), %cl
movl %ecx, %edx
xorb $0x1, %dl
movabsq $0x100000001, %rbp      # imm = 0x100000001
movabsq $0x2000000005, %r13     # imm = 0x2000000005
testb %dl, %al
jne 0x6e437
leaq 0x8(%rbx), %r14
movq 0x20(%rbx), %r15
movq 0x28(%rbx), %rbp
cmpq %rbp, %r15
setne %r13b
je 0x6e04d
cmpl $0x2, 0x8(%r15)
jne 0x6e030
movq %r15, %rdi
callq 0x9b30
movb 0x398(%rbx), %cl
movl 0x10(%rax), %edx
cmpb $0x1, %cl
jne 0x6e000
cmpl $0x1, %edx
jne 0x6e000
movl 0x8(%rax), %esi
movq 0x38(%rbx), %rdi
imulq $0x148, %rsi, %r8       # imm = 0x148
cmpb $0x1, 0xcc(%rdi,%r8)
jne 0x6e000
addq %r8, %rdi
cmpl $0xf, 0xa0(%rdi)
je 0x6e039
btl $0x13, %r12d
jae 0x6e030
cmpl $0x1, %edx
jne 0x6e030
movl 0x8(%rax), %eax
movq 0x38(%rbx), %rdx
imulq $0x148, %rax, %rsi      # imm = 0x148
cmpb $0x1, 0xcc(%rdx,%rsi)
jne 0x6e030
addq %rsi, %rdx
cmpl $0x12, 0xa0(%rdx)
je 0x6e047
addq $0x10, %r15
jmp 0x6dfac
movl %esi, 0x7c0(%rbx)
xorl %r13d, %r13d
jmp 0x6e238
movl %eax, 0x7c4(%rbx)
testb $0x1, %cl
je 0x6e238
pushq $0x3
popq %rsi
movq %r14, %rdi
callq 0x202bc
leaq 0x1e0(%rsp), %rcx
andl $0x0, -0xc8(%rcx)
leaq 0x79379(%rip), %rbp     # 0xe73f0
addq $0x10, %rbp
movq %rbp, -0xd0(%rcx)
movl $0x1, -0xb8(%rcx)
andq $0x0, -0x88(%rcx)
movl %eax, %r15d
andl $0x0, -0x80(%rcx)
leal 0x1(%r15), %eax
andq $0x0, -0x78(%rcx)
movl %eax, 0x2c0(%rsp)
movb $0x0, -0x70(%rcx)
xorps %xmm0, %xmm0
movups %xmm0, -0xb0(%rcx)
movups %xmm0, -0xa0(%rcx)
andl $0x0, -0x90(%rcx)
movl $0x8, -0x6c(%rcx)
andq $0x0, -0x58(%rcx)
movups %xmm0, -0x68(%rcx)
andq $0x0, -0x38(%rcx)
movq %rcx, -0x30(%rcx)
movq $0x1, -0x28(%rcx)
movups %xmm0, -0x20(%rcx)
movl $0x3f800000, -0x10(%rcx) # imm = 0x3F800000
movups %xmm0, -0x8(%rcx)
movabsq $0x200000000a, %rax     # imm = 0x200000000A
movq %rax, -0xc4(%rcx)
movl $0x4, -0xbc(%rcx)
leaq 0x110(%rsp), %rdx
movq %rbx, %rdi
movl %r15d, %esi
callq 0x63e9e
leaq 0x108(%rsp), %rax
movq %rbp, -0xd0(%rax)
movaps 0x21aa5(%rip), %xmm0    # 0x8fbe0
movups %xmm0, -0xc8(%rax)
movl $0x1, -0xb8(%rax)
andq $0x0, -0x88(%rax)
andl $0x0, -0x80(%rax)
andq $0x0, -0x78(%rax)
movb $0x0, -0x70(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0xb0(%rax)
movups %xmm0, -0xa0(%rax)
andl $0x0, -0x90(%rax)
movl $0x8, -0x6c(%rax)
movups %xmm0, -0x68(%rax)
andq $0x0, -0x58(%rax)
andq $0x0, -0x38(%rax)
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
leaq 0x38(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x173b0
leaq 0x38(%rsp), %rdx
movb $0x1, 0x60(%rdx)
movl %r15d, 0x9c(%rdx)
movl $0x1, 0x64(%rdx)
movl 0x2c0(%rsp), %esi
movq %rbx, %rdi
callq 0x63e9e
movl %r15d, %ebp
addl $0x2, %ebp
movl %r15d, 0x8(%rax)
leaq 0x1e8(%rsp), %rcx
movl $0x1, (%rcx)
leaq 0x2c0(%rsp), %rdx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x63ec6
pushq $0xb
popq %rdx
pushq $0xf
popq %rcx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x1206e
movl %ebp, 0x7c0(%rbx)
leaq 0x38(%rsp), %rdi
callq 0x17a3e
leaq 0x110(%rsp), %rdi
callq 0x17a3e
movabsq $0x100000001, %rbp      # imm = 0x100000001
testb %r13b, %r13b
movabsq $0x2000000005, %r13     # imm = 0x2000000005
jne 0x6e437
andl $0x80000, %r12d         # imm = 0x80000
je 0x6e437
pushq $0x3
popq %rsi
movq %r14, %rdi
callq 0x202bc
leaq 0x1e0(%rsp), %rcx
andl $0x0, -0xc8(%rcx)
leaq 0x7916d(%rip), %r15     # 0xe73f0
addq $0x10, %r15
movq %r15, -0xd0(%rcx)
movq %rbp, -0xbc(%rcx)
andq $0x0, -0x88(%rcx)
andl $0x0, -0x80(%rcx)
andq $0x0, -0x78(%rcx)
movl %eax, %r14d
movb $0x0, -0x70(%rcx)
xorps %xmm0, %xmm0
movups %xmm0, -0xb0(%rcx)
movups %xmm0, -0xa0(%rcx)
andl $0x0, -0x90(%rcx)
movl $0x8, -0x6c(%rcx)
andq $0x0, -0x58(%rcx)
movups %xmm0, -0x68(%rcx)
andq $0x0, -0x38(%rcx)
leal 0x1(%r14), %eax
movl %eax, 0x2c0(%rsp)
movq %rcx, -0x30(%rcx)
movq $0x1, -0x28(%rcx)
movups %xmm0, -0x20(%rcx)
movl $0x3f800000, -0x10(%rcx) # imm = 0x3F800000
movups %xmm0, -0x8(%rcx)
movq %r13, -0xc4(%rcx)
leaq 0x110(%rsp), %rdx
movq %rbx, %rdi
movl %r14d, %esi
callq 0x63e9e
leaq 0x108(%rsp), %rax
movq %r15, -0xd0(%rax)
movaps 0x218b0(%rip), %xmm0    # 0x8fbe0
movups %xmm0, -0xc8(%rax)
movl $0x1, -0xb8(%rax)
andq $0x0, -0x88(%rax)
andl $0x0, -0x80(%rax)
andq $0x0, -0x78(%rax)
movb $0x0, -0x70(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0xb0(%rax)
movups %xmm0, -0xa0(%rax)
andl $0x0, -0x90(%rax)
movl $0x8, -0x6c(%rax)
movups %xmm0, -0x68(%rax)
andq $0x0, -0x58(%rax)
andq $0x0, -0x38(%rax)
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
leaq 0x38(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x173b0
leaq 0x38(%rsp), %rdx
movb $0x1, 0x60(%rdx)
movl %r14d, 0x9c(%rdx)
movl $0x1, 0x64(%rdx)
movl 0x2c0(%rsp), %esi
movq %rbx, %rdi
callq 0x63e9e
movl %r14d, %ebp
addl $0x2, %ebp
movl %r14d, 0x8(%rax)
leaq 0x1e8(%rsp), %rcx
movl $0x1, (%rcx)
leaq 0x2c0(%rsp), %rdx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x63ec6
pushq $0xb
popq %rdx
pushq $0x12
popq %rcx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x1206e
movl %ebp, 0x7c4(%rbx)
leaq 0x38(%rsp), %rdi
callq 0x17a3e
leaq 0x110(%rsp), %rdi
callq 0x17a3e
movabsq $0x100000001, %rbp      # imm = 0x100000001
cmpb $0x1, 0x7df(%rbx)
jne 0x6e796
cmpb $0x1, 0x934(%rbx)
jne 0x6e796
leaq 0x8(%rbx), %rdi
pushq $0x5
popq %rsi
callq 0x202bc
leaq 0x1e0(%rsp), %rcx
andl $0x0, -0xc8(%rcx)
leaq 0x78f7d(%rip), %r15     # 0xe73f0
addq $0x10, %r15
movq %r15, -0xd0(%rcx)
movq %rbp, -0xbc(%rcx)
andq $0x0, -0x88(%rcx)
movl %eax, %r14d
andl $0x0, -0x80(%rcx)
leal 0x1(%r14), %eax
andq $0x0, -0x78(%rcx)
movl %eax, 0xc(%rsp)
movb $0x0, -0x70(%rcx)
xorps %xmm0, %xmm0
movups %xmm0, -0xb0(%rcx)
movups %xmm0, -0xa0(%rcx)
andl $0x0, -0x90(%rcx)
movl $0x8, -0x6c(%rcx)
andq $0x0, -0x58(%rcx)
movups %xmm0, -0x68(%rcx)
andq $0x0, -0x38(%rcx)
leal 0x3(%r14), %ebp
movl %ebp, 0x14(%rsp)
movq %rcx, -0x30(%rcx)
movq $0x1, -0x28(%rcx)
movups %xmm0, -0x20(%rcx)
movl $0x3f800000, -0x10(%rcx) # imm = 0x3F800000
movups %xmm0, -0x8(%rcx)
movq %r13, -0xc4(%rcx)
leaq 0x110(%rsp), %rdx
movq %rbx, %rdi
movl %r14d, %esi
callq 0x63e9e
leaq 0x38(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x1a29c
leaq 0x58(%rsp), %rdi
leaq 0x2c0(%rsp), %rsi
andl $0x0, (%rsi)
callq 0x83138
leaq 0x70(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x7f856
leaq 0x38(%rsp), %rdx
movl %r14d, 0x9c(%rdx)
movl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0x63e9e
movl 0xc(%rsp), %esi
pushq $0x6
popq %rdx
pushq $0x4
popq %rcx
movq %rbx, %rdi
callq 0x1206e
leaq 0x328(%rsp), %rdi
andl $0x0, -0x60(%rdi)
movq %r15, -0x68(%rdi)
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, -0x58(%rdi)
movl $0x1, -0x50(%rdi)
andq $0x0, -0x20(%rdi)
andl $0x0, -0x18(%rdi)
andq $0x0, -0x10(%rdi)
movb $0x0, -0x8(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, -0x48(%rdi)
movups %xmm0, -0x38(%rdi)
andl $0x0, -0x28(%rdi)
movl $0x8, -0x4(%rdi)
andq $0x0, 0x10(%rdi)
movups %xmm0, (%rdi)
andq $0x0, 0x30(%rdi)
leaq 0x390(%rsp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
movl $0xc, -0x5c(%rdi)
leaq 0xc(%rsp), %rsi
callq 0x6c06
leal 0x2(%r14), %r15d
leaq 0x2c0(%rsp), %rdx
movq %rbx, %rdi
movl %r15d, %esi
callq 0x63e9e
movl %r15d, 0x8(%rax)
pushq $0x2
popq %rdx
movq %rbx, %rdi
movl %r15d, %esi
xorl %ecx, %ecx
callq 0x1206e
leaq 0x2cacd(%rip), %rsi     # 0x9b0fa
leaq 0x1e8(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x6100
leaq 0x1e8(%rsp), %rdx
movq %rbx, %rdi
movl %r15d, %esi
callq 0x11dda
leaq 0x1e8(%rsp), %rdi
callq 0x6548
leaq 0x2ca9b(%rip), %rsi     # 0x9b101
leaq 0x1e8(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x6100
leaq 0x1e8(%rsp), %rcx
movq %rbx, %rdi
movl %r15d, %esi
xorl %edx, %edx
callq 0x11ed8
leaq 0x1e8(%rsp), %rdi
callq 0x6548
pushq $0x23
popq %rcx
movq %rbx, %rdi
movl %r15d, %esi
xorl %edx, %edx
xorl %r8d, %r8d
callq 0x11ece
leaq 0x1e8(%rsp), %rdi
leaq 0x2c0(%rsp), %rsi
callq 0x1a29c
leaq 0x1e8(%rsp), %rdx
movb $0x1, 0x60(%rdx)
movl %r15d, 0x9c(%rdx)
movl $0x2, 0x64(%rdx)
movq %rbx, %rdi
movl %ebp, %esi
callq 0x63e9e
addl $0x4, %r14d
movl %r15d, 0x8(%rax)
leaq 0x18(%rsp), %rcx
movl $0x2, (%rcx)
leaq 0x14(%rsp), %rdx
movq %rbx, %rdi
movl %r14d, %esi
callq 0x63ec6
leaq 0x2c9fe(%rip), %rsi     # 0x9b10e
leaq 0x18(%rsp), %rdi
leaq 0x13(%rsp), %rdx
callq 0x6100
leaq 0x18(%rsp), %rdx
movq %rbx, %rdi
movl %r14d, %esi
callq 0x11dda
leaq 0x18(%rsp), %rdi
callq 0x6548
pushq $0x22
popq %rdx
pushq $-0x2
popq %rcx
movq %rbx, %rdi
movl %r14d, %esi
callq 0x1206e
movl 0x7d8(%rbx), %ecx
pushq $0x21
popq %rdx
movq %rbx, %rdi
movl %r14d, %esi
callq 0x1206e
movl %r14d, 0x7c8(%rbx)
leaq 0x1e8(%rsp), %rdi
callq 0x17a3e
leaq 0x2c0(%rsp), %rdi
callq 0x17a3e
leaq 0x38(%rsp), %rdi
callq 0x17a3e
leaq 0x110(%rsp), %rdi
callq 0x17a3e
addq $0x398, %rsp            # imm = 0x398
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6e814
jmp 0x6e814
jmp 0x6e7e7
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x6548
jmp 0x6e7f3
jmp 0x6e7f0
jmp 0x6e7f0
jmp 0x6e802
jmp 0x6e7c7
jmp 0x6e802
movq %rax, %rbx
leaq 0x1e8(%rsp), %rdi
callq 0x6548
jmp 0x6e805
jmp 0x6e802
jmp 0x6e802
jmp 0x6e814
jmp 0x6e814
jmp 0x6e7e7
jmp 0x6e814
jmp 0x6e7e7
movq %rax, %rbx
jmp 0x6e821
jmp 0x6e814
jmp 0x6e814
movq %rax, %rbx
leaq 0x1e8(%rsp), %rdi
callq 0x17a3e
jmp 0x6e805
movq %rax, %rbx
leaq 0x2c0(%rsp), %rdi
callq 0x17a3e
jmp 0x6e817
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x17a3e
leaq 0x110(%rsp), %rdi
callq 0x17a3e
movq %rbx, %rdi
callq 0x64b0