#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 tic();
double benchmark() {
  double elapsed;
  double x;
  double y;
  double t;
  int i;
  t = tic();
  for (i = 0; i < 1000000; i++) {
    x = 0.0;
    y = 0.0;
    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    $0x30,%rsp
mov    $0x0,%al
call   1040 <tic@plt>
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0xf4240,-0x24(%rbp)
jge    1197 <benchmark+0x77>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    1173 <benchmark+0x53>
jp     1173 <benchmark+0x53>
jmp    1184 <benchmark+0x64>
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
jmp    1197 <benchmark+0x77>
jmp    1189 <benchmark+0x69>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113b <benchmark+0x1b>
mov    $0x0,%al
call   1040 <tic@plt>
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x18(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    11c3 <benchmark+0xa3>
jp     11c3 <benchmark+0xa3>
jmp    11cf <benchmark+0xaf>
lea    0xe36(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<benchmark>:
push   %rax
xor    %eax,%eax
call   1030 <tic@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <tic@plt>
subsd  (%rsp),%xmm0
pop    %rax
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 i32
%6 = call double (...) @tic()
store double %6, double* %4
store i32 0, i32* %5
br label %7
7: ; preds = %17, %0
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 1000000
br i1 %9, label %10, label %20
10: ; preds = %7
store double 0.000000e+00, double* %2
store double 0.000000e+00, double* %3
%11 = load double, double* %3
%12 = load double, double* %3
%13 = fcmp une double %11, %12
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %20
16: ; preds = %10
br label %17
17: ; preds = %16
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
store i32 %19, i32* %5
br label %7
20: ; preds = %14, %7
%21 = call double (...) @tic()
%22 = load double, double* %4
%23 = fsub double %21, %22
store double %23, double* %1
%24 = load double, double* %3
%25 = load double, double* %3
%26 = fcmp une double %24, %25
br i1 %26, label %27, label %29
27: ; preds = %20
%28 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %29
29: ; preds = %27, %20
%30 = load double, double* %1
ret double %30
}

LLVM IR (-O2):
define double @benchmark() {
%1 = tail call double (...) @tic()
%2 = tail call double (...) @tic()
%3 = fsub double %2, %1
ret double %3
}