#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*/ c_sfill(int, float, float *, int);
int /*<<< orphan*/ printf(char *);
float rand_float();
double tic();
double benchmark(int iterations, int len) {
  double elapsed;
  float x[len];
  double t;
  int i;
  for (i = 0; i < len; i++) {
    x[i] = (rand_float() * 200.0f) - 100.0f;
  }
  t = tic();
  for (i = 0; i < iterations; i++) {
    c_sfill(len, (float)i, x, 1);
    if (x[0] != x[0]) {
      printf("should not return NaN\n");
      break;
    }
  }
  elapsed = tic() - t;
  if (x[0] != x[0]) {
    printf("should not return NaN\n");
  }
  return elapsed;
}


x86 assembly (clang, -O0):
<benchmark>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c2 <benchmark+0x82>
mov    $0x0,%al
call   1030 <rand_float@plt>
mov    -0x38(%rbp),%rax
movss  0xe65(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe5d(%rip),%xmm1
addss  %xmm1,%xmm0
movslq -0x2c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    117c <benchmark+0x3c>
mov    $0x0,%al
call   1050 <tic@plt>
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1237 <benchmark+0xf7>
mov    -0x38(%rbp),%rsi
mov    -0x8(%rbp),%edi
cvtsi2ssl -0x2c(%rbp),%xmm0
mov    $0x1,%edx
call   1060 <c_sfill@plt>
mov    -0x38(%rbp),%rax
movss  (%rax),%xmm0
ucomiss (%rax),%xmm0
jne    1213 <benchmark+0xd3>
jp     1213 <benchmark+0xd3>
jmp    1224 <benchmark+0xe4>
lea    0xdee(%rip),%rdi
call   1040 <printf@plt>
jmp    1237 <benchmark+0xf7>
jmp    1229 <benchmark+0xe9>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11d5 <benchmark+0x95>
mov    $0x0,%al
call   1050 <tic@plt>
mov    -0x38(%rbp),%rax
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movss  (%rax),%xmm0
ucomiss (%rax),%xmm0
jne    1264 <benchmark+0x124>
jp     1264 <benchmark+0x124>
jmp    1270 <benchmark+0x130>
lea    0xd9d(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<benchmark>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r14d
mov    %edi,%r15d
mov    %esi,%r12d
mov    %rsp,%r13
lea    0xf(,%r12,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
test   %esi,%esi
jle    11a7 <benchmark+0x67>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1040 <rand_float@plt>
mulss  0xe71(%rip),%xmm0
addss  0xe6d(%rip),%xmm0
movss  %xmm0,0x0(%r13,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1180 <benchmark+0x40>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <tic@plt>
movsd  %xmm0,-0x38(%rbp)
test   %r15d,%r15d
jle    11f8 <benchmark+0xb8>
nopw   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mov    %r14d,%edi
mov    %r13,%rsi
mov    $0x1,%edx
call   1060 <c_sfill@plt>
movss  0x0(%r13),%xmm0
ucomiss %xmm0,%xmm0
jp     11ec <benchmark+0xac>
add    $0x1,%ebx
cmp    %ebx,%r15d
jne    11c0 <benchmark+0x80>
jmp    11f8 <benchmark+0xb8>
lea    0xe15(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <tic@plt>
movss  0x0(%r13),%xmm1
ucomiss %xmm1,%xmm1
jp     121e <benchmark+0xde>
subsd  -0x38(%rbp),%xmm0
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xde3(%rip),%rdi
movsd  %xmm0,-0x30(%rbp)
call   1030 <puts@plt>
movsd  -0x30(%rbp),%xmm0
jmp    120a <benchmark+0xca>

LLVM IR (-O0):
@.str = [23 x i8] c"should not return NaN\0A\00"
define double @benchmark(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca i8*
%7 = alloca i64
%8 = alloca double
%9 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%10 = load i32, i32* %4
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %6
%13 = alloca float, i64 %11
store i64 %11, i64* %7
store i32 0, i32* %9
br label %14
14: ; preds = %24, %2
%15 = load i32, i32* %9
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %27
18: ; preds = %14
%19 = call float (...) @rand_float()
%20 = call float @llvm.fmuladd.f32(float %19, float 2.000000e+02, float -1.000000e+02)
%21 = load i32, i32* %9
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds float, float* %13, i64 %22
store float %20, float* %23
br label %24
24: ; preds = %18
%25 = load i32, i32* %9
%26 = add nsw i32 %25, 1
store i32 %26, i32* %9
br label %14
27: ; preds = %14
%28 = call double (...) @tic()
store double %28, double* %8
store i32 0, i32* %9
br label %29
29: ; preds = %46, %27
%30 = load i32, i32* %9
%31 = load i32, i32* %3
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %49
33: ; preds = %29
%34 = load i32, i32* %4
%35 = load i32, i32* %9
%36 = sitofp i32 %35 to float
%37 = call i32 @c_sfill(i32 %34, float %36, float* %13, i32 1)
%38 = getelementptr inbounds float, float* %13, i64 0
%39 = load float, float* %38
%40 = getelementptr inbounds float, float* %13, i64 0
%41 = load float, float* %40
%42 = fcmp une float %39, %41
br i1 %42, label %43, label %45
43: ; preds = %33
%44 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %49
45: ; preds = %33
br label %46
46: ; preds = %45
%47 = load i32, i32* %9
%48 = add nsw i32 %47, 1
store i32 %48, i32* %9
br label %29
49: ; preds = %43, %29
%50 = call double (...) @tic()
%51 = load double, double* %8
%52 = fsub double %50, %51
store double %52, double* %5
%53 = getelementptr inbounds float, float* %13, i64 0
%54 = load float, float* %53
%55 = getelementptr inbounds float, float* %13, i64 0
%56 = load float, float* %55
%57 = fcmp une float %54, %56
br i1 %57, label %58, label %60
58: ; preds = %49
%59 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %60
60: ; preds = %58, %49
%61 = load double, double* %5
%62 = load i8*, i8** %6
ret double %61
}

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