// File: rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::to_ternary_expression[abi:cxx11](spirv_cross::SPIRType const&, unsigned int, unsigned int, unsigned int)
string CompilerGLSL::to_ternary_expression(const SPIRType &restype, uint32_t select, uint32_t true_value,
                                           uint32_t false_value)
{
	string expr;
	auto &lerptype = expression_type(select);

	if (lerptype.vecsize == 1)
		expr = join(to_enclosed_expression(select), " ? ", to_enclosed_expression(true_value), " : ",
		            to_enclosed_expression(false_value));
	else
	{
		auto swiz = [this](uint32_t expression, uint32_t i) { return to_extract_component_expression(expression, i); };

		expr = type_to_glsl_constructor(restype);
		expr += "(";
		for (uint32_t i = 0; i < restype.vecsize; i++)
		{
			expr += swiz(select, i);
			expr += " ? ";
			expr += swiz(true_value, i);
			expr += " : ";
			expr += swiz(false_value, i);
			if (i + 1 < restype.vecsize)
				expr += ", ";
		}
		expr += ")";
	}

	return expr;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x170(%rbp)
movq %rdi, %rax
movq %rax, -0x168(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x160(%rbp)
movb $0x0, -0x25(%rbp)
callq 0x7530
movq -0x160(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x1f760
movq %rax, -0x158(%rbp)
jmp 0x7329f
movq -0x158(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x1, 0x14(%rax)
jne 0x733c6
movq -0x160(%rbp), %rsi
movl -0x1c(%rbp), %edx
leaq -0x80(%rbp), %rdi
callq 0x72630
jmp 0x732cd
movq -0x160(%rbp), %rsi
movl -0x20(%rbp), %edx
leaq -0xa0(%rbp), %rdi
callq 0x72630
jmp 0x732e5
movq -0x160(%rbp), %rsi
movl -0x24(%rbp), %edx
leaq -0xc0(%rbp), %rdi
callq 0x72630
jmp 0x732fd
leaq 0xd9638(%rip), %rdx     # 0x14c93c
leaq 0xcb04e(%rip), %r8      # 0x13e359
leaq -0x60(%rbp), %rdi
leaq -0x80(%rbp), %rsi
leaq -0xa0(%rbp), %rcx
leaq -0xc0(%rbp), %r9
callq 0xa3690
jmp 0x73328
movq -0x170(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x7430
leaq -0x60(%rbp), %rdi
callq 0x7708
leaq -0xc0(%rbp), %rdi
callq 0x7708
leaq -0xa0(%rbp), %rdi
callq 0x7708
leaq -0x80(%rbp), %rdi
callq 0x7708
jmp 0x735cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x735f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x733b8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x733ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x7708
leaq -0xa0(%rbp), %rdi
callq 0x7708
leaq -0x80(%rbp), %rdi
callq 0x7708
jmp 0x735f2
movq -0x160(%rbp), %rsi
movq %rsi, -0xc8(%rbp)
movq -0x18(%rbp), %rdx
leaq -0xe8(%rbp), %rdi
callq 0x72bf0
jmp 0x733e6
movq -0x170(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
movq %rsi, -0x178(%rbp)
callq 0x7430
movq -0x178(%rbp), %rdi
callq 0x7708
movq -0x170(%rbp), %rdi
leaq 0xd9f13(%rip), %rsi     # 0x14d32d
callq 0x7340
jmp 0x73421
movl $0x0, -0xec(%rbp)
movl -0xec(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jae 0x735b5
movl -0x1c(%rbp), %edx
movl -0xec(%rbp), %ecx
leaq -0x110(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x7ac00
jmp 0x7345c
movq -0x170(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x7470
jmp 0x73471
leaq -0x110(%rbp), %rdi
callq 0x7708
movq -0x170(%rbp), %rdi
leaq 0xd94b1(%rip), %rsi     # 0x14c93c
callq 0x7340
jmp 0x73492
movl -0x20(%rbp), %edx
movl -0xec(%rbp), %ecx
leaq -0x130(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x7ac00
jmp 0x734b0
movq -0x170(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x7470
jmp 0x734c5
leaq -0x130(%rbp), %rdi
callq 0x7708
movq -0x170(%rbp), %rdi
leaq 0xcae7a(%rip), %rsi     # 0x13e359
callq 0x7340
jmp 0x734e6
movl -0x24(%rbp), %edx
movl -0xec(%rbp), %ecx
leaq -0x150(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x7ac00
jmp 0x73504
movq -0x170(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x7470
jmp 0x73519
leaq -0x150(%rbp), %rdi
callq 0x7708
movl -0xec(%rbp), %eax
addl $0x1, %eax
movq -0x18(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jae 0x7359f
movq -0x170(%rbp), %rdi
leaq 0xd104a(%rip), %rsi     # 0x14458f
callq 0x7340
jmp 0x7354c
jmp 0x7359f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x7708
jmp 0x735f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x7708
jmp 0x735f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x7708
jmp 0x735f2
jmp 0x735a1
movl -0xec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xec(%rbp)
jmp 0x7342b
movq -0x170(%rbp), %rdi
leaq 0xd1936(%rip), %rsi     # 0x144ef9
callq 0x7340
jmp 0x735ca
jmp 0x735cc
movb $0x1, -0x25(%rbp)
testb $0x1, -0x25(%rbp)
jne 0x735e2
movq -0x170(%rbp), %rdi
callq 0x7708
movq -0x168(%rbp), %rax
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
movq -0x170(%rbp), %rdi
callq 0x7708
movq -0x38(%rbp), %rdi
callq 0x7640
nopw (%rax,%rax)