#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 *);
double rand_uniform(double, double);
int /*<<< orphan*/ stdlib_strided_dmskcbrt(int, double *, int, scalar_t__ *,
                                           int, double *, int);
double tic();
double benchmark(int iterations, int len) {
  double elapsed;
  uint8_t m[len];
  double x[len];
  double y[len];
  double t;
  int i;
  for (i = 0; i < len; i++) {
    x[i] = rand_uniform(-100.0, 100.0);
    y[i] = 0.0;
    m[i] = 0;
  }
  t = tic();
  for (i = 0; i < iterations; i++) {
    stdlib_strided_dmskcbrt(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,8),%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,8),%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>
movsd  0xe30(%rip),%xmm0
movsd  0xe30(%rip),%xmm1
call   1060 <rand_uniform@plt>
mov    -0x50(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0x58(%rbp),%rax
movslq -0x3c(%rbp),%rsi
movsd  %xmm0,(%rdx,%rsi,8)
movslq -0x3c(%rbp),%rdx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rcx,%rdx,8)
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    12a4 <benchmark+0x164>
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   1050 <stdlib_strided_dmskcbrt@plt>
add    $0x10,%rsp
mov    -0x48(%rbp),%rax
movsd  (%rax),%xmm0
ucomisd (%rax),%xmm0
jne    1280 <benchmark+0x140>
jp     1280 <benchmark+0x140>
jmp    1291 <benchmark+0x151>
lea    0xd89(%rip),%rdi
call   1030 <printf@plt>
jmp    12a4 <benchmark+0x164>
jmp    1296 <benchmark+0x156>
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)
movsd  (%rax),%xmm0
ucomisd (%rax),%xmm0
jne    12d2 <benchmark+0x192>
jp     12d2 <benchmark+0x192>
jmp    12de <benchmark+0x19e>
lea    0xd37(%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,%r12
sub    %rax,%r12
mov    %r12,%rsp
mov    %rsp,%r15
sub    %rax,%r15
mov    %r15,%rsp
mov    %esi,-0x30(%rbp)
test   %esi,%esi
jle    11dc <benchmark+0x9c>
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
movsd  0xe68(%rip),%xmm0
movsd  0xe68(%rip),%xmm1
mov    %r13,%rbx
mov    %r15,%r13
mov    %r12,%r15
mov    %rcx,%r12
call   1060 <rand_uniform@plt>
mov    %r12,%rcx
mov    %r15,%r12
mov    %r13,%r15
mov    %rbx,%r13
movsd  %xmm0,(%r12,%r14,8)
movq   $0x0,(%r15,%r14,8)
movq   $0x0,(%rbx,%r14,8)
add    $0x1,%r14
cmp    %r14,%rcx
jne    1190 <benchmark+0x50>
xor    %eax,%eax
call   1040 <tic@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x34(%rbp),%ebx
test   %ebx,%ebx
mov    -0x30(%rbp),%r14d
jle    1244 <benchmark+0x104>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
sub    $0x8,%rsp
mov    %r14d,%edi
mov    %r12,%rsi
mov    $0x1,%edx
mov    %r13,%rcx
mov    $0x1,%r8d
mov    %r15,%r9
push   $0x1
call   1050 <stdlib_strided_dmskcbrt@plt>
add    $0x10,%rsp
movsd  (%r15),%xmm0
ucomisd %xmm0,%xmm0
jp     1238 <benchmark+0xf8>
add    $0xffffffff,%ebx
jne    1200 <benchmark+0xc0>
jmp    1244 <benchmark+0x104>
lea    0xdd1(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <tic@plt>
movsd  (%r15),%xmm1
ucomisd %xmm1,%xmm1
jp     126a <benchmark+0x12a>
subsd  -0x40(%rbp),%xmm0
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd9f(%rip),%rdi
movsd  %xmm0,-0x30(%rbp)
call   1030 <puts@plt>
movsd  -0x30(%rbp),%xmm0
jmp    1256 <benchmark+0x116>

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 double, i64 %17
store i64 %17, i64* %8
%19 = load i32, i32* %4
%20 = zext i32 %19 to i64
%21 = alloca double, 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 double @rand_uniform(double -1.000000e+02, double 1.000000e+02)
%28 = load i32, i32* %11
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %18, i64 %29
store double %27, double* %30
%31 = load i32, i32* %11
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %21, i64 %32
store double 0.000000e+00, double* %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_dmskcbrt(i32 %47, double* %18, i32 1, i64* %15, i32 1, double* %21, i32 1)
%49 = getelementptr inbounds double, double* %21, i64 0
%50 = load double, double* %49
%51 = getelementptr inbounds double, double* %21, i64 0
%52 = load double, double* %51
%53 = fcmp une double %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 double, double* %21, i64 0
%65 = load double, double* %64
%66 = getelementptr inbounds double, double* %21, i64 0
%67 = load double, double* %66
%68 = fcmp une double %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 double, i64 %3
%6 = alloca double, 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 double @rand_uniform(double -1.000000e+02, double 1.000000e+02)
%11 = getelementptr inbounds double, double* %5, i64 %9
store double %10, double* %11
%12 = getelementptr inbounds double, double* %6, i64 %9
store double 0.000000e+00, double* %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_dmskcbrt(i32 %1, double* %5, i32 1, i64* %4, i32 1, double* %6, i32 1)
%24 = load double, double* %6
%25 = fcmp uno double %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 double, double* %6
%32 = fcmp uno double %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
}