#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 *, double, double, double, double);
double stdlib_base_clamp(double, double, double);
int main() {
  double x[] = {3.14, -3.14, 0.0, 0.0 / 0.0};
  double y;
  int i;
  for (i = 0; i < 4; i++) {
    y = stdlib_base_clamp(x[i], -3.0, 3.0);
    printf("clamp(%lf, %lf, %lf) = %lf\n", x[i], -3.0, 3.0, y);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeda(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xed7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xed4(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xed1(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x4,-0x3c(%rbp)
jge    11c9 <main+0xa9>
movslq -0x3c(%rbp),%rax
movsd  -0x30(%rbp,%rax,8),%xmm0
movsd  0xe82(%rip),%xmm1
movsd  0xe82(%rip),%xmm2
call   1040 <stdlib_base_clamp@plt>
movsd  %xmm0,-0x38(%rbp)
movslq -0x3c(%rbp),%rax
movsd  -0x30(%rbp,%rax,8),%xmm0
movsd  -0x38(%rbp),%xmm3
lea    0xe8a(%rip),%rdi
movsd  0xe52(%rip),%xmm1
movsd  0xe52(%rip),%xmm2
call   1030 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1162 <main+0x42>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
movsd  0xed7(%rip),%xmm0
movsd  0xed7(%rip),%xmm1
movsd  0xed7(%rip),%xmm2
call   1040 <stdlib_base_clamp@plt>
movaps %xmm0,%xmm3
lea    0xee0(%rip),%rbx
mov    %rbx,%rdi
movsd  0xead(%rip),%xmm0
movsd  0xead(%rip),%xmm1
movsd  0xead(%rip),%xmm2
call   1030 <printf@plt>
movsd  0xea8(%rip),%xmm0
movsd  0xe90(%rip),%xmm1
movsd  0xe90(%rip),%xmm2
call   1040 <stdlib_base_clamp@plt>
movaps %xmm0,%xmm3
mov    %rbx,%rdi
movsd  0xe85(%rip),%xmm0
movsd  0xe6d(%rip),%xmm1
movsd  0xe6d(%rip),%xmm2
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
movsd  0xe55(%rip),%xmm1
movsd  0xe55(%rip),%xmm2
call   1040 <stdlib_base_clamp@plt>
movaps %xmm0,%xmm3
xorps  %xmm0,%xmm0
mov    %rbx,%rdi
movsd  0xe37(%rip),%xmm1
movsd  0xe37(%rip),%xmm2
call   1030 <printf@plt>
movsd  0xe3a(%rip),%xmm0
movsd  0xe1a(%rip),%xmm1
movsd  0xe1a(%rip),%xmm2
call   1040 <stdlib_base_clamp@plt>
movaps %xmm0,%xmm3
mov    %rbx,%rdi
movsd  0xe17(%rip),%xmm0
movsd  0xdf7(%rip),%xmm1
movsd  0xdf7(%rip),%xmm2
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.x = [4 x double] [double 3.140000e+00, double -3.140000e+00, double 0.000000e+00, double 0x7FF8000000000000]
@.str = [28 x i8] c"clamp(%lf, %lf, %lf) = %lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x double]
%3 = alloca double
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [4 x double]* %2 to i8*
store i32 0, i32* %4
br label %6
6: ; preds = %21, %0
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 4
br i1 %8, label %9, label %24
9: ; preds = %6
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 0, i64 %11
%13 = load double, double* %12
%14 = call double @stdlib_base_clamp(double %13, double -3.000000e+00, double 3.000000e+00)
store double %14, double* %3
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 0, i64 %16
%18 = load double, double* %17
%19 = load double, double* %3
%20 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), double %18, double -3.000000e+00, double 3.000000e+00, double %19)
br label %21
21: ; preds = %9
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %6
24: ; preds = %6
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@.str = [28 x i8] c"clamp(%lf, %lf, %lf) = %lf\0A\00"
define i32 @main() {
%1 = tail call double @stdlib_base_clamp(double 3.140000e+00, double -3.000000e+00, double 3.000000e+00)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), double 3.140000e+00, double -3.000000e+00, double 3.000000e+00, double %1)
%3 = tail call double @stdlib_base_clamp(double -3.140000e+00, double -3.000000e+00, double 3.000000e+00)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), double -3.140000e+00, double -3.000000e+00, double 3.000000e+00, double %3)
%5 = tail call double @stdlib_base_clamp(double 0.000000e+00, double -3.000000e+00, double 3.000000e+00)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), double 0.000000e+00, double -3.000000e+00, double 3.000000e+00, double %5)
%7 = tail call double @stdlib_base_clamp(double 0x7FF8000000000000, double -3.000000e+00, double 3.000000e+00)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), double 0x7FF8000000000000, double -3.000000e+00, double 3.000000e+00, double %7)
ret i32 0
}