#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ assert(int);
float max(float, float);
float min(float, float);
float mid(float x, float y, float z) {
  assert(x == x);
  assert(y == y);
  assert(z == z);
  float tmp = x;
  x = min(x, z);
  z = max(tmp, z);
  return min(max(x, y), z);
}


x86 assembly (clang, -O0):
<mid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
ucomiss -0x4(%rbp),%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movss  -0x8(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movss  -0xc(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
call   1030 <min@plt>
movss  %xmm0,-0x4(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
call   1040 <max@plt>
movss  %xmm0,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
call   1040 <max@plt>
movss  -0xc(%rbp),%xmm1
call   1030 <min@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mid>:
sub    $0x18,%rsp
movss  %xmm2,0x8(%rsp)
movss  %xmm1,0x10(%rsp)
movss  %xmm0,0xc(%rsp)
xor    %edi,%edi
ucomiss %xmm0,%xmm0
setnp  %dil
call   1050 <assert@plt>
xor    %edi,%edi
movss  0x10(%rsp),%xmm0
ucomiss %xmm0,%xmm0
setnp  %dil
call   1050 <assert@plt>
xor    %edi,%edi
movss  0x8(%rsp),%xmm0
ucomiss %xmm0,%xmm0
setnp  %dil
call   1050 <assert@plt>
movss  0xc(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
call   1030 <min@plt>
movss  %xmm0,0x14(%rsp)
movss  0xc(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
call   1040 <max@plt>
movss  %xmm0,0x8(%rsp)
movss  0x14(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
call   1040 <max@plt>
movss  0x8(%rsp),%xmm1
add    $0x18,%rsp
jmp    1030 <min@plt>

LLVM IR (-O0):
define float @mid(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store float %0, float* %4
store float %1, float* %5
store float %2, float* %6
%8 = load float, float* %4
%9 = load float, float* %4
%10 = fcmp oeq float %8, %9
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load float, float* %5
%14 = load float, float* %5
%15 = fcmp oeq float %13, %14
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load float, float* %6
%19 = load float, float* %6
%20 = fcmp oeq float %18, %19
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = load float, float* %4
store float %23, float* %7
%24 = load float, float* %4
%25 = load float, float* %6
%26 = call float @min(float %24, float %25)
store float %26, float* %4
%27 = load float, float* %7
%28 = load float, float* %6
%29 = call float @max(float %27, float %28)
store float %29, float* %6
%30 = load float, float* %4
%31 = load float, float* %5
%32 = call float @max(float %30, float %31)
%33 = load float, float* %6
%34 = call float @min(float %32, float %33)
ret float %34
}

LLVM IR (-O2):
define float @mid(float %0, float %1, float %2) {
%4 = fcmp ord float %0, 0.000000e+00
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = fcmp ord float %1, 0.000000e+00
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = fcmp ord float %2, 0.000000e+00
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = tail call float @min(float %0, float %2)
%14 = tail call float @max(float %0, float %2)
%15 = tail call float @max(float %13, float %1)
%16 = tail call float @min(float %15, float %14)
ret float %16
}