#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*/ isfinite(float);
scalar_t__ isnan(float);
float dddsp_clampf(float value, float nanvalue, float min, float max) {
  value = (isnan(value) || !isfinite(value)) ? nanvalue : value;
  if (value > max) {
    value = max;
  }
  if (value < min) {
    value = min;
  }
  return value;
}


x86 assembly (clang, -O0):
<dddsp_clampf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  %xmm3,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
jne    1163 <dddsp_clampf+0x43>
movss  -0x4(%rbp),%xmm0
call   1030 <isfinite@plt>
cmp    $0x0,%eax
jne    1172 <dddsp_clampf+0x52>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    117c <dddsp_clampf+0x5c>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    119f <dddsp_clampf+0x7f>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11bc <dddsp_clampf+0x9c>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dddsp_clampf>:
sub    $0x18,%rsp
movss  %xmm3,0x14(%rsp)
movss  %xmm2,0x10(%rsp)
movss  %xmm1,0xc(%rsp)
movss  %xmm0,0x8(%rsp)
call   1040 <isnan@plt>
test   %rax,%rax
je     115a <dddsp_clampf+0x3a>
movss  0x14(%rsp),%xmm1
movss  0x10(%rsp),%xmm0
movss  0xc(%rsp),%xmm2
jmp    1181 <dddsp_clampf+0x61>
movss  0x8(%rsp),%xmm0
call   1030 <isfinite@plt>
test   %eax,%eax
movss  0xc(%rsp),%xmm2
je     1175 <dddsp_clampf+0x55>
movss  0x8(%rsp),%xmm2
movss  0x14(%rsp),%xmm1
movss  0x10(%rsp),%xmm0
minss  %xmm2,%xmm1
maxss  %xmm1,%xmm0
add    $0x18,%rsp
ret

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

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