#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*/ printf(char *);
int rc_saturate_float(float *val, float min, float max) {
  if (min > max) {
    printf("ERROR: in rc_saturate_float, min must be less than max\n");
    return -1;
  }
  if (*val > max) {
    *val = max;
    return 1;
  } else if (*val < min) {
    *val = min;
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<rc_saturate_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
movss  %xmm1,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
ucomiss -0x18(%rbp),%xmm0
jbe    114d <rc_saturate_float+0x3d>
lea    0xec4(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b3 <rc_saturate_float+0xa3>
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
ucomiss -0x18(%rbp),%xmm0
jbe    1178 <rc_saturate_float+0x68>
movss  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11b3 <rc_saturate_float+0xa3>
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm1
movss  -0x14(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11a7 <rc_saturate_float+0x97>
movss  -0x14(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11b3 <rc_saturate_float+0xa3>
jmp    11ac <rc_saturate_float+0x9c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rc_saturate_float>:
push   %rax
ucomiss %xmm1,%xmm0
jbe    1129 <rc_saturate_float+0x19>
lea    0xee3(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret
movss  (%rdi),%xmm2
ucomiss %xmm1,%xmm2
jbe    1138 <rc_saturate_float+0x28>
movss  %xmm1,(%rdi)
jmp    1143 <rc_saturate_float+0x33>
xor    %eax,%eax
ucomiss %xmm2,%xmm0
jbe    1148 <rc_saturate_float+0x38>
movss  %xmm0,(%rdi)
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [56 x i8] c"ERROR: in rc_saturate_float, min must be less than max\0A\00"
define i32 @rc_saturate_float(float* %0, float %1, float %2) {
%4 = alloca i32
%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 = load float, float* %7
%10 = fcmp ogt float %8, %9
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %4
br label %31
13: ; preds = %3
%14 = load float*, float** %5
%15 = load float, float* %14
%16 = load float, float* %7
%17 = fcmp ogt float %15, %16
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = load float, float* %7
%20 = load float*, float** %5
store float %19, float* %20
store i32 1, i32* %4
br label %31
21: ; preds = %13
%22 = load float*, float** %5
%23 = load float, float* %22
%24 = load float, float* %6
%25 = fcmp olt float %23, %24
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = load float, float* %6
%28 = load float*, float** %5
store float %27, float* %28
store i32 1, i32* %4
br label %31
29: ; preds = %21
br label %30
30: ; preds = %29
store i32 0, i32* %4
br label %31
31: ; preds = %30, %26, %18, %11
%32 = load i32, i32* %4
ret i32 %32
}

LLVM IR (-O2):
@str = [55 x i8] c"ERROR: in rc_saturate_float, min must be less than max\00"
define i32 @rc_saturate_float(float* nocapture %0, float %1, float %2) {
%4 = fcmp ogt float %1, %2
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str, i64 0, i64 0))
br label %14
7: ; preds = %3
%8 = load float, float* %0
%9 = fcmp ogt float %8, %2
br i1 %9, label %10, label %11
10: ; preds = %7
store float %2, float* %0
br label %14
11: ; preds = %7
%12 = fcmp olt float %8, %1
br i1 %12, label %13, label %14
13: ; preds = %11
store float %1, float* %0
br label %14
14: ; preds = %11, %13, %10, %5
%15 = phi i32 [ -1, %5 ], [ 1, %10 ], [ 1, %13 ], [ 0, %11 ]
ret i32 %15
}