#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*/ isnan(float);
float flim(float x, float a, float b) {
  if (!isnan(a) && x < a) {
    return a;
  } else if (!isnan(b) && x > b) {
    return b;
  }
  return x;
}


x86 assembly (clang, -O0):
<flim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <isnan@plt>
cmp    $0x0,%eax
jne    115c <flim+0x4c>
movss  -0x8(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    115c <flim+0x4c>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    119c <flim+0x8c>
movss  -0x10(%rbp),%xmm0
call   1030 <isnan@plt>
cmp    $0x0,%eax
jne    118d <flim+0x7d>
movss  -0x8(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    118d <flim+0x7d>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    119c <flim+0x8c>
jmp    1192 <flim+0x82>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flim>:
sub    $0x38,%rsp
movaps %xmm2,0x10(%rsp)
movss  %xmm1,0xc(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm1,%xmm0
call   1030 <isnan@plt>
movss  0xc(%rsp),%xmm0
ucomiss 0x20(%rsp),%xmm0
jbe    1142 <flim+0x32>
test   %eax,%eax
jne    1142 <flim+0x32>
add    $0x38,%rsp
ret
movaps 0x10(%rsp),%xmm0
call   1030 <isnan@plt>
movaps 0x10(%rsp),%xmm0
test   %eax,%eax
je     115a <flim+0x4a>
movaps 0x20(%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
movaps 0x20(%rsp),%xmm2
cmpltss %xmm2,%xmm1
andps  %xmm1,%xmm0
andnps %xmm2,%xmm1
orps   %xmm0,%xmm1
movaps %xmm1,%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
define float @flim(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store float %0, float* %5
store float %1, float* %6
store float %2, float* %7
%8 = load float, float* %6
%9 = call i32 @isnan(float %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %3
%12 = load float, float* %5
%13 = load float, float* %6
%14 = fcmp olt float %12, %13
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = load float, float* %6
store float %16, float* %4
br label %30
17: ; preds = %11, %3
%18 = load float, float* %7
%19 = call i32 @isnan(float %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %27, label %21
21: ; preds = %17
%22 = load float, float* %5
%23 = load float, float* %7
%24 = fcmp ogt float %22, %23
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = load float, float* %7
store float %26, float* %4
br label %30
27: ; preds = %21, %17
br label %28
28: ; preds = %27
%29 = load float, float* %5
store float %29, float* %4
br label %30
30: ; preds = %28, %25, %15
%31 = load float, float* %4
ret float %31
}

LLVM IR (-O2):
define float @flim(float %0, float %1, float %2) {
%4 = tail call i32 @isnan(float %1)
%5 = icmp eq i32 %4, 0
%6 = fcmp olt float %0, %1
%7 = and i1 %6, %5
br i1 %7, label %14, label %8
8: ; preds = %3
%9 = tail call i32 @isnan(float %2)
%10 = icmp eq i32 %9, 0
%11 = fcmp ogt float %0, %2
%12 = and i1 %11, %10
%13 = select i1 %12, float %2, float %0
br label %14
14: ; preds = %8, %3
%15 = phi float [ %1, %3 ], [ %13, %8 ]
ret float %15
}