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


x86 assembly (clang, -O0):
<benchmark>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f2 <benchmark+0xb2>
mov    $0x0,%al
call   1030 <rand_float@plt>
mov    -0x48(%rbp),%rcx
mov    -0x40(%rbp),%rax
movss  0xe45(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe3d(%rip),%xmm1
addss  %xmm1,%xmm0
movslq -0x34(%rbp),%rdx
movss  %xmm0,(%rcx,%rdx,4)
movslq -0x34(%rbp),%rcx
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    119c <benchmark+0x5c>
mov    $0x0,%al
call   1050 <tic@plt>
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    127a <benchmark+0x13a>
mov    -0x40(%rbp),%rcx
mov    -0x48(%rbp),%rsi
movss  0xddf(%rip),%xmm0
addss  (%rsi),%xmm0
movss  %xmm0,(%rsi)
mov    -0x8(%rbp),%edi
mov    $0x1,%r8d
mov    %r8d,%edx
call   1060 <stdlib_strided_scumin@plt>
mov    -0x40(%rbp),%rax
movss  (%rax),%xmm0
ucomiss (%rax),%xmm0
jne    1256 <benchmark+0x116>
jp     1256 <benchmark+0x116>
jmp    1267 <benchmark+0x127>
lea    0xdaf(%rip),%rdi
call   1040 <printf@plt>
jmp    127a <benchmark+0x13a>
jmp    126c <benchmark+0x12c>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1205 <benchmark+0xc5>
mov    $0x0,%al
call   1050 <tic@plt>
mov    -0x40(%rbp),%rax
subsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
ucomiss (%rax,%rcx,4),%xmm0
jne    12bb <benchmark+0x17b>
jp     12bb <benchmark+0x17b>
jmp    12c7 <benchmark+0x187>
lea    0xd4a(%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    %edi,%ebx
mov    %esi,%r13d
mov    %rsp,%r12
lea    0xf(,%r13,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    %rsp,%r15
sub    %rax,%r15
mov    %r15,%rsp
mov    %esi,-0x30(%rbp)
test   %esi,%esi
jle    11ae <benchmark+0x6e>
xor    %r14d,%r14d
xchg   %ax,%ax
xor    %eax,%eax
call   1040 <rand_float@plt>
mulss  0xe71(%rip),%xmm0
addss  0xe6d(%rip),%xmm0
movss  %xmm0,(%r12,%r14,4)
movl   $0x0,(%r15,%r14,4)
add    $0x1,%r14
cmp    %r14,%r13
jne    1180 <benchmark+0x40>
xor    %eax,%eax
call   1050 <tic@plt>
movsd  %xmm0,-0x38(%rbp)
test   %ebx,%ebx
mov    -0x30(%rbp),%r14d
jle    121a <benchmark+0xda>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movss  (%r12),%xmm0
addss  0xe2a(%rip),%xmm0
movss  %xmm0,(%r12)
mov    %r14d,%edi
mov    %r12,%rsi
mov    $0x1,%edx
mov    %r15,%rcx
mov    $0x1,%r8d
call   1060 <stdlib_strided_scumin@plt>
movss  (%r15),%xmm0
ucomiss %xmm0,%xmm0
jp     120e <benchmark+0xce>
add    $0xffffffff,%ebx
jne    11d0 <benchmark+0x90>
jmp    121a <benchmark+0xda>
lea    0xdf7(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <tic@plt>
movslq %r14d,%rax
movss  -0x4(%r15,%rax,4),%xmm1
ucomiss %xmm1,%xmm1
jp     1244 <benchmark+0x104>
subsd  -0x38(%rbp),%xmm0
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdc1(%rip),%rdi
movsd  %xmm0,-0x30(%rbp)
call   1030 <puts@plt>
movsd  -0x30(%rbp),%xmm0
jmp    1230 <benchmark+0xf0>

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 i64
%9 = alloca double
%10 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%11 = load i32, i32* %4
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %6
%14 = alloca float, i64 %12
store i64 %12, i64* %7
%15 = load i32, i32* %4
%16 = zext i32 %15 to i64
%17 = alloca float, i64 %16
store i64 %16, i64* %8
store i32 0, i32* %10
br label %18
18: ; preds = %31, %2
%19 = load i32, i32* %10
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %34
22: ; preds = %18
%23 = call float (...) @rand_float()
%24 = call float @llvm.fmuladd.f32(float %23, float 2.000000e+04, float -1.000000e+04)
%25 = load i32, i32* %10
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds float, float* %14, i64 %26
store float %24, float* %27
%28 = load i32, i32* %10
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds float, float* %17, i64 %29
store float 0.000000e+00, float* %30
br label %31
31: ; preds = %22
%32 = load i32, i32* %10
%33 = add nsw i32 %32, 1
store i32 %33, i32* %10
br label %18
34: ; preds = %18
%35 = call double (...) @tic()
store double %35, double* %9
store i32 0, i32* %10
br label %36
36: ; preds = %54, %34
%37 = load i32, i32* %10
%38 = load i32, i32* %3
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %57
40: ; preds = %36
%41 = getelementptr inbounds float, float* %14, i64 0
%42 = load float, float* %41
%43 = fadd float %42, 1.000000e+00
store float %43, float* %41
%44 = load i32, i32* %4
%45 = call i32 @stdlib_strided_scumin(i32 %44, float* %14, i32 1, float* %17, i32 1)
%46 = getelementptr inbounds float, float* %17, i64 0
%47 = load float, float* %46
%48 = getelementptr inbounds float, float* %17, i64 0
%49 = load float, float* %48
%50 = fcmp une float %47, %49
br i1 %50, label %51, label %53
51: ; preds = %40
%52 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %57
53: ; preds = %40
br label %54
54: ; preds = %53
%55 = load i32, i32* %10
%56 = add nsw i32 %55, 1
store i32 %56, i32* %10
br label %36
57: ; preds = %51, %36
%58 = call double (...) @tic()
%59 = load double, double* %9
%60 = fsub double %58, %59
store double %60, double* %5
%61 = load i32, i32* %4
%62 = sub nsw i32 %61, 1
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds float, float* %17, i64 %63
%65 = load float, float* %64
%66 = load i32, i32* %4
%67 = sub nsw i32 %66, 1
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds float, float* %17, i64 %68
%70 = load float, float* %69
%71 = fcmp une float %65, %70
br i1 %71, label %72, label %74
72: ; preds = %57
%73 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %74
74: ; preds = %72, %57
%75 = load double, double* %5
%76 = load i8*, i8** %6
ret double %75
}

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 = alloca float, i64 %3
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %15
7: ; preds = %2, %7
%8 = phi i64 [ %13, %7 ], [ 0, %2 ]
%9 = tail call float (...) @rand_float()
%10 = tail call float @llvm.fmuladd.f32(float %9, float 2.000000e+04, float -1.000000e+04)
%11 = getelementptr inbounds float, float* %4, i64 %8
store float %10, float* %11
%12 = getelementptr inbounds float, float* %5, i64 %8
store float 0.000000e+00, float* %12
%13 = add nuw nsw i64 %8, 1
%14 = icmp eq i64 %13, %3
br i1 %14, label %15, label %7
15: ; preds = %7, %2
%16 = tail call double (...) @tic()
%17 = icmp sgt i32 %0, 0
br i1 %17, label %20, label %30
18: ; preds = %20
%19 = icmp eq i32 %27, %0
br i1 %19, label %30, label %20
20: ; preds = %15, %18
%21 = phi i32 [ %27, %18 ], [ 0, %15 ]
%22 = load float, float* %4
%23 = fadd float %22, 1.000000e+00
store float %23, float* %4
%24 = call i32 @stdlib_strided_scumin(i32 %1, float* %4, i32 1, float* %5, i32 1)
%25 = load float, float* %5
%26 = fcmp uno float %25, 0.000000e+00
%27 = add nuw nsw i32 %21, 1
br i1 %26, label %28, label %18
28: ; preds = %20
%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 = %18, %15, %28
%31 = call double (...) @tic()
%32 = add nsw i32 %1, -1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds float, float* %5, i64 %33
%35 = load float, float* %34
%36 = fcmp uno float %35, 0.000000e+00
br i1 %36, label %37, label %39
37: ; preds = %30
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.1, i64 0, i64 0))
br label %39
39: ; preds = %37, %30
%40 = fsub double %31, %16
ret double %40
}