// File: rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::emit_spv_amd_shader_trinary_minmax_op(unsigned int, unsigned int, unsigned int, unsigned int const*, unsigned int)
void CompilerGLSL::emit_spv_amd_shader_trinary_minmax_op(uint32_t result_type, uint32_t id, uint32_t eop,
                                                         const uint32_t *args, uint32_t)
{
	require_extension_internal("GL_AMD_shader_trinary_minmax");

	enum AMDShaderTrinaryMinMax
	{
		FMin3AMD = 1,
		UMin3AMD = 2,
		SMin3AMD = 3,
		FMax3AMD = 4,
		UMax3AMD = 5,
		SMax3AMD = 6,
		FMid3AMD = 7,
		UMid3AMD = 8,
		SMid3AMD = 9
	};

	auto op = static_cast<AMDShaderTrinaryMinMax>(eop);

	switch (op)
	{
	case FMin3AMD:
	case UMin3AMD:
	case SMin3AMD:
		emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "min3");
		break;

	case FMax3AMD:
	case UMax3AMD:
	case SMax3AMD:
		emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "max3");
		break;

	case FMid3AMD:
	case UMid3AMD:
	case SMid3AMD:
		emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "mid3");
		break;

	default:
		statement("// unimplemented SPV AMD shader trinary minmax op ", eop);
		break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
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, -0x70(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0x68(%rbp)
callq 0x7650
movq -0x68(%rbp), %rdx
leaq 0xc33ea(%rip), %rsi     # 0x142d9a
leaq -0x48(%rbp), %rdi
callq 0x7520
jmp 0x7f9bb
movq -0x70(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x589d0
jmp 0x7f9ca
leaq -0x48(%rbp), %rdi
callq 0x7708
leaq -0x49(%rbp), %rdi
callq 0x73d0
movl -0x14(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %eax
movl %eax, -0x74(%rbp)
decl %eax
subl $0x3, %eax
jb 0x7fa43
jmp 0x7f9f1
movl -0x74(%rbp), %eax
addl $-0x4, %eax
subl $0x3, %eax
jb 0x7fa75
jmp 0x7f9fe
movl -0x74(%rbp), %eax
addl $-0x7, %eax
subl $0x3, %eax
jb 0x7faa7
jmp 0x7fad9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x7fa35
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
jmp 0x7faf6
movq -0x70(%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 0xc334d(%rip), %rax     # 0x142db7
movq %rax, (%rsp)
callq 0x798c0
jmp 0x7faed
movq -0x70(%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 0xc3320(%rip), %rax     # 0x142dbc
movq %rax, (%rsp)
callq 0x798c0
jmp 0x7faed
movq -0x70(%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 0xc32f3(%rip), %rax     # 0x142dc1
movq %rax, (%rsp)
callq 0x798c0
jmp 0x7faed
movq -0x70(%rbp), %rdi
leaq 0xc32e2(%rip), %rsi     # 0x142dc6
leaq -0x14(%rbp), %rdx
callq 0xa4050
addq $0x80, %rsp
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x7640
nop