// File: rossy[P]crossc/SPIRV-Cross/spirv_cross_parsed_ir.cpp
// Function: spirv_cross::ensure_valid_identifier(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, bool)
static string ensure_valid_identifier(const string &name, bool member)
{
	// Functions in glslangValidator are mangled with name(<mangled> stuff.
	// Normally, we would never see '(' in any legal identifiers, so just strip them out.
	auto str = name.substr(0, name.find('('));

	for (uint32_t i = 0; i < str.size(); i++)
	{
		auto &c = str[i];

		if (member)
		{
			// _m<num> variables are reserved by the internal implementation,
			// otherwise, make sure the name is a valid identifier.
			if (i == 0)
				c = isalpha(c) ? c : '_';
			else if (i == 2 && str[0] == '_' && str[1] == 'm')
				c = isalpha(c) ? c : '_';
			else
				c = isalnum(c) ? c : '_';
		}
		else
		{
			// _<num> variables are reserved by the internal implementation,
			// otherwise, make sure the name is a valid identifier.
			if (i == 0 || (str[0] == '_' && i == 1))
				c = isalpha(c) ? c : '_';
			else
				c = isalnum(c) ? c : '_';
		}
	}
	return str;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x40(%rbp)
movb %dl, %al
movq %rdi, %rcx
movq %rcx, -0x48(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movb $0x0, -0x12(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movl $0x28, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x74a0
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq %rax, %rcx
xorl %eax, %eax
movl %eax, %edx
callq 0x73a0
movl $0x0, -0x18(%rbp)
movq -0x40(%rbp), %rdi
movl -0x18(%rbp), %eax
movq %rax, -0x50(%rbp)
callq 0x7290
movq %rax, %rcx
movq -0x50(%rbp), %rax
cmpq %rcx, %rax
jae 0x545c4
movq -0x40(%rbp), %rdi
movl -0x18(%rbp), %eax
movl %eax, %esi
callq 0x76d0
movq %rax, -0x58(%rbp)
jmp 0x54412
movq -0x58(%rbp), %rax
movq %rax, -0x20(%rbp)
testb $0x1, -0x11(%rbp)
je 0x5451b
cmpl $0x0, -0x18(%rbp)
jne 0x54475
movq -0x20(%rbp), %rax
movsbl (%rax), %edi
callq 0x75c0
cmpl $0x0, %eax
je 0x54446
movq -0x20(%rbp), %rax
movb (%rax), %al
movb %al, -0x59(%rbp)
jmp 0x5444d
movb $0x5f, %al
movb %al, -0x59(%rbp)
jmp 0x5444d
movb -0x59(%rbp), %cl
movq -0x20(%rbp), %rax
movb %cl, (%rax)
jmp 0x54516
movq -0x40(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x7708
jmp 0x545e4
cmpl $0x2, -0x18(%rbp)
jne 0x544e8
movq -0x40(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x76d0
movq %rax, -0x68(%rbp)
jmp 0x5448e
movq -0x68(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5f, %eax
jne 0x544e8
movq -0x40(%rbp), %rdi
movl $0x1, %esi
callq 0x76d0
movq %rax, -0x70(%rbp)
jmp 0x544ae
movq -0x70(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x6d, %eax
jne 0x544e8
movq -0x20(%rbp), %rax
movsbl (%rax), %edi
callq 0x75c0
cmpl $0x0, %eax
je 0x544d6
movq -0x20(%rbp), %rax
movb (%rax), %al
movb %al, -0x71(%rbp)
jmp 0x544dd
movb $0x5f, %al
movb %al, -0x71(%rbp)
jmp 0x544dd
movb -0x71(%rbp), %cl
movq -0x20(%rbp), %rax
movb %cl, (%rax)
jmp 0x54514
movq -0x20(%rbp), %rax
movsbl (%rax), %edi
callq 0x7390
cmpl $0x0, %eax
je 0x54504
movq -0x20(%rbp), %rax
movb (%rax), %al
movb %al, -0x72(%rbp)
jmp 0x5450b
movb $0x5f, %al
movb %al, -0x72(%rbp)
jmp 0x5450b
movb -0x72(%rbp), %cl
movq -0x20(%rbp), %rax
movb %cl, (%rax)
jmp 0x54516
jmp 0x545b4
cmpl $0x0, -0x18(%rbp)
je 0x54546
movq -0x40(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x76d0
movq %rax, -0x80(%rbp)
jmp 0x54534
movq -0x80(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5f, %eax
jne 0x5457d
cmpl $0x1, -0x18(%rbp)
jne 0x5457d
movq -0x20(%rbp), %rax
movsbl (%rax), %edi
callq 0x75c0
cmpl $0x0, %eax
je 0x54565
movq -0x20(%rbp), %rax
movb (%rax), %al
movb %al, -0x81(%rbp)
jmp 0x5456f
movb $0x5f, %al
movb %al, -0x81(%rbp)
jmp 0x5456f
movb -0x81(%rbp), %cl
movq -0x20(%rbp), %rax
movb %cl, (%rax)
jmp 0x545b2
movq -0x20(%rbp), %rax
movsbl (%rax), %edi
callq 0x7390
cmpl $0x0, %eax
je 0x5459c
movq -0x20(%rbp), %rax
movb (%rax), %al
movb %al, -0x82(%rbp)
jmp 0x545a6
movb $0x5f, %al
movb %al, -0x82(%rbp)
jmp 0x545a6
movb -0x82(%rbp), %cl
movq -0x20(%rbp), %rax
movb %cl, (%rax)
jmp 0x545b4
jmp 0x545b6
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x543de
movb $0x1, -0x12(%rbp)
testb $0x1, -0x12(%rbp)
jne 0x545d7
movq -0x40(%rbp), %rdi
callq 0x7708
movq -0x48(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x7640
nopl (%rax)