#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdlib_base_float64_set_low_word(int, double *);
double tic();
double benchmark() {
  double elapsed;
  uint32_t l;
  double x;
  double t;
  int i;
  x = 3.14;
  l = 1374389535;
  t = tic();
  for (i = 0; i < 1000000; i++) {
    stdlib_base_float64_set_low_word(l + i, &x);
    if (x != x) {
      printf("should not return NaN\n");
      break;
    }
  }
  elapsed = tic() - t;
  if (x != x) {
    printf("should not return NaN\n");
  }
  return elapsed;
}


x86 assembly (clang, -O0):
<benchmark>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  0xec0(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x51eb851f,-0xc(%rbp)
mov    $0x0,%al
call   1040 <tic@plt>
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0xf4240,-0x24(%rbp)
jge    11ba <benchmark+0x8a>
mov    -0xc(%rbp),%edi
add    -0x24(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   1050 <stdlib_base_float64_set_low_word@plt>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    1196 <benchmark+0x66>
jp     1196 <benchmark+0x66>
jmp    11a7 <benchmark+0x77>
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
jmp    11ba <benchmark+0x8a>
jmp    11ac <benchmark+0x7c>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115f <benchmark+0x2f>
mov    $0x0,%al
call   1040 <tic@plt>
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x18(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    11e6 <benchmark+0xb6>
jp     11e6 <benchmark+0xb6>
jmp    11f2 <benchmark+0xc2>
lea    0xe1b(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<benchmark>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movabs $0x40091eb851eb851f,%rax
1e 09 40
mov    %rax,(%rsp)
xor    %eax,%eax
call   1040 <tic@plt>
movsd  %xmm0,0x10(%rsp)
mov    $0x51eb851f,%ebx
mov    %rsp,%r14
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <stdlib_base_float64_set_low_word@plt>
movsd  (%rsp),%xmm0
ucomisd %xmm0,%xmm0
jp     1182 <benchmark+0x52>
add    $0x1,%ebx
cmp    $0x51fac75f,%ebx
jne    1160 <benchmark+0x30>
jmp    118e <benchmark+0x5e>
lea    0xe77(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <tic@plt>
movsd  (%rsp),%xmm1
ucomisd %xmm1,%xmm1
jp     11ae <benchmark+0x7e>
subsd  0x10(%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe4b(%rip),%rdi
movsd  %xmm0,0x8(%rsp)
call   1030 <puts@plt>
movsd  0x8(%rsp),%xmm0
jmp    11a0 <benchmark+0x70>

LLVM IR (-O0):
@.str = [23 x i8] c"should not return NaN\0A\00"
define double @benchmark() {
%1 = alloca double
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = alloca i32
store double 3.140000e+00, double* %3
store i32 1374389535, i32* %2
%6 = call double (...) @tic()
store double %6, double* %4
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 = load i32, i32* %2
%12 = load i32, i32* %5
%13 = add nsw i32 %11, %12
%14 = call i32 @stdlib_base_float64_set_low_word(i32 %13, double* %3)
%15 = load double, double* %3
%16 = load double, double* %3
%17 = fcmp une double %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* %4
%27 = fsub double %25, %26
store double %27, double* %1
%28 = load double, double* %3
%29 = load double, double* %3
%30 = fcmp une double %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 = alloca double
%2 = bitcast double* %1 to i8*
store double 3.140000e+00, double* %1
%3 = tail call double (...) @tic()
br label %7
4: ; preds = %7
%5 = add nuw nsw i32 %8, 1
%6 = icmp eq i32 %5, 1000000
br i1 %6, label %15, label %7
7: ; preds = %0, %4
%8 = phi i32 [ 0, %0 ], [ %5, %4 ]
%9 = add nuw nsw i32 %8, 1374389535
%10 = call i32 @stdlib_base_float64_set_low_word(i32 %9, double* %1)
%11 = load double, double* %1
%12 = fcmp uno double %11, 0.000000e+00
br i1 %12, label %13, label %4
13: ; preds = %7
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.1, i64 0, i64 0))
br label %15
15: ; preds = %4, %13
%16 = call double (...) @tic()
%17 = load double, double* %1
%18 = fcmp uno double %17, 0.000000e+00
br i1 %18, label %19, label %21
19: ; preds = %15
%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 = %19, %15
%22 = fsub double %16, %3
ret double %22
}