// File: rossy[P]crossc/SPIRV-Cross/spirv_msl.cpp
// Function: spirv_cross::CompilerMSL::replace_illegal_names()
void CompilerMSL::replace_illegal_names()
{
	// FIXME: MSL and GLSL are doing two different things here.
	// Agree on convention and remove this override.
	static const unordered_set<string> keywords = {
		"kernel", "vertex", "fragment", "compute", "bias",
	};

	static const unordered_set<string> illegal_func_names = {
		"main",
		"saturate",
	};

	for (auto &id : ir.ids)
	{
		switch (id.get_type())
		{
		case TypeVariable:
		{
			auto &dec = ir.meta[id.get_id()].decoration;
			if (keywords.find(dec.alias) != end(keywords))
				dec.alias += "0";

			break;
		}

		case TypeFunction:
		{
			auto &dec = ir.meta[id.get_id()].decoration;
			if (illegal_func_names.find(dec.alias) != end(illegal_func_names))
				dec.alias += "0";

			break;
		}

		case TypeType:
		{
			for (auto &mbr_dec : ir.meta[id.get_id()].members)
				if (keywords.find(mbr_dec.alias) != end(keywords))
					mbr_dec.alias += "0";

			break;
		}

		default:
			break;
		}
	}

	for (auto &entry : ir.entry_points)
	{
		// Change both the entry point name and the alias, to keep them synced.
		string &ep_name = entry.second.name;
		if (illegal_func_names.find(ep_name) != end(illegal_func_names))
			ep_name += "0";

		// Always write this because entry point might have been renamed earlier.
		ir.meta[entry.first].decoration.alias = ep_name;
	}

	CompilerGLSL::replace_illegal_names();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x330, %rsp            # imm = 0x330
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x200(%rbp)
cmpb $0x0, 0xa459f(%rip)     # 0x1af7d0
jne 0x10b4ba
leaq 0xa4592(%rip), %rdi     # 0x1af7d0
callq 0x7670
cmpl $0x0, %eax
je 0x10b4ba
movb $0x1, -0xd9(%rbp)
leaq -0xb8(%rbp), %rax
movq %rax, -0x210(%rbp)
movq %rax, -0xc0(%rbp)
leaq -0xc1(%rbp), %rdi
movq %rdi, -0x208(%rbp)
callq 0x7650
movq -0x210(%rbp), %rdi
movq -0x208(%rbp), %rdx
leaq 0x42235(%rip), %rsi     # 0x14d4c5
callq 0x7520
jmp 0x10b297
leaq -0x98(%rbp), %rax
movq %rax, -0x220(%rbp)
movq %rax, -0xc0(%rbp)
leaq -0xd5(%rbp), %rdi
movq %rdi, -0x218(%rbp)
callq 0x7650
movq -0x220(%rbp), %rdi
movq -0x218(%rbp), %rdx
leaq 0x42640(%rip), %rsi     # 0x14d914
callq 0x7520
jmp 0x10b2db
leaq -0x78(%rbp), %rax
movq %rax, -0x230(%rbp)
movq %rax, -0xc0(%rbp)
leaq -0xd6(%rbp), %rdi
movq %rdi, -0x228(%rbp)
callq 0x7650
movq -0x230(%rbp), %rdi
movq -0x228(%rbp), %rdx
leaq 0x421a7(%rip), %rsi     # 0x14d4bc
callq 0x7520
jmp 0x10b31c
leaq -0x58(%rbp), %rax
movq %rax, -0x240(%rbp)
movq %rax, -0xc0(%rbp)
leaq -0xd7(%rbp), %rdi
movq %rdi, -0x238(%rbp)
callq 0x7650
movq -0x240(%rbp), %rdi
movq -0x238(%rbp), %rdx
leaq 0x42246(%rip), %rsi     # 0x14d59c
callq 0x7520
jmp 0x10b35d
leaq -0x38(%rbp), %rax
movq %rax, -0x250(%rbp)
movq %rax, -0xc0(%rbp)
leaq -0xd8(%rbp), %rdi
movq %rdi, -0x248(%rbp)
callq 0x7650
movq -0x250(%rbp), %rdi
movq -0x248(%rbp), %rdx
leaq 0x3d0f8(%rip), %rsi     # 0x14848f
callq 0x7520
jmp 0x10b39e
movb $0x0, -0xd9(%rbp)
leaq -0xb8(%rbp), %rax
movq %rax, -0x18(%rbp)
movq $0x5, -0x10(%rbp)
leaq -0xdc(%rbp), %rdi
movq %rdi, -0x258(%rbp)
callq 0x3d1e0
movq -0x258(%rbp), %rcx
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq %rsp, %rax
movq %rcx, (%rax)
leaq 0xa43b1(%rip), %rdi     # 0x1af798
xorl %eax, %eax
movl %eax, %ecx
leaq -0xda(%rbp), %r8
leaq -0xdb(%rbp), %r9
callq 0xa05d0
jmp 0x10b400
leaq -0xdc(%rbp), %rdi
callq 0x15040
leaq -0xb8(%rbp), %rax
movq %rax, -0x268(%rbp)
addq $0xa0, %rax
movq %rax, -0x260(%rbp)
movq -0x260(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x270(%rbp)
callq 0x7708
movq -0x268(%rbp), %rcx
movq -0x270(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x260(%rbp)
jne 0x10b427
leaq -0xd8(%rbp), %rdi
callq 0x73d0
leaq -0xd7(%rbp), %rdi
callq 0x73d0
leaq -0xd6(%rbp), %rdi
callq 0x73d0
leaq -0xd5(%rbp), %rdi
callq 0x73d0
leaq -0xc1(%rbp), %rdi
callq 0x73d0
leaq -0xf636b(%rip), %rdi    # 0x15130
leaq 0xa42f6(%rip), %rsi     # 0x1af798
leaq 0xa3ed7(%rip), %rdx     # 0x1af380
callq 0x7300
leaq 0xa431b(%rip), %rdi     # 0x1af7d0
callq 0x7250
cmpb $0x0, 0xa434f(%rip)     # 0x1af810
jne 0x10b66d
leaq 0xa4342(%rip), %rdi     # 0x1af810
callq 0x7670
cmpl $0x0, %eax
je 0x10b66d
movb $0x1, -0x13b(%rbp)
leaq -0x130(%rbp), %rax
movq %rax, -0x280(%rbp)
movq %rax, -0x138(%rbp)
leaq -0x139(%rbp), %rdi
movq %rdi, -0x278(%rbp)
callq 0x7650
movq -0x280(%rbp), %rdi
movq -0x278(%rbp), %rdx
leaq 0x3cb24(%rip), %rsi     # 0x148044
callq 0x7520
jmp 0x10b527
leaq -0x110(%rbp), %rax
movq %rax, -0x290(%rbp)
movq %rax, -0x138(%rbp)
leaq -0x13a(%rbp), %rdi
movq %rdi, -0x288(%rbp)
callq 0x7650
movq -0x290(%rbp), %rdi
movq -0x288(%rbp), %rdx
leaq 0x42040(%rip), %rsi     # 0x14d5a4
callq 0x7520
jmp 0x10b56b
movb $0x0, -0x13b(%rbp)
leaq -0x130(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq $0x2, -0xe8(%rbp)
leaq -0x13e(%rbp), %rdi
movq %rdi, -0x298(%rbp)
callq 0x3d1e0
movq -0x298(%rbp), %rcx
movq -0xf0(%rbp), %rsi
movq -0xe8(%rbp), %rdx
movq %rsp, %rax
movq %rcx, (%rax)
leaq 0xa4218(%rip), %rdi     # 0x1af7d8
xorl %eax, %eax
movl %eax, %ecx
leaq -0x13c(%rbp), %r8
leaq -0x13d(%rbp), %r9
callq 0xa05d0
jmp 0x10b5d9
leaq -0x13e(%rbp), %rdi
callq 0x15040
leaq -0x130(%rbp), %rax
movq %rax, -0x2a8(%rbp)
addq $0x40, %rax
movq %rax, -0x2a0(%rbp)
movq -0x2a0(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x2b0(%rbp)
callq 0x7708
movq -0x2a8(%rbp), %rcx
movq -0x2b0(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x2a0(%rbp)
jne 0x10b5fe
leaq -0x13a(%rbp), %rdi
callq 0x73d0
leaq -0x139(%rbp), %rdi
callq 0x73d0
leaq -0xf651e(%rip), %rdi    # 0x15130
leaq 0xa4183(%rip), %rsi     # 0x1af7d8
leaq 0xa3d24(%rip), %rdx     # 0x1af380
callq 0x7300
leaq 0xa41a8(%rip), %rdi     # 0x1af810
callq 0x7250
movq -0x200(%rbp), %rax
addq $0x8, %rax
addq $0x18, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0xf940
movq %rax, -0x150(%rbp)
movq -0x148(%rbp), %rdi
callq 0xf970
movq %rax, -0x158(%rbp)
leaq -0x150(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0xf9a0
testb $0x1, %al
jne 0x10b6c5
jmp 0x10bbf5
leaq -0x150(%rbp), %rdi
callq 0xf9e0
movq %rax, -0x160(%rbp)
movq -0x160(%rbp), %rdi
callq 0xfa00
movl %eax, %ecx
movl %ecx, -0x2b4(%rbp)
subl $0x1, %eax
je 0x10bae1
jmp 0x10b6f7
movl -0x2b4(%rbp), %eax
subl $0x2, %eax
je 0x10b9b3
jmp 0x10b708
movl -0x2b4(%rbp), %eax
subl $0x4, %eax
je 0x10ba4a
jmp 0x10bbe0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
jmp 0x10b828
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
jmp 0x10b81c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
jmp 0x10b810
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
jmp 0x10b804
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
jmp 0x10b7f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
leaq -0xdc(%rbp), %rdi
callq 0x15040
leaq -0xb8(%rbp), %rax
movq %rax, -0x2c8(%rbp)
addq $0xa0, %rax
movq %rax, -0x2c0(%rbp)
movq -0x2c0(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x2d0(%rbp)
callq 0x7708
movq -0x2c8(%rbp), %rcx
movq -0x2d0(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x2c0(%rbp)
jne 0x10b7c5
jmp 0x10b7f8
leaq -0xd8(%rbp), %rdi
callq 0x73d0
leaq -0xd7(%rbp), %rdi
callq 0x73d0
leaq -0xd6(%rbp), %rdi
callq 0x73d0
leaq -0xd5(%rbp), %rdi
callq 0x73d0
leaq -0xc1(%rbp), %rdi
callq 0x73d0
testb $0x1, -0xd9(%rbp)
jne 0x10b83f
jmp 0x10b88c
movq -0xc0(%rbp), %rax
leaq -0xb8(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0x2d8(%rbp)
je 0x10b88a
movq -0x2d8(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x2e0(%rbp)
callq 0x7708
movq -0x2e0(%rbp), %rax
leaq -0xb8(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0x2d8(%rbp)
jne 0x10b859
jmp 0x10b88c
leaq 0xa3f3d(%rip), %rdi     # 0x1af7d0
callq 0x7240
jmp 0x10bd33
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
jmp 0x10b93e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
jmp 0x10b932
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
leaq -0x13e(%rbp), %rdi
callq 0x15040
leaq -0x130(%rbp), %rax
movq %rax, -0x2f0(%rbp)
addq $0x40, %rax
movq %rax, -0x2e8(%rbp)
movq -0x2e8(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x2f8(%rbp)
callq 0x7708
movq -0x2f0(%rbp), %rcx
movq -0x2f8(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x2e8(%rbp)
jne 0x10b8ff
jmp 0x10b932
leaq -0x13a(%rbp), %rdi
callq 0x73d0
leaq -0x139(%rbp), %rdi
callq 0x73d0
testb $0x1, -0x13b(%rbp)
jne 0x10b955
jmp 0x10b9a2
movq -0x138(%rbp), %rax
leaq -0x130(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0x300(%rbp)
je 0x10b9a0
movq -0x300(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x308(%rbp)
callq 0x7708
movq -0x308(%rbp), %rax
leaq -0x130(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0x300(%rbp)
jne 0x10b96f
jmp 0x10b9a2
leaq 0xa3e67(%rip), %rdi     # 0x1af810
callq 0x7240
jmp 0x10bd33
movq -0x200(%rbp), %rax
addq $0x8, %rax
addq $0x30, %rax
movq %rax, -0x310(%rbp)
movq -0x160(%rbp), %rdi
callq 0x2f2b0
movq -0x310(%rbp), %rdi
movl %eax, %eax
movl %eax, %esi
callq 0xead0
movq %rax, -0x168(%rbp)
movq -0x168(%rbp), %rsi
leaq 0xa3d9e(%rip), %rdi     # 0x1af798
callq 0xa0630
movq %rax, -0x170(%rbp)
leaq 0xa3d8b(%rip), %rdi     # 0x1af798
callq 0xa0660
movq %rax, -0x178(%rbp)
leaq -0x170(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x2f970
testb $0x1, %al
jne 0x10ba32
jmp 0x10ba45
movq -0x168(%rbp), %rdi
leaq 0x4174f(%rip), %rsi     # 0x14d18f
callq 0x7340
jmp 0x10bbe2
movq -0x200(%rbp), %rax
addq $0x8, %rax
addq $0x30, %rax
movq %rax, -0x318(%rbp)
movq -0x160(%rbp), %rdi
callq 0x2f2b0
movq -0x318(%rbp), %rdi
movl %eax, %eax
movl %eax, %esi
callq 0xead0
movq %rax, -0x180(%rbp)
movq -0x180(%rbp), %rsi
leaq 0xa3d47(%rip), %rdi     # 0x1af7d8
callq 0xa0630
movq %rax, -0x188(%rbp)
leaq 0xa3d34(%rip), %rdi     # 0x1af7d8
callq 0xa0660
movq %rax, -0x190(%rbp)
leaq -0x188(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x2f970
testb $0x1, %al
jne 0x10bac9
jmp 0x10badc
movq -0x180(%rbp), %rdi
leaq 0x416b8(%rip), %rsi     # 0x14d18f
callq 0x7340
jmp 0x10bbe2
movq -0x200(%rbp), %rax
addq $0x8, %rax
addq $0x30, %rax
movq %rax, -0x320(%rbp)
movq -0x160(%rbp), %rdi
callq 0x2f2b0
movq -0x320(%rbp), %rdi
movl %eax, %eax
movl %eax, %esi
callq 0xead0
addq $0xd0, %rax
movq %rax, -0x198(%rbp)
movq -0x198(%rbp), %rdi
callq 0x38cd0
movq %rax, -0x1a0(%rbp)
movq -0x198(%rbp), %rdi
callq 0x38d00
movq %rax, -0x1a8(%rbp)
leaq -0x1a0(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x38e30
testb $0x1, %al
jne 0x10bb5f
jmp 0x10bbde
leaq -0x1a0(%rbp), %rdi
callq 0x38e70
movq %rax, -0x1b0(%rbp)
movq -0x1b0(%rbp), %rsi
leaq 0xa3c18(%rip), %rdi     # 0x1af798
callq 0xa0630
movq %rax, -0x1b8(%rbp)
leaq 0xa3c05(%rip), %rdi     # 0x1af798
callq 0xa0660
movq %rax, -0x1c0(%rbp)
leaq -0x1b8(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x2f970
testb $0x1, %al
jne 0x10bbb8
jmp 0x10bbcb
movq -0x1b0(%rbp), %rdi
leaq 0x415c9(%rip), %rsi     # 0x14d18f
callq 0x7340
jmp 0x10bbcd
leaq -0x1a0(%rbp), %rdi
callq 0x38e90
jmp 0x10bb46
jmp 0x10bbe2
jmp 0x10bbe2
jmp 0x10bbe4
leaq -0x150(%rbp), %rdi
callq 0xfbd0
jmp 0x10b6a9
movq -0x200(%rbp), %rax
addq $0x8, %rax
addq $0xc8, %rax
movq %rax, -0x1c8(%rbp)
movq -0x1c8(%rbp), %rdi
callq 0x2f4a0
movq %rax, -0x1d0(%rbp)
movq -0x1c8(%rbp), %rdi
callq 0x2f4d0
movq %rax, -0x1d8(%rbp)
leaq -0x1d0(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x2f500
testb $0x1, %al
jne 0x10bc4f
jmp 0x10bd1e
leaq -0x1d0(%rbp), %rdi
callq 0x2f530
movq %rax, -0x1e0(%rbp)
movq -0x1e0(%rbp), %rax
addq $0x8, %rax
addq $0x8, %rax
movq %rax, -0x1e8(%rbp)
movq -0x1e8(%rbp), %rsi
leaq 0xa3b52(%rip), %rdi     # 0x1af7d8
callq 0xa0630
movq %rax, -0x1f0(%rbp)
leaq 0xa3b3f(%rip), %rdi     # 0x1af7d8
callq 0xa0660
movq %rax, -0x1f8(%rbp)
leaq -0x1f0(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x2f970
testb $0x1, %al
jne 0x10bcbe
jmp 0x10bcd1
movq -0x1e8(%rbp), %rdi
leaq 0x414c3(%rip), %rsi     # 0x14d18f
callq 0x7340
movq -0x200(%rbp), %rdi
movq -0x1e8(%rbp), %rax
movq %rax, -0x328(%rbp)
addq $0x8, %rdi
addq $0x30, %rdi
movq -0x1e0(%rbp), %rax
movl (%rax), %eax
movl %eax, %esi
callq 0xead0
movq -0x328(%rbp), %rsi
movq %rax, %rdi
callq 0x7050
leaq -0x1d0(%rbp), %rdi
callq 0x2f590
jmp 0x10bc33
movq -0x200(%rbp), %rdi
callq 0x652b0
addq $0x330, %rsp            # imm = 0x330
popq %rbp
retq
movq -0xd0(%rbp), %rdi
callq 0x7640
nop