#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 */
scalar_t__ stdlib_base_is_nanf(float const);
scalar_t__ stdlib_base_is_negative_zerof(float const);
float stdlib_base_clampf(const float v, const float min, const float max) {
  if (stdlib_base_is_nanf(v) || stdlib_base_is_nanf(min) ||
      stdlib_base_is_nanf(max)) {
    return 0.0f / 0.0f;
  }
  if (v < min) {
    return min;
  }
  if (v > max) {
    return max;
  }
  if (min == 0.0f && stdlib_base_is_negative_zerof(v)) {
    return min;
  }
  if (v == 0.0f && stdlib_base_is_negative_zerof(max)) {
    return max;
  }
  return v;
}


x86 assembly (clang, -O0):
<stdlib_base_clampf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
call   1040 <stdlib_base_is_nanf@plt>
cmp    $0x0,%rax
jne    1173 <stdlib_base_clampf+0x53>
movss  -0xc(%rbp),%xmm0
call   1040 <stdlib_base_is_nanf@plt>
cmp    $0x0,%rax
jne    1173 <stdlib_base_clampf+0x53>
movss  -0x10(%rbp),%xmm0
call   1040 <stdlib_base_is_nanf@plt>
cmp    $0x0,%rax
je     1185 <stdlib_base_clampf+0x65>
movss  0xe85(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1243 <stdlib_base_clampf+0x123>
movss  -0x8(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11a7 <stdlib_base_clampf+0x87>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1243 <stdlib_base_clampf+0x123>
movss  -0x8(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    11c5 <stdlib_base_clampf+0xa5>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1243 <stdlib_base_clampf+0x123>
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11ff <stdlib_base_clampf+0xdf>
jp     11ff <stdlib_base_clampf+0xdf>
movss  -0x8(%rbp),%xmm0
call   1030 <stdlib_base_is_negative_zerof@plt>
cmp    $0x0,%rax
je     11ff <stdlib_base_clampf+0xdf>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1243 <stdlib_base_clampf+0x123>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1239 <stdlib_base_clampf+0x119>
jp     1239 <stdlib_base_clampf+0x119>
movss  -0x10(%rbp),%xmm0
call   1030 <stdlib_base_is_negative_zerof@plt>
cmp    $0x0,%rax
je     1239 <stdlib_base_clampf+0x119>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1243 <stdlib_base_clampf+0x123>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stdlib_base_clampf>:
sub    $0x18,%rsp
movss  %xmm2,0x10(%rsp)
movss  %xmm1,0x14(%rsp)
movss  %xmm0,0xc(%rsp)
call   1040 <stdlib_base_is_nanf@plt>
movss  0xebd(%rip),%xmm0
test   %rax,%rax
je     114d <stdlib_base_clampf+0x2d>
add    $0x18,%rsp
ret
movss  0x14(%rsp),%xmm0
call   1040 <stdlib_base_is_nanf@plt>
test   %rax,%rax
je     116a <stdlib_base_clampf+0x4a>
movss  0xe9b(%rip),%xmm0
add    $0x18,%rsp
ret
movss  0x10(%rsp),%xmm0
call   1040 <stdlib_base_is_nanf@plt>
test   %rax,%rax
movss  0xe80(%rip),%xmm0
jne    1148 <stdlib_base_clampf+0x28>
movss  0xc(%rsp),%xmm0
movss  0x14(%rsp),%xmm2
ucomiss %xmm0,%xmm2
jbe    119b <stdlib_base_clampf+0x7b>
movaps %xmm2,%xmm0
add    $0x18,%rsp
ret
movss  0x10(%rsp),%xmm1
ucomiss %xmm1,%xmm0
jbe    11ae <stdlib_base_clampf+0x8e>
movaps %xmm1,%xmm0
add    $0x18,%rsp
ret
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm2
jne    11d5 <stdlib_base_clampf+0xb5>
jp     11d5 <stdlib_base_clampf+0xb5>
movss  0xc(%rsp),%xmm0
call   1030 <stdlib_base_is_negative_zerof@plt>
xorps  %xmm1,%xmm1
movss  0x14(%rsp),%xmm0
test   %rax,%rax
jne    1148 <stdlib_base_clampf+0x28>
movss  0xc(%rsp),%xmm0
ucomiss %xmm1,%xmm0
jne    11fc <stdlib_base_clampf+0xdc>
jp     11fc <stdlib_base_clampf+0xdc>
movss  0x10(%rsp),%xmm0
call   1030 <stdlib_base_is_negative_zerof@plt>
movss  0x10(%rsp),%xmm0
test   %rax,%rax
jne    1148 <stdlib_base_clampf+0x28>
movss  0xc(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define float @stdlib_base_clampf(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* %5
%9 = call i64 @stdlib_base_is_nanf(float %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %19, label %11
11: ; preds = %3
%12 = load float, float* %6
%13 = call i64 @stdlib_base_is_nanf(float %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %11
%16 = load float, float* %7
%17 = call i64 @stdlib_base_is_nanf(float %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15, %11, %3
store float 0x7FF8000000000000, float* %4
br label %52
20: ; preds = %15
%21 = load float, float* %5
%22 = load float, float* %6
%23 = fcmp olt float %21, %22
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = load float, float* %6
store float %25, float* %4
br label %52
26: ; preds = %20
%27 = load float, float* %5
%28 = load float, float* %7
%29 = fcmp ogt float %27, %28
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = load float, float* %7
store float %31, float* %4
br label %52
32: ; preds = %26
%33 = load float, float* %6
%34 = fcmp oeq float %33, 0.000000e+00
br i1 %34, label %35, label %41
35: ; preds = %32
%36 = load float, float* %5
%37 = call i64 @stdlib_base_is_negative_zerof(float %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = load float, float* %6
store float %40, float* %4
br label %52
41: ; preds = %35, %32
%42 = load float, float* %5
%43 = fcmp oeq float %42, 0.000000e+00
br i1 %43, label %44, label %50
44: ; preds = %41
%45 = load float, float* %7
%46 = call i64 @stdlib_base_is_negative_zerof(float %45)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %44
%49 = load float, float* %7
store float %49, float* %4
br label %52
50: ; preds = %44, %41
%51 = load float, float* %5
store float %51, float* %4
br label %52
52: ; preds = %50, %48, %39, %30, %24, %19
%53 = load float, float* %4
ret float %53
}

LLVM IR (-O2):
define float @stdlib_base_clampf(float %0, float %1, float %2) {
%4 = tail call i64 @stdlib_base_is_nanf(float %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %27
6: ; preds = %3
%7 = tail call i64 @stdlib_base_is_nanf(float %1)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %27
9: ; preds = %6
%10 = tail call i64 @stdlib_base_is_nanf(float %2)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %27
12: ; preds = %9
%13 = fcmp olt float %0, %1
br i1 %13, label %27, label %14
14: ; preds = %12
%15 = fcmp ogt float %0, %2
br i1 %15, label %27, label %16
16: ; preds = %14
%17 = fcmp oeq float %1, 0.000000e+00
br i1 %17, label %18, label %21
18: ; preds = %16
%19 = tail call i64 @stdlib_base_is_negative_zerof(float %0)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %18, %16
%22 = fcmp oeq float %0, 0.000000e+00
br i1 %22, label %23, label %26
23: ; preds = %21
%24 = tail call i64 @stdlib_base_is_negative_zerof(float %2)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %23, %21
br label %27
27: ; preds = %23, %18, %14, %12, %3, %6, %9, %26
%28 = phi float [ %0, %26 ], [ 0x7FF8000000000000, %9 ], [ 0x7FF8000000000000, %6 ], [ 0x7FF8000000000000, %3 ], [ %1, %12 ], [ %2, %14 ], [ %1, %18 ], [ %2, %23 ]
ret float %28
}