// File: rossy[P]crossc/SPIRV-Cross/spirv_hlsl.cpp
// Function: spirv_cross::CompilerHLSL::emit_glsl_op(unsigned int, unsigned int, unsigned int, unsigned int const*, unsigned int)
void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, const uint32_t *args, uint32_t count)
{
	GLSLstd450 op = static_cast<GLSLstd450>(eop);

	switch (op)
	{
	case GLSLstd450InverseSqrt:
		emit_unary_func_op(result_type, id, args[0], "rsqrt");
		break;

	case GLSLstd450Fract:
		emit_unary_func_op(result_type, id, args[0], "frac");
		break;

	case GLSLstd450RoundEven:
		SPIRV_CROSS_THROW("roundEven is not supported on HLSL.");

	case GLSLstd450Acosh:
	case GLSLstd450Asinh:
	case GLSLstd450Atanh:
		SPIRV_CROSS_THROW("Inverse hyperbolics are not supported on HLSL.");

	case GLSLstd450FMix:
	case GLSLstd450IMix:
		emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "lerp");
		break;

	case GLSLstd450Atan2:
		emit_binary_func_op(result_type, id, args[0], args[1], "atan2");
		break;

	case GLSLstd450Fma:
		emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "mad");
		break;

	case GLSLstd450InterpolateAtCentroid:
		emit_unary_func_op(result_type, id, args[0], "EvaluateAttributeAtCentroid");
		break;
	case GLSLstd450InterpolateAtSample:
		emit_binary_func_op(result_type, id, args[0], args[1], "EvaluateAttributeAtSample");
		break;
	case GLSLstd450InterpolateAtOffset:
		emit_binary_func_op(result_type, id, args[0], args[1], "EvaluateAttributeSnapped");
		break;

	case GLSLstd450PackHalf2x16:
		if (!requires_fp16_packing)
		{
			requires_fp16_packing = true;
			force_recompile = true;
		}
		emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_packHalf2x16");
		break;

	case GLSLstd450UnpackHalf2x16:
		if (!requires_fp16_packing)
		{
			requires_fp16_packing = true;
			force_recompile = true;
		}
		emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_unpackHalf2x16");
		break;

	case GLSLstd450PackSnorm4x8:
		if (!requires_snorm8_packing)
		{
			requires_snorm8_packing = true;
			force_recompile = true;
		}
		emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_packSnorm4x8");
		break;

	case GLSLstd450UnpackSnorm4x8:
		if (!requires_snorm8_packing)
		{
			requires_snorm8_packing = true;
			force_recompile = true;
		}
		emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_unpackSnorm4x8");
		break;

	case GLSLstd450PackUnorm4x8:
		if (!requires_unorm8_packing)
		{
			requires_unorm8_packing = true;
			force_recompile = true;
		}
		emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_packUnorm4x8");
		break;

	case GLSLstd450UnpackUnorm4x8:
		if (!requires_unorm8_packing)
		{
			requires_unorm8_packing = true;
			force_recompile = true;
		}
		emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_unpackUnorm4x8");
		break;

	case GLSLstd450PackSnorm2x16:
		if (!requires_snorm16_packing)
		{
			requires_snorm16_packing = true;
			force_recompile = true;
		}
		emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_packSnorm2x16");
		break;

	case GLSLstd450UnpackSnorm2x16:
		if (!requires_snorm16_packing)
		{
			requires_snorm16_packing = true;
			force_recompile = true;
		}
		emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_unpackSnorm2x16");
		break;

	case GLSLstd450PackUnorm2x16:
		if (!requires_unorm16_packing)
		{
			requires_unorm16_packing = true;
			force_recompile = true;
		}
		emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_packUnorm2x16");
		break;

	case GLSLstd450UnpackUnorm2x16:
		if (!requires_unorm16_packing)
		{
			requires_unorm16_packing = true;
			force_recompile = true;
		}
		emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_unpackUnorm2x16");
		break;

	case GLSLstd450PackDouble2x32:
	case GLSLstd450UnpackDouble2x32:
		SPIRV_CROSS_THROW("packDouble2x32/unpackDouble2x32 not supported in HLSL.");

	case GLSLstd450FindILsb:
		emit_unary_func_op(result_type, id, args[0], "firstbitlow");
		break;
	case GLSLstd450FindSMsb:
	case GLSLstd450FindUMsb:
		emit_unary_func_op(result_type, id, args[0], "firstbithigh");
		break;

	case GLSLstd450MatrixInverse:
	{
		auto &type = get<SPIRType>(result_type);
		if (type.vecsize == 2 && type.columns == 2)
		{
			if (!requires_inverse_2x2)
			{
				requires_inverse_2x2 = true;
				force_recompile = true;
			}
		}
		else if (type.vecsize == 3 && type.columns == 3)
		{
			if (!requires_inverse_3x3)
			{
				requires_inverse_3x3 = true;
				force_recompile = true;
			}
		}
		else if (type.vecsize == 4 && type.columns == 4)
		{
			if (!requires_inverse_4x4)
			{
				requires_inverse_4x4 = true;
				force_recompile = true;
			}
		}
		emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_Inverse");
		break;
	}

	default:
		CompilerGLSL::emit_glsl_op(result_type, id, eop, args, count);
		break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movq %r8, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xc8(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
addl $-0x2, %eax
movl %eax, %ecx
movq %rcx, -0xc0(%rbp)
subl $0x4c, %eax
ja 0xc9d62
movq -0xc0(%rbp), %rax
leaq 0x7c171(%rip), %rcx     # 0x1456f8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0xc8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
leaq 0x7f074(%rip), %r8      # 0x14861e
callq 0x79220
jmp 0xc9d7f
movq -0xc8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
leaq 0x7f056(%rip), %r8      # 0x148624
callq 0x79220
jmp 0xc9d7f
movb $0x1, -0x5d(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0xd8(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
callq 0x7650
movq -0xd0(%rbp), %rdx
leaq 0x7f01e(%rip), %rsi     # 0x148629
leaq -0x48(%rbp), %rdi
callq 0x7520
jmp 0xc9616
movq -0xd8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x9c50
jmp 0xc9628
movq -0xd8(%rbp), %rdi
movb $0x0, -0x5d(%rbp)
leaq 0xe479e(%rip), %rsi     # 0x1addd8
leaq -0xbf9b1(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0xc9d91
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xc966e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x7708
leaq -0x49(%rbp), %rdi
callq 0x73d0
testb $0x1, -0x5d(%rbp)
jne 0xc967f
jmp 0xc968b
movq -0xd8(%rbp), %rdi
callq 0x72c0
jmp 0xc9d88
movb $0x1, -0x82(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0xe8(%rbp)
leaq -0x81(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x7650
movq -0xe0(%rbp), %rdx
leaq 0x7ef84(%rip), %rsi     # 0x14864d
leaq -0x80(%rbp), %rdi
callq 0x7520
jmp 0xc96d4
movq -0xe8(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x9c50
jmp 0xc96e6
movq -0xe8(%rbp), %rdi
movb $0x0, -0x82(%rbp)
leaq 0xe46dd(%rip), %rsi     # 0x1addd8
leaq -0xbfa72(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0xc9d91
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xc972f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x7708
leaq -0x81(%rbp), %rdi
callq 0x73d0
testb $0x1, -0x82(%rbp)
jne 0xc9746
jmp 0xc9752
movq -0xe8(%rbp), %rdi
callq 0x72c0
jmp 0xc9d88
movq -0xc8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
movq -0x20(%rbp), %rax
movl 0x4(%rax), %r8d
movq -0x20(%rbp), %rax
movl 0x8(%rax), %r9d
leaq 0x7eefb(%rip), %rax     # 0x14867c
movq %rax, (%rsp)
callq 0x798c0
jmp 0xc9d7f
movq -0xc8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
movq -0x20(%rbp), %rax
movl 0x4(%rax), %r8d
leaq 0x7eed0(%rip), %r9      # 0x148681
callq 0x79330
jmp 0xc9d7f
movq -0xc8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
movq -0x20(%rbp), %rax
movl 0x4(%rax), %r8d
movq -0x20(%rbp), %rax
movl 0x8(%rax), %r9d
leaq 0x7eea2(%rip), %rax     # 0x148687
movq %rax, (%rsp)
callq 0x798c0
jmp 0xc9d7f
movq -0xc8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
leaq 0x7ee7e(%rip), %r8      # 0x14868b
callq 0x79220
jmp 0xc9d7f
movq -0xc8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
movq -0x20(%rbp), %rax
movl 0x4(%rax), %r8d
leaq 0x7ee6e(%rip), %r9      # 0x1486a7
callq 0x79330
jmp 0xc9d7f
movq -0xc8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
movq -0x20(%rbp), %rax
movl 0x4(%rax), %r8d
leaq 0x7ee5c(%rip), %r9      # 0x1486c1
callq 0x79330
jmp 0xc9d7f
movq -0xc8(%rbp), %rax
testb $0x1, 0x792(%rax)
jne 0xc9894
movq -0xc8(%rbp), %rax
movb $0x1, 0x792(%rax)
movb $0x1, 0x1d0(%rax)
movq -0xc8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
leaq 0x7ee2c(%rip), %r8      # 0x1486da
callq 0x79220
jmp 0xc9d7f
movq -0xc8(%rbp), %rax
testb $0x1, 0x792(%rax)
jne 0xc98dd
movq -0xc8(%rbp), %rax
movb $0x1, 0x792(%rax)
movb $0x1, 0x1d0(%rax)
movq -0xc8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
leaq 0x7edfc(%rip), %r8      # 0x1486f3
callq 0x79220
jmp 0xc9d7f
movq -0xc8(%rbp), %rax
testb $0x1, 0x795(%rax)
jne 0xc9926
movq -0xc8(%rbp), %rax
movb $0x1, 0x795(%rax)
movb $0x1, 0x1d0(%rax)
movq -0xc8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
leaq 0x7edce(%rip), %r8      # 0x14870e
callq 0x79220
jmp 0xc9d7f
movq -0xc8(%rbp), %rax
testb $0x1, 0x795(%rax)
jne 0xc996f
movq -0xc8(%rbp), %rax
movb $0x1, 0x795(%rax)
movb $0x1, 0x1d0(%rax)
movq -0xc8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
leaq 0x7ed9e(%rip), %r8      # 0x148727
callq 0x79220
jmp 0xc9d7f
movq -0xc8(%rbp), %rax
testb $0x1, 0x794(%rax)
jne 0xc99b8
movq -0xc8(%rbp), %rax
movb $0x1, 0x794(%rax)
movb $0x1, 0x1d0(%rax)
movq -0xc8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
leaq 0x7ed70(%rip), %r8      # 0x148742
callq 0x79220
jmp 0xc9d7f
movq -0xc8(%rbp), %rax
testb $0x1, 0x794(%rax)
jne 0xc9a01
movq -0xc8(%rbp), %rax
movb $0x1, 0x794(%rax)
movb $0x1, 0x1d0(%rax)
movq -0xc8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
leaq 0x7ed40(%rip), %r8      # 0x14875b
callq 0x79220
jmp 0xc9d7f
movq -0xc8(%rbp), %rax
testb $0x1, 0x797(%rax)
jne 0xc9a4a
movq -0xc8(%rbp), %rax
movb $0x1, 0x797(%rax)
movb $0x1, 0x1d0(%rax)
movq -0xc8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
leaq 0x7ed12(%rip), %r8      # 0x148776
callq 0x79220
jmp 0xc9d7f
movq -0xc8(%rbp), %rax
testb $0x1, 0x797(%rax)
jne 0xc9a93
movq -0xc8(%rbp), %rax
movb $0x1, 0x797(%rax)
movb $0x1, 0x1d0(%rax)
movq -0xc8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
leaq 0x7ece3(%rip), %r8      # 0x148790
callq 0x79220
jmp 0xc9d7f
movq -0xc8(%rbp), %rax
testb $0x1, 0x796(%rax)
jne 0xc9adc
movq -0xc8(%rbp), %rax
movb $0x1, 0x796(%rax)
movb $0x1, 0x1d0(%rax)
movq -0xc8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
leaq 0x7ecb6(%rip), %r8      # 0x1487ac
callq 0x79220
jmp 0xc9d7f
movq -0xc8(%rbp), %rax
testb $0x1, 0x796(%rax)
jne 0xc9b25
movq -0xc8(%rbp), %rax
movb $0x1, 0x796(%rax)
movb $0x1, 0x1d0(%rax)
movq -0xc8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
leaq 0x7ec87(%rip), %r8      # 0x1487c6
callq 0x79220
jmp 0xc9d7f
movb $0x1, -0xaa(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0xf8(%rbp)
leaq -0xa9(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x7650
movq -0xf0(%rbp), %rdx
leaq 0x7ec60(%rip), %rsi     # 0x1487e2
leaq -0xa8(%rbp), %rdi
callq 0x7520
jmp 0xc9b90
movq -0xf8(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x9c50
jmp 0xc9ba5
movq -0xf8(%rbp), %rdi
movb $0x0, -0xaa(%rbp)
leaq 0xe421e(%rip), %rsi     # 0x1addd8
leaq -0xbff31(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0xc9d91
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xc9bf1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x7708
leaq -0xa9(%rbp), %rdi
callq 0x73d0
testb $0x1, -0xaa(%rbp)
jne 0xc9c08
jmp 0xc9c14
movq -0xf8(%rbp), %rdi
callq 0x72c0
jmp 0xc9d88
movq -0xc8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
leaq 0x7ebe6(%rip), %r8      # 0x148819
callq 0x79220
jmp 0xc9d7f
movq -0xc8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
leaq 0x7ebce(%rip), %r8      # 0x148825
callq 0x79220
jmp 0xc9d7f
movq -0xc8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xea90
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
cmpl $0x2, 0x14(%rax)
jne 0xc9cbb
movq -0xb8(%rbp), %rax
cmpl $0x2, 0x18(%rax)
jne 0xc9cbb
movq -0xc8(%rbp), %rax
testb $0x1, 0x79a(%rax)
jne 0xc9cb6
movq -0xc8(%rbp), %rax
movb $0x1, 0x79a(%rax)
movb $0x1, 0x1d0(%rax)
jmp 0xc9d41
movq -0xb8(%rbp), %rax
cmpl $0x3, 0x14(%rax)
jne 0xc9cfc
movq -0xb8(%rbp), %rax
cmpl $0x3, 0x18(%rax)
jne 0xc9cfc
movq -0xc8(%rbp), %rax
testb $0x1, 0x79b(%rax)
jne 0xc9cfa
movq -0xc8(%rbp), %rax
movb $0x1, 0x79b(%rax)
movb $0x1, 0x1d0(%rax)
jmp 0xc9d3f
movq -0xb8(%rbp), %rax
cmpl $0x4, 0x14(%rax)
jne 0xc9d3d
movq -0xb8(%rbp), %rax
cmpl $0x4, 0x18(%rax)
jne 0xc9d3d
movq -0xc8(%rbp), %rax
testb $0x1, 0x79c(%rax)
jne 0xc9d3b
movq -0xc8(%rbp), %rax
movb $0x1, 0x79c(%rax)
movb $0x1, 0x1d0(%rax)
jmp 0xc9d3d
jmp 0xc9d3f
jmp 0xc9d41
movq -0xc8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
leaq 0x7ead7(%rip), %r8      # 0x148832
callq 0x79220
jmp 0xc9d7f
movq -0xc8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movl -0x14(%rbp), %ecx
movq -0x20(%rbp), %r8
movl -0x24(%rbp), %r9d
callq 0x7e110
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x7640
nopw %cs:(%rax,%rax)