// File: /workspace/github_cpp_makefile_star2_O3/rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::remove_unity_swizzle(unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
bool CompilerGLSL::remove_unity_swizzle(uint32_t base, string &op)
{
	auto pos = op.find_last_of('.');
	if (pos == string::npos || pos == 0)
		return false;

	string final_swiz = op.substr(pos + 1, string::npos);

	if (backend.swizzle_is_function)
	{
		if (final_swiz.size() < 2)
			return false;

		if (final_swiz.substr(final_swiz.size() - 2, string::npos) == "()")
			final_swiz.erase(final_swiz.size() - 2, string::npos);
		else
			return false;
	}

	// Check if final swizzle is of form .x, .xy, .xyz, .xyzw or similar.
	// If so, and previous swizzle is of same length,
	// we can drop the final swizzle altogether.
	for (uint32_t i = 0; i < final_swiz.size(); i++)
	{
		static const char expected[] = { 'x', 'y', 'z', 'w' };
		if (i >= 4 || final_swiz[i] != expected[i])
			return false;
	}

	auto &type = expression_type(base);

	// Sanity checking ...
	assert(type.columns == 1 && type.array.empty());

	if (type.vecsize == final_swiz.size())
		op.erase(pos, string::npos);
	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, %r15
movq %rdx, %rdi
movl $0x2e, %esi
movq $-0x1, %rdx
callq 0x64f0
leaq 0x1(%rax), %rdx
cmpq $0x2, %rdx
jae 0x43b57
xorl %ebp, %ebp
jmp 0x43c85
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
movq $-0x1, %rcx
callq 0x6290
cmpb $0x1, 0x620(%r15)
jne 0x43bff
movq 0x10(%rsp), %rdx
cmpq $0x2, %rdx
jb 0x43bd8
addq $-0x2, %rdx
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movq $-0x1, %rcx
callq 0x6290
leaq 0x74da8(%rip), %rsi     # 0xb8950
leaq 0x28(%rsp), %r13
movq %r13, %rdi
callq 0x60a0
movl %eax, %r12d
movq (%r13), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x43bd3
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x6260
testl %r12d, %r12d
je 0x43bdf
xorl %ebp, %ebp
jmp 0x43c6a
movq 0x10(%rsp), %rcx
movq %rcx, %rdx
subq $0x2, %rdx
jb 0x43ccd
movq %rdx, 0x10(%rsp)
movq 0x8(%rsp), %rax
movb $0x0, (%rax,%rdx)
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x43c2f
movq 0x8(%rsp), %rcx
xorl %edx, %edx
leaq 0x728b5(%rip), %rsi     # 0xb64cc
cmpq $0x4, %rdx
je 0x43bd8
movb (%rcx,%rdx), %dil
cmpb (%rdx,%rsi), %dil
jne 0x43bd8
incq %rdx
cmpq %rdx, %rax
jne 0x43c17
movq %r15, %rdi
movl %ebp, %esi
callq 0x12a72
cmpl $0x1, 0x18(%rax)
jne 0x43c96
movq 0x20(%rax), %rcx
cmpq 0x28(%rax), %rcx
jne 0x43c96
movl 0x14(%rax), %eax
movb $0x1, %bpl
cmpq %rax, 0x10(%rsp)
jne 0x43c6a
movq 0x8(%r14), %rcx
cmpq %rbx, %rcx
jb 0x43cb5
movq %rbx, 0x8(%r14)
movq (%r14), %rax
movb $0x0, (%rax,%rbx)
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x43c85
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x75eb1(%rip), %rdi     # 0xb9b4e
leaq 0x730a4(%rip), %rsi     # 0xb6d48
leaq 0x75ecb(%rip), %rcx     # 0xb9b76
movl $0x179f, %edx           # imm = 0x179F
callq 0x61b0
leaq 0x771b3(%rip), %rdi     # 0xbae6f
leaq 0x771e3(%rip), %rsi     # 0xbaea6
movq %rbx, %rdx
xorl %eax, %eax
callq 0x63d0
leaq 0x7719b(%rip), %rdi     # 0xbae6f
leaq 0x771cb(%rip), %rsi     # 0xbaea6
xorl %eax, %eax
callq 0x63d0
jmp 0x43ce6
jmp 0x43ce6
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x43d04
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
movq %rbx, %rdi
callq 0x64a0