#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__ clock_t;

/* Variables and functions */
float CLOCKS_PER_SEC;
int /*<<< orphan*/ Ramp(double *, int, double, double);
scalar_t__ clock();
int /*<<< orphan*/ printf(char *, double);
void main() {
  double array[10000];
  int i;
  clock_t t1, t2;
  float seconds;
  t1 = clock();
  for (i = 0; i < 10000; i++)
    Ramp(array, 10000, 0.0, 1.0);
  t2 = clock();
  seconds = (float)(t2 - t1) / CLOCKS_PER_SEC;
  printf("c version (seconds): %f\n", seconds);
  printf("array[500]: %f\n", array[500]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x138a0,%rsp
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x13890(%rbp)
movl   $0x0,-0x13884(%rbp)
cmpl   $0x2710,-0x13884(%rbp)
jge    1193 <main+0x63>
lea    -0x13880(%rbp),%rdi
mov    $0x2710,%esi
xorps  %xmm0,%xmm0
movsd  0xe86(%rip),%xmm1
call   1050 <Ramp@plt>
mov    -0x13884(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x13884(%rbp)
jmp    1153 <main+0x23>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x13898(%rbp)
mov    -0x13898(%rbp),%rax
sub    -0x13890(%rbp),%rax
cvtsi2ss %rax,%xmm0
mov    0x2e2d(%rip),%rax
divss  (%rax),%xmm0
movss  %xmm0,-0x1389c(%rbp)
ff
movss  -0x1389c(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xe2e(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x128e0(%rbp),%xmm0
ff
lea    0xe33(%rip),%rdi
call   1040 <printf@plt>
add    $0x138a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x13880,%rsp
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%r14
mov    $0x2710,%ebp
mov    %rsp,%rbx
nopl   (%rax)
xorps  %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x2710,%esi
movsd  0xe9d(%rip),%xmm1
call   1050 <Ramp@plt>
add    $0xffffffff,%ebp
jne    1150 <main+0x20>
xor    %eax,%eax
call   1030 <clock@plt>
sub    %r14,%rax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mov    0x2e62(%rip),%rax
divss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe73(%rip),%rdi
call   1040 <printf@plt>
movsd  0xfa0(%rsp),%xmm0
lea    0xe77(%rip),%rdi
call   1040 <printf@plt>
add    $0x13880,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@CLOCKS_PER_SEC = global float 0.000000e+00
@.str = [25 x i8] c"c version (seconds): %f\0A\00"
@.str.1 = [16 x i8] c"array[500]: %f\0A\00"
define void @main() {
%1 = alloca [10000 x double]
%2 = alloca i32
%3 = alloca i64
%4 = alloca i64
%5 = alloca float
%6 = call i64 (...) @clock()
store i64 %6, i64* %3
store i32 0, i32* %2
br label %7
7: ; preds = %13, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 10000
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = getelementptr inbounds [10000 x double], [10000 x double]* %1, i64 0, i64 0
%12 = call i32 @Ramp(double* %11, i32 10000, double 0.000000e+00, double 1.000000e+00)
br label %13
13: ; preds = %10
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
br label %7
16: ; preds = %7
%17 = call i64 (...) @clock()
store i64 %17, i64* %4
%18 = load i64, i64* %4
%19 = load i64, i64* %3
%20 = sub nsw i64 %18, %19
%21 = sitofp i64 %20 to float
%22 = load float, float* @CLOCKS_PER_SEC
%23 = fdiv float %21, %22
store float %23, float* %5
%24 = load float, float* %5
%25 = fpext float %24 to double
%26 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %25)
%27 = getelementptr inbounds [10000 x double], [10000 x double]* %1, i64 0, i64 500
%28 = load double, double* %27
%29 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), double %28)
ret void
}

LLVM IR (-O2):
@CLOCKS_PER_SEC = global float 0.000000e+00
@.str = [25 x i8] c"c version (seconds): %f\0A\00"
@.str.1 = [16 x i8] c"array[500]: %f\0A\00"
define void @main() {
%1 = alloca [10000 x double]
%2 = bitcast [10000 x double]* %1 to i8*
%3 = tail call i64 (...) @clock()
%4 = getelementptr inbounds [10000 x double], [10000 x double]* %1, i64 0, i64 0
br label %5
5: ; preds = %0, %5
%6 = phi i32 [ 0, %0 ], [ %8, %5 ]
%7 = call i32 @Ramp(double* %4, i32 10000, double 0.000000e+00, double 1.000000e+00)
%8 = add nuw nsw i32 %6, 1
%9 = icmp eq i32 %8, 10000
br i1 %9, label %10, label %5
10: ; preds = %5
%11 = call i64 (...) @clock()
%12 = sub nsw i64 %11, %3
%13 = sitofp i64 %12 to float
%14 = load float, float* @CLOCKS_PER_SEC
%15 = fdiv float %13, %14
%16 = fpext float %15 to double
%17 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %16)
%18 = getelementptr inbounds [10000 x double], [10000 x double]* %1, i64 0, i64 500
%19 = load double, double* %18
%20 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), double %19)
ret void
}