#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 *);
float rand_float();
float stdlib_base_deg2radf(float);
double tic();
double benchmark() {
  double elapsed;
  double t;
  float x;
  float y;
  int i;
  t = tic();
  for (i = 0; i < 1000000; i++) {
    x = (720.0f * rand_float()) - 360.0f;
    y = stdlib_base_deg2radf(x);
    if (y != y) {
      printf("should not return NaN\n");
      break;
    }
  }
  elapsed = tic() - t;
  if (y != y) {
    printf("should not return NaN\n");
  }
  return elapsed;
}


x86 assembly (clang, -O0):
<benchmark>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1050 <tic@plt>
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0xf4240,-0x1c(%rbp)
jge    11d9 <benchmark+0x99>
mov    $0x0,%al
call   1030 <rand_float@plt>
movss  0xe89(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe81(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
call   1060 <stdlib_base_deg2radf@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
ucomiss -0x18(%rbp),%xmm0
jne    11b5 <benchmark+0x75>
jp     11b5 <benchmark+0x75>
jmp    11c6 <benchmark+0x86>
lea    0xe4c(%rip),%rdi
call   1040 <printf@plt>
jmp    11d9 <benchmark+0x99>
jmp    11cb <benchmark+0x8b>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115b <benchmark+0x1b>
mov    $0x0,%al
call   1050 <tic@plt>
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movss  -0x18(%rbp),%xmm0
ucomiss -0x18(%rbp),%xmm0
jne    1204 <benchmark+0xc4>
jp     1204 <benchmark+0xc4>
jmp    1210 <benchmark+0xd0>
lea    0xdfd(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<benchmark>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1050 <tic@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0xf4240,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <rand_float@plt>
mulss  0xe91(%rip),%xmm0
addss  0xe8d(%rip),%xmm0
call   1060 <stdlib_base_deg2radf@plt>
ucomiss %xmm0,%xmm0
jp     118f <benchmark+0x4f>
add    $0xffffffff,%ebx
jne    1160 <benchmark+0x20>
xor    %eax,%eax
call   1050 <tic@plt>
jmp    11b7 <benchmark+0x77>
lea    0xe72(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <tic@plt>
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
call   1030 <puts@plt>
movsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"should not return NaN\0A\00"
define double @benchmark() {
%1 = alloca double
%2 = alloca double
%3 = alloca float
%4 = alloca float
%5 = alloca i32
%6 = call double (...) @tic()
store double %6, double* %2
store i32 0, i32* %5
br label %7
7: ; preds = %21, %0
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 1000000
br i1 %9, label %10, label %24
10: ; preds = %7
%11 = call float (...) @rand_float()
%12 = call float @llvm.fmuladd.f32(float 7.200000e+02, float %11, float -3.600000e+02)
store float %12, float* %3
%13 = load float, float* %3
%14 = call float @stdlib_base_deg2radf(float %13)
store float %14, float* %4
%15 = load float, float* %4
%16 = load float, float* %4
%17 = fcmp une float %15, %16
br i1 %17, label %18, label %20
18: ; preds = %10
%19 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %24
20: ; preds = %10
br label %21
21: ; preds = %20
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %7
24: ; preds = %18, %7
%25 = call double (...) @tic()
%26 = load double, double* %2
%27 = fsub double %25, %26
store double %27, double* %1
%28 = load float, float* %4
%29 = load float, float* %4
%30 = fcmp une float %28, %29
br i1 %30, label %31, label %33
31: ; preds = %24
%32 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %33
33: ; preds = %31, %24
%34 = load double, double* %1
ret double %34
}

LLVM IR (-O2):
@str.1 = [22 x i8] c"should not return NaN\00"
define double @benchmark() {
%1 = tail call double (...) @tic()
br label %5
2: ; preds = %5
%3 = add nuw nsw i32 %6, 1
%4 = icmp eq i32 %3, 1000000
br i1 %4, label %11, label %5
5: ; preds = %0, %2
%6 = phi i32 [ 0, %0 ], [ %3, %2 ]
%7 = tail call float (...) @rand_float()
%8 = tail call float @llvm.fmuladd.f32(float %7, float 7.200000e+02, float -3.600000e+02)
%9 = tail call float @stdlib_base_deg2radf(float %8)
%10 = fcmp uno float %9, 0.000000e+00
br i1 %10, label %13, label %2
11: ; preds = %2
%12 = tail call double (...) @tic()
br label %17
13: ; preds = %5
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.1, i64 0, i64 0))
%15 = tail call double (...) @tic()
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.1, i64 0, i64 0))
br label %17
17: ; preds = %11, %13
%18 = phi double [ %15, %13 ], [ %12, %11 ]
%19 = fsub double %18, %1
ret double %19
}