#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 */
double incbi(double, double, double);
int /*<<< orphan*/ printf(char *);
double rand_double();
double tic();
double benchmark() {
  double elapsed;
  double x;
  double a;
  double b;
  double y;
  double t;
  int i;
  t = tic();
  for (i = 0; i < 1000000; i++) {
    x = rand_double();
    a = (1000.0 * rand_double()) + 0.1;
    b = (1000.0 * rand_double()) + 0.1;
    y = incbi(a, b, 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    $0x40,%rsp
mov    $0x0,%al
call   1050 <tic@plt>
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0xf4240,-0x34(%rbp)
jge    1214 <benchmark+0xd4>
mov    $0x0,%al
call   1060 <rand_double@plt>
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1060 <rand_double@plt>
movsd  0xe7d(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe79(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1060 <rand_double@plt>
movsd  0xe59(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe55(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
call   1030 <incbi@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jne    11f0 <benchmark+0xb0>
jp     11f0 <benchmark+0xb0>
jmp    1201 <benchmark+0xc1>
lea    0xe19(%rip),%rdi
call   1040 <printf@plt>
jmp    1214 <benchmark+0xd4>
jmp    1206 <benchmark+0xc6>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    115b <benchmark+0x1b>
mov    $0x0,%al
call   1050 <tic@plt>
subsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x28(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jne    1240 <benchmark+0x100>
jp     1240 <benchmark+0x100>
jmp    124c <benchmark+0x10c>
lea    0xdc9(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<benchmark>:
push   %rbx
sub    $0x20,%rsp
xor    %eax,%eax
call   1050 <tic@plt>
movsd  %xmm0,0x10(%rsp)
mov    $0xf4240,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <rand_double@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1060 <rand_double@plt>
movapd %xmm0,%xmm1
movsd  0xe80(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xe7c(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
xor    %eax,%eax
call   1060 <rand_double@plt>
movapd %xmm0,%xmm1
mulsd  0xe57(%rip),%xmm1
addsd  0xe57(%rip),%xmm1
movsd  0x18(%rsp),%xmm0
movsd  0x8(%rsp),%xmm2
call   1030 <incbi@plt>
ucomisd %xmm0,%xmm0
jp     11d6 <benchmark+0x96>
add    $0xffffffff,%ebx
jne    1160 <benchmark+0x20>
xor    %eax,%eax
call   1050 <tic@plt>
jmp    1200 <benchmark+0xc0>
lea    0xe33(%rip),%rbx
mov    %rbx,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <tic@plt>
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
call   1040 <puts@plt>
movsd  0x8(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
add    $0x20,%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 double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = call double (...) @tic()
store double %8, double* %6
store i32 0, i32* %7
br label %9
9: ; preds = %28, %0
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 1000000
br i1 %11, label %12, label %31
12: ; preds = %9
%13 = call double (...) @rand_double()
store double %13, double* %2
%14 = call double (...) @rand_double()
%15 = call double @llvm.fmuladd.f64(double 1.000000e+03, double %14, double 1.000000e-01)
store double %15, double* %3
%16 = call double (...) @rand_double()
%17 = call double @llvm.fmuladd.f64(double 1.000000e+03, double %16, double 1.000000e-01)
store double %17, double* %4
%18 = load double, double* %3
%19 = load double, double* %4
%20 = load double, double* %2
%21 = call double @incbi(double %18, double %19, double %20)
store double %21, double* %5
%22 = load double, double* %5
%23 = load double, double* %5
%24 = fcmp une double %22, %23
br i1 %24, label %25, label %27
25: ; preds = %12
%26 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %31
27: ; preds = %12
br label %28
28: ; preds = %27
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
br label %9
31: ; preds = %25, %9
%32 = call double (...) @tic()
%33 = load double, double* %6
%34 = fsub double %32, %33
store double %34, double* %1
%35 = load double, double* %5
%36 = load double, double* %5
%37 = fcmp une double %35, %36
br i1 %37, label %38, label %40
38: ; preds = %31
%39 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %40
40: ; preds = %38, %31
%41 = load double, double* %1
ret double %41
}

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 %14, label %5
5: ; preds = %0, %2
%6 = phi i32 [ 0, %0 ], [ %3, %2 ]
%7 = tail call double (...) @rand_double()
%8 = tail call double (...) @rand_double()
%9 = tail call double @llvm.fmuladd.f64(double %8, double 1.000000e+03, double 1.000000e-01)
%10 = tail call double (...) @rand_double()
%11 = tail call double @llvm.fmuladd.f64(double %10, double 1.000000e+03, double 1.000000e-01)
%12 = tail call double @incbi(double %9, double %11, double %7)
%13 = fcmp uno double %12, 0.000000e+00
br i1 %13, label %16, label %2
14: ; preds = %2
%15 = tail call double (...) @tic()
br label %20
16: ; preds = %5
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.1, i64 0, i64 0))
%18 = tail call double (...) @tic()
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.1, i64 0, i64 0))
br label %20
20: ; preds = %14, %16
%21 = phi double [ %18, %16 ], [ %15, %14 ]
%22 = fsub double %21, %1
ret double %22
}