#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 */
double CLOCKS_PER_SEC;
scalar_t__ clock();
int /*<<< orphan*/ era_sinh(double);
int /*<<< orphan*/ printf(char *, double, ...);
int /*<<< orphan*/ sinh(double);
void testSpeedInRange(double from, double to, double step) {
  double oldFrom = from;
  long long counter = 0;
  while (from <= to) {
    from = from + step;
    counter = counter + 1;
  }
  from = oldFrom;
  clock_t start_era = clock();
  while (from <= to) {
    era_sinh(from);
    from = from + step;
  }
  clock_t stop_era = clock();
  from = oldFrom;
  clock_t start_c = clock();
  while (from <= to) {
    sinh(from);
    from = from + step;
  }
  clock_t stop_c = clock();
  double ourTotalTime = (double)(stop_era - start_era) / CLOCKS_PER_SEC * 1000;
  double cTotalTime = (double)(stop_c - start_c) / CLOCKS_PER_SEC * 1000;
  printf("Our function took %f ms, the C function took %f ms\n", ourTotalTime,
         cTotalTime);
  printf("That is about %f ms per call for our function.\n",
         ourTotalTime / (double)counter);
  printf("And about %f ms per call for the C function.\n",
         cTotalTime / (double)counter);
}


x86 assembly (clang, -O0):
<testSpeedInRange>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     119d <testSpeedInRange+0x5d>
movsd  -0x8(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1169 <testSpeedInRange+0x29>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     11e4 <testSpeedInRange+0xa4>
movsd  -0x8(%rbp),%xmm0
call   1060 <era_sinh@plt>
movsd  -0x8(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11b2 <testSpeedInRange+0x72>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1236 <testSpeedInRange+0xf6>
movsd  -0x8(%rbp),%xmm0
call   1030 <sinh@plt>
movsd  -0x8(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1204 <testSpeedInRange+0xc4>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x48(%rbp)
mov    -0x38(%rbp),%rax
sub    -0x30(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2d93(%rip),%rax
divsd  (%rax),%xmm0
movsd  0xd9f(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x48(%rbp),%rax
sub    -0x40(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2d6a(%rip),%rax
divsd  (%rax),%xmm0
movsd  0xd76(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
lea    0xd64(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  -0x50(%rbp),%xmm0
cvtsi2sdq -0x28(%rbp),%xmm1
divsd  %xmm1,%xmm0
lea    0xd7b(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  -0x58(%rbp),%xmm0
cvtsi2sdq -0x28(%rbp),%xmm1
divsd  %xmm1,%xmm0
lea    0xd8e(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testSpeedInRange>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
ucomisd %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
movsd  %xmm2,0x28(%rsp)
jae    1177 <testSpeedInRange+0x37>
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%r14
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x18(%rsp)
jmp    11e9 <testSpeedInRange+0xa9>
xor    %ebx,%ebx
nopl   0x0(%rax)
addsd  %xmm2,%xmm0
add    $0x1,%rbx
ucomisd %xmm0,%xmm1
jae    1180 <testSpeedInRange+0x40>
xor    %eax,%eax
call   1040 <clock@plt>
movsd  0x8(%rsp),%xmm1
mov    %rax,%r14
movsd  0x10(%rsp),%xmm2
ucomisd %xmm2,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %rbx,%xmm0
movsd  %xmm0,0x18(%rsp)
jb     11e9 <testSpeedInRange+0xa9>
nopl   0x0(%rax,%rax,1)
movsd  %xmm2,0x20(%rsp)
movsd  0x20(%rsp),%xmm0
call   1060 <era_sinh@plt>
movsd  0x20(%rsp),%xmm2
addsd  0x28(%rsp),%xmm2
movsd  0x8(%rsp),%xmm0
ucomisd %xmm2,%xmm0
jae    11c0 <testSpeedInRange+0x80>
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%r15
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
ucomisd %xmm1,%xmm0
jb     123b <testSpeedInRange+0xfb>
nop
movsd  %xmm1,0x10(%rsp)
movapd %xmm1,%xmm0
call   1030 <sinh@plt>
movsd  0x28(%rsp),%xmm2
movsd  0x10(%rsp),%xmm1
addsd  %xmm2,%xmm1
movsd  0x8(%rsp),%xmm0
ucomisd %xmm1,%xmm0
jae    1210 <testSpeedInRange+0xd0>
xor    %eax,%eax
call   1040 <clock@plt>
sub    %r14,%rbx
xorps  %xmm2,%xmm2
cvtsi2sd %rbx,%xmm2
mov    0x2d94(%rip),%rcx
movsd  (%rcx),%xmm0
divsd  %xmm0,%xmm2
movsd  0xd9c(%rip),%xmm3
mulsd  %xmm3,%xmm2
movsd  %xmm2,0x8(%rsp)
sub    %r15,%rax
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
divsd  %xmm0,%xmm1
mulsd  %xmm3,%xmm1
movsd  %xmm1,0x10(%rsp)
lea    0xd7a(%rip),%rdi
movapd %xmm2,%xmm0
mov    $0x2,%al
call   1050 <printf@plt>
movsd  0x8(%rsp),%xmm0
divsd  0x18(%rsp),%xmm0
lea    0xd90(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x10(%rsp),%xmm0
divsd  0x18(%rsp),%xmm0
lea    0xda6(%rip),%rdi
mov    $0x1,%al
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <printf@plt>

LLVM IR (-O0):
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str = [52 x i8] c"Our function took %f ms, the C function took %f ms\0A\00"
@.str.1 = [48 x i8] c"That is about %f ms per call for our function.\0A\00"
@.str.2 = [46 x i8] c"And about %f ms per call for the C function.\0A\00"
define void @testSpeedInRange(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca double
%14 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%15 = load double, double* %4
store double %15, double* %7
store i64 0, i64* %8
br label %16
16: ; preds = %20, %3
%17 = load double, double* %4
%18 = load double, double* %5
%19 = fcmp ole double %17, %18
br i1 %19, label %20, label %26
20: ; preds = %16
%21 = load double, double* %4
%22 = load double, double* %6
%23 = fadd double %21, %22
store double %23, double* %4
%24 = load i64, i64* %8
%25 = add nsw i64 %24, 1
store i64 %25, i64* %8
br label %16
26: ; preds = %16
%27 = load double, double* %7
store double %27, double* %4
%28 = call i64 (...) @clock()
store i64 %28, i64* %9
br label %29
29: ; preds = %33, %26
%30 = load double, double* %4
%31 = load double, double* %5
%32 = fcmp ole double %30, %31
br i1 %32, label %33, label %39
33: ; preds = %29
%34 = load double, double* %4
%35 = call i32 @era_sinh(double %34)
%36 = load double, double* %4
%37 = load double, double* %6
%38 = fadd double %36, %37
store double %38, double* %4
br label %29
39: ; preds = %29
%40 = call i64 (...) @clock()
store i64 %40, i64* %10
%41 = load double, double* %7
store double %41, double* %4
%42 = call i64 (...) @clock()
store i64 %42, i64* %11
br label %43
43: ; preds = %47, %39
%44 = load double, double* %4
%45 = load double, double* %5
%46 = fcmp ole double %44, %45
br i1 %46, label %47, label %53
47: ; preds = %43
%48 = load double, double* %4
%49 = call i32 @sinh(double %48)
%50 = load double, double* %4
%51 = load double, double* %6
%52 = fadd double %50, %51
store double %52, double* %4
br label %43
53: ; preds = %43
%54 = call i64 (...) @clock()
store i64 %54, i64* %12
%55 = load i64, i64* %10
%56 = load i64, i64* %9
%57 = sub nsw i64 %55, %56
%58 = sitofp i64 %57 to double
%59 = load double, double* @CLOCKS_PER_SEC
%60 = fdiv double %58, %59
%61 = fmul double %60, 1.000000e+03
store double %61, double* %13
%62 = load i64, i64* %12
%63 = load i64, i64* %11
%64 = sub nsw i64 %62, %63
%65 = sitofp i64 %64 to double
%66 = load double, double* @CLOCKS_PER_SEC
%67 = fdiv double %65, %66
%68 = fmul double %67, 1.000000e+03
store double %68, double* %14
%69 = load double, double* %13
%70 = load double, double* %14
%71 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), double %69, double %70)
%72 = load double, double* %13
%73 = load i64, i64* %8
%74 = sitofp i64 %73 to double
%75 = fdiv double %72, %74
%76 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), double %75)
%77 = load double, double* %14
%78 = load i64, i64* %8
%79 = sitofp i64 %78 to double
%80 = fdiv double %77, %79
%81 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), double %80)
ret void
}

LLVM IR (-O2):
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str = [52 x i8] c"Our function took %f ms, the C function took %f ms\0A\00"
@.str.1 = [48 x i8] c"That is about %f ms per call for our function.\0A\00"
@.str.2 = [46 x i8] c"And about %f ms per call for the C function.\0A\00"
define void @testSpeedInRange(double %0, double %1, double %2) {
%4 = fcmp ugt double %0, %1
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i64 (...) @clock()
br label %21
7: ; preds = %3, %7
%8 = phi double [ %10, %7 ], [ %0, %3 ]
%9 = phi i64 [ %11, %7 ], [ 0, %3 ]
%10 = fadd double %8, %2
%11 = add nuw nsw i64 %9, 1
%12 = fcmp ugt double %10, %1
br i1 %12, label %13, label %7
13: ; preds = %7
%14 = sitofp i64 %11 to double
%15 = tail call i64 (...) @clock()
br i1 %4, label %21, label %16
16: ; preds = %13, %16
%17 = phi double [ %19, %16 ], [ %0, %13 ]
%18 = tail call i32 @era_sinh(double %17)
%19 = fadd double %17, %2
%20 = fcmp ugt double %19, %1
br i1 %20, label %21, label %16
21: ; preds = %16, %5, %13
%22 = phi i64 [ %6, %5 ], [ %15, %13 ], [ %15, %16 ]
%23 = phi double [ 0.000000e+00, %5 ], [ %14, %13 ], [ %14, %16 ]
%24 = tail call i64 (...) @clock()
%25 = tail call i64 (...) @clock()
br i1 %4, label %31, label %26
26: ; preds = %21, %26
%27 = phi double [ %29, %26 ], [ %0, %21 ]
%28 = tail call i32 @sinh(double %27)
%29 = fadd double %27, %2
%30 = fcmp ugt double %29, %1
br i1 %30, label %31, label %26
31: ; preds = %26, %21
%32 = tail call i64 (...) @clock()
%33 = sub nsw i64 %24, %22
%34 = sitofp i64 %33 to double
%35 = load double, double* @CLOCKS_PER_SEC
%36 = fdiv double %34, %35
%37 = fmul double %36, 1.000000e+03
%38 = sub nsw i64 %32, %25
%39 = sitofp i64 %38 to double
%40 = fdiv double %39, %35
%41 = fmul double %40, 1.000000e+03
%42 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), double %37, double %41)
%43 = fdiv double %37, %23
%44 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), double %43)
%45 = fdiv double %41, %23
%46 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), double %45)
ret void
}