#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 rand_double();
int /*<<< orphan*/ sici(double, double *, double *);
double tic();
double benchmark() {
  double elapsed;
  double x;
  double y;
  double z;
  double t;
  int i;
  t = tic();
  for (i = 0; i < 1000000; i++) {
    x = (100.0 * rand_double()) - 50.0;
    sici(x, &y, &z);
    if (y != y || z != z) {
      printf("should not return NaN\n");
      break;
    }
  }
  elapsed = tic() - t;
  if (y != y || z != z) {
    printf("should not return NaN\n");
  }
  return elapsed;
}


x86 assembly (clang, -O0):
<benchmark>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x0,%al
call   1040 <tic@plt>
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0xf4240,-0x2c(%rbp)
jge    11f3 <benchmark+0xb3>
mov    $0x0,%al
call   1050 <rand_double@plt>
movsd  0xe89(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe85(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <sici@plt>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    11cf <benchmark+0x8f>
jp     11cf <benchmark+0x8f>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jne    11cf <benchmark+0x8f>
jp     11cf <benchmark+0x8f>
jmp    11e0 <benchmark+0xa0>
lea    0xe3a(%rip),%rdi
call   1030 <printf@plt>
jmp    11f3 <benchmark+0xb3>
jmp    11e5 <benchmark+0xa5>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    115b <benchmark+0x1b>
mov    $0x0,%al
call   1040 <tic@plt>
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x18(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    1235 <benchmark+0xf5>
jp     1235 <benchmark+0xf5>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jne    1235 <benchmark+0xf5>
jp     1235 <benchmark+0xf5>
jmp    1241 <benchmark+0x101>
lea    0xdd4(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<benchmark>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
xor    %eax,%eax
call   1040 <tic@plt>
movsd  %xmm0,0x18(%rsp)
mov    $0xf4240,%ebp
lea    0x8(%rsp),%r14
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <rand_double@plt>
mulsd  0xe81(%rip),%xmm0
addsd  0xe81(%rip),%xmm0
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <sici@plt>
movsd  0x8(%rsp),%xmm0
ucomisd %xmm0,%xmm0
jp     11b0 <benchmark+0x70>
movsd  (%rsp),%xmm0
ucomisd %xmm0,%xmm0
jp     11b0 <benchmark+0x70>
add    $0xffffffff,%ebp
jne    1170 <benchmark+0x30>
jmp    11bc <benchmark+0x7c>
lea    0xe59(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <tic@plt>
movsd  0x8(%rsp),%xmm1
ucomisd %xmm1,%xmm1
jp     11da <benchmark+0x9a>
movsd  (%rsp),%xmm1
ucomisd %xmm1,%xmm1
jnp    11f2 <benchmark+0xb2>
lea    0xe2f(%rip),%rdi
movsd  %xmm0,0x10(%rsp)
call   1030 <puts@plt>
movsd  0x10(%rsp),%xmm0
subsd  0x18(%rsp),%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
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 i32
%7 = call double (...) @tic()
store double %7, double* %5
store i32 0, i32* %6
br label %8
8: ; preds = %26, %0
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 1000000
br i1 %10, label %11, label %29
11: ; preds = %8
%12 = call double (...) @rand_double()
%13 = call double @llvm.fmuladd.f64(double 1.000000e+02, double %12, double -5.000000e+01)
store double %13, double* %2
%14 = load double, double* %2
%15 = call i32 @sici(double %14, double* %3, double* %4)
%16 = load double, double* %3
%17 = load double, double* %3
%18 = fcmp une double %16, %17
br i1 %18, label %23, label %19
19: ; preds = %11
%20 = load double, double* %4
%21 = load double, double* %4
%22 = fcmp une double %20, %21
br i1 %22, label %23, label %25
23: ; preds = %19, %11
%24 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %29
25: ; preds = %19
br label %26
26: ; preds = %25
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %8
29: ; preds = %23, %8
%30 = call double (...) @tic()
%31 = load double, double* %5
%32 = fsub double %30, %31
store double %32, double* %1
%33 = load double, double* %3
%34 = load double, double* %3
%35 = fcmp une double %33, %34
br i1 %35, label %40, label %36
36: ; preds = %29
%37 = load double, double* %4
%38 = load double, double* %4
%39 = fcmp une double %37, %38
br i1 %39, label %40, label %42
40: ; preds = %36, %29
%41 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %42
42: ; preds = %40, %36
%43 = load double, double* %1
ret double %43
}

LLVM IR (-O2):
@str.1 = [22 x i8] c"should not return NaN\00"
define double @benchmark() {
%1 = alloca double
%2 = alloca double
%3 = bitcast double* %1 to i8*
%4 = bitcast double* %2 to i8*
%5 = tail call double (...) @tic()
br label %9
6: ; preds = %9
%7 = add nuw nsw i32 %10, 1
%8 = icmp eq i32 %7, 1000000
br i1 %8, label %21, label %9
9: ; preds = %0, %6
%10 = phi i32 [ 0, %0 ], [ %7, %6 ]
%11 = call double (...) @rand_double()
%12 = call double @llvm.fmuladd.f64(double %11, double 1.000000e+02, double -5.000000e+01)
%13 = call i32 @sici(double %12, double* %1, double* %2)
%14 = load double, double* %1
%15 = fcmp uno double %14, 0.000000e+00
%16 = load double, double* %2
%17 = fcmp uno double %16, 0.000000e+00
%18 = select i1 %15, i1 true, i1 %17
br i1 %18, label %19, label %6
19: ; preds = %9
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.1, i64 0, i64 0))
br label %21
21: ; preds = %6, %19
%22 = call double (...) @tic()
%23 = load double, double* %1
%24 = fcmp uno double %23, 0.000000e+00
%25 = load double, double* %2
%26 = fcmp uno double %25, 0.000000e+00
%27 = select i1 %24, i1 true, i1 %26
br i1 %27, label %28, label %30
28: ; preds = %21
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.1, i64 0, i64 0))
br label %30
30: ; preds = %21, %28
%31 = fsub double %22, %5
ret double %31
}