#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 scalar_t__ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
float rand_uniformf(float, float);
int /*<<< orphan*/ stdlib_strided_smskramp(int, float *, int, scalar_t__ *, int,
                                           float *, int);
double tic();
double benchmark(int iterations, int len) {
  double elapsed;
  uint8_t m[len];
  float x[len];
  float y[len];
  double t;
  int i;
  for (i = 0; i < len; i++) {
    x[i] = rand_uniformf(-10.0f, 10.0f);
    y[i] = 0.0f;
    m[i] = 0;
  }
  t = tic();
  for (i = 0; i < iterations; i++) {
    stdlib_strided_smskramp(len, x, 1, m, 1, y, 1);
    if (y[0] != y[0]) {
      printf("should not return NaN\n");
      break;
    }
  }
  elapsed = tic() - t;
  if (y[0] != y[0]) {
    printf("should not return NaN\n");
  }
  return elapsed;
}


x86 assembly (clang, -O0):
<benchmark>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x58(%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,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1218 <benchmark+0xd8>
movss  0xe30(%rip),%xmm0
movss  0xe2c(%rip),%xmm1
call   1050 <rand_uniformf@plt>
mov    -0x50(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0x58(%rbp),%rax
movslq -0x3c(%rbp),%rsi
movss  %xmm0,(%rdx,%rsi,4)
movslq -0x3c(%rbp),%rdx
xorps  %xmm0,%xmm0
movss  %xmm0,(%rcx,%rdx,4)
movslq -0x3c(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11bc <benchmark+0x7c>
mov    $0x0,%al
call   1040 <tic@plt>
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12a3 <benchmark+0x163>
mov    -0x48(%rbp),%r9
mov    -0x58(%rbp),%rcx
mov    -0x50(%rbp),%rsi
mov    -0x8(%rbp),%edi
mov    $0x1,%r8d
sub    $0x10,%rsp
mov    %r8d,%edx
movl   $0x1,(%rsp)
call   1060 <stdlib_strided_smskramp@plt>
add    $0x10,%rsp
mov    -0x48(%rbp),%rax
movss  (%rax),%xmm0
ucomiss (%rax),%xmm0
jne    127f <benchmark+0x13f>
jp     127f <benchmark+0x13f>
jmp    1290 <benchmark+0x150>
lea    0xd82(%rip),%rdi
call   1030 <printf@plt>
jmp    12a3 <benchmark+0x163>
jmp    1295 <benchmark+0x155>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    122b <benchmark+0xeb>
mov    $0x0,%al
call   1040 <tic@plt>
mov    -0x48(%rbp),%rax
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movss  (%rax),%xmm0
ucomiss (%rax),%xmm0
jne    12d0 <benchmark+0x190>
jp     12d0 <benchmark+0x190>
jmp    12dc <benchmark+0x19c>
lea    0xd31(%rip),%rdi
call   1030 <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,-0x34(%rbp)
mov    %esi,%ecx
mov    %rsp,%r13
lea    0xf(,%rcx,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    %rsp,%r15
lea    0xf(,%rcx,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    %rsp,%r12
sub    %rax,%r12
mov    %r12,%rsp
mov    %esi,-0x30(%rbp)
test   %esi,%esi
jle    11ec <benchmark+0xac>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movss  0xe58(%rip),%xmm0
movss  0xe54(%rip),%xmm1
mov    %r13,%rbx
mov    %r12,%r13
mov    %r15,%r12
mov    %rcx,%r15
call   1050 <rand_uniformf@plt>
mov    %r15,%rcx
mov    %r12,%r15
mov    %r13,%r12
mov    %rbx,%r13
movss  %xmm0,(%r15,%r14,4)
movl   $0x0,(%r12,%r14,4)
movq   $0x0,(%rbx,%r14,8)
add    $0x1,%r14
cmp    %r14,%rcx
jne    11a0 <benchmark+0x60>
xor    %eax,%eax
call   1040 <tic@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x34(%rbp),%ebx
test   %ebx,%ebx
mov    -0x30(%rbp),%r14d
jle    1254 <benchmark+0x114>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
sub    $0x8,%rsp
mov    %r14d,%edi
mov    %r15,%rsi
mov    $0x1,%edx
mov    %r13,%rcx
mov    $0x1,%r8d
mov    %r12,%r9
push   $0x1
call   1060 <stdlib_strided_smskramp@plt>
add    $0x10,%rsp
movss  (%r12),%xmm0
ucomiss %xmm0,%xmm0
jp     1248 <benchmark+0x108>
add    $0xffffffff,%ebx
jne    1210 <benchmark+0xd0>
jmp    1254 <benchmark+0x114>
lea    0xdb9(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <tic@plt>
movss  (%r12),%xmm1
ucomiss %xmm1,%xmm1
jp     127a <benchmark+0x13a>
subsd  -0x40(%rbp),%xmm0
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd87(%rip),%rdi
movsd  %xmm0,-0x30(%rbp)
call   1030 <puts@plt>
movsd  -0x30(%rbp),%xmm0
jmp    1266 <benchmark+0x126>

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

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