// File: rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::remap_swizzle(spirv_cross::SPIRType const&, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
string CompilerGLSL::remap_swizzle(const SPIRType &out_type, uint32_t input_components, const string &expr)
{
	if (out_type.vecsize == input_components)
		return expr;
	else if (input_components == 1 && !backend.can_swizzle_scalar)
		return join(type_to_glsl(out_type), "(", expr, ")");
	else
	{
		// FIXME: This will not work with packed expressions.
		auto e = enclose_expression(expr) + ".";
		// Just clamp the swizzle index if we have more outputs than inputs.
		for (uint32_t c = 0; c < out_type.vecsize; c++)
			e += index_to_swizzle(min(c, input_components - 1));
		if (backend.swizzle_is_function && out_type.vecsize > 1)
			e += "()";

		remove_duplicate_swizzle(e);
		return e;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x98(%rbp)
movq %rdi, %rax
movq %rax, -0x90(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
cmpl -0x1c(%rbp), %eax
jne 0x6fd5b
movq -0x98(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x7170
jmp 0x6ff33
cmpl $0x1, -0x1c(%rbp)
jne 0x6fde8
movq -0x88(%rbp), %rax
testb $0x1, 0x62c(%rax)
jne 0x6fde8
movq -0x88(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq (%rsi), %rax
movq 0x98(%rax), %rax
leaq -0x48(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
xorl %ecx, %ecx
callq *%rax
movq -0x98(%rbp), %rdi
movq -0xa0(%rbp), %rsi
movq -0x28(%rbp), %rcx
leaq 0xdd57b(%rip), %rdx     # 0x14d32d
leaq 0xd5140(%rip), %r8      # 0x144ef9
callq 0xa0840
jmp 0x6fdc0
leaq -0x48(%rbp), %rdi
callq 0x7708
jmp 0x6ff33
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x7708
jmp 0x6ff43
movq -0x88(%rbp), %rsi
movb $0x0, -0x55(%rbp)
movq -0x28(%rbp), %rdx
leaq -0x78(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
callq 0x6ff50
movq -0x98(%rbp), %rdi
movq -0xa8(%rbp), %rsi
leaq 0xd4f11(%rip), %rdx     # 0x144d2d
callq 0x11910
jmp 0x6fe23
leaq -0x78(%rbp), %rdi
callq 0x7708
movl $0x0, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jae 0x6fed5
movl -0x1c(%rbp), %eax
decl %eax
movl %eax, -0x80(%rbp)
leaq -0x7c(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0xa0900
movq %rax, -0xb0(%rbp)
jmp 0x6fe61
movq -0x88(%rbp), %rdi
movq -0xb0(%rbp), %rax
movl (%rax), %esi
callq 0x70100
movq %rax, -0xb8(%rbp)
jmp 0x6fe7f
movq -0xb8(%rbp), %rsi
movq -0x98(%rbp), %rdi
callq 0x7340
jmp 0x6fe94
jmp 0x6fe96
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x6fe33
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x7708
jmp 0x6ff43
movq -0x98(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
callq 0x7708
jmp 0x6ff43
movq -0x88(%rbp), %rax
testb $0x1, 0x620(%rax)
je 0x6ff06
movq -0x18(%rbp), %rax
cmpl $0x1, 0x14(%rax)
jbe 0x6ff06
movq -0x98(%rbp), %rdi
leaq 0xd2f37(%rip), %rsi     # 0x142e34
callq 0x7340
jmp 0x6ff04
jmp 0x6ff06
movq -0x98(%rbp), %rsi
movq -0x88(%rbp), %rdi
callq 0x70230
jmp 0x6ff1b
movb $0x1, -0x55(%rbp)
testb $0x1, -0x55(%rbp)
jne 0x6ff31
movq -0x98(%rbp), %rdi
callq 0x7708
jmp 0x6ff33
movq -0x90(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x7640
nopl (%rax)