#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 */
scalar_t__ CLOCKS_PER_SEC;
scalar_t__ clock();
double pow(double, int);
int /*<<< orphan*/ printf(char *, double);
int main() {
  int i;
  double a = 11234567890123456.0, b;
  clock_t time_1, time_2;
  time_1 = clock();
  for (i = 0; i < 1000000; i++)
    b = a * a * a * a;
  time_2 = clock();
  printf("CPU time needed to evaluate a*a*a*a:   %f microsecs\n",
         (double)(time_2 - time_1) / (double)CLOCKS_PER_SEC);
  time_1 = clock();
  for (i = 0; i < 1000000; i++)
    b = pow(a, 4.);
  time_2 = clock();
  printf("CPU time needed to evaluate pow(a, 4.): %f microsecs\n",
         (double)(time_2 - time_1) / (double)CLOCKS_PER_SEC);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xeb9(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xf4240,-0x8(%rbp)
jge    1192 <main+0x62>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115e <main+0x2e>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
sub    -0x20(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2e37(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
lea    0xe47(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xf4240,-0x8(%rbp)
jge    1207 <main+0xd7>
movsd  -0x10(%rbp),%xmm0
mov    $0x4,%edi
call   1050 <pow@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11d8 <main+0xa8>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
sub    -0x20(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2dc2(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
lea    0xe07(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <clock@plt>
sub    %rbx,%rax
cvtsi2sd %rax,%xmm0
mov    0x2e94(%rip),%r14
cvtsi2sdq (%r14),%xmm1
divsd  %xmm1,%xmm0
lea    0xea4(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%rbx
mov    $0xf4240,%ebp
nopl   0x0(%rax,%rax,1)
movsd  0xe78(%rip),%xmm0
mov    $0x4,%edi
call   1050 <pow@plt>
movsd  0xe66(%rip),%xmm0
mov    $0x4,%edi
call   1050 <pow@plt>
movsd  0xe54(%rip),%xmm0
mov    $0x4,%edi
call   1050 <pow@plt>
movsd  0xe42(%rip),%xmm0
mov    $0x4,%edi
call   1050 <pow@plt>
movsd  0xe30(%rip),%xmm0
mov    $0x4,%edi
call   1050 <pow@plt>
movsd  0xe1e(%rip),%xmm0
mov    $0x4,%edi
call   1050 <pow@plt>
movsd  0xe0c(%rip),%xmm0
mov    $0x4,%edi
call   1050 <pow@plt>
movsd  0xdfa(%rip),%xmm0
mov    $0x4,%edi
call   1050 <pow@plt>
movsd  0xde8(%rip),%xmm0
mov    $0x4,%edi
call   1050 <pow@plt>
movsd  0xdd6(%rip),%xmm0
mov    $0x4,%edi
call   1050 <pow@plt>
add    $0xfffffff6,%ebp
jne    1180 <main+0x50>
xor    %eax,%eax
call   1030 <clock@plt>
sub    %rbx,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq (%r14),%xmm1
divsd  %xmm1,%xmm0
lea    0xddb(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [53 x i8] c"CPU time needed to evaluate a*a*a*a: %f microsecs\0A\00"
@CLOCKS_PER_SEC = global i64 0
@.str.1 = [54 x i8] c"CPU time needed to evaluate pow(a, 4.): %f microsecs\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = alloca i64
%6 = alloca i64
store i32 0, i32* %1
store double 0x4343F4E3D625DD60, double* %3
%7 = call i64 (...) @clock()
store i64 %7, i64* %5
store i32 0, i32* %2
br label %8
8: ; preds = %19, %0
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 1000000
br i1 %10, label %11, label %22
11: ; preds = %8
%12 = load double, double* %3
%13 = load double, double* %3
%14 = fmul double %12, %13
%15 = load double, double* %3
%16 = fmul double %14, %15
%17 = load double, double* %3
%18 = fmul double %16, %17
store double %18, double* %4
br label %19
19: ; preds = %11
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
store i32 %21, i32* %2
br label %8
22: ; preds = %8
%23 = call i64 (...) @clock()
store i64 %23, i64* %6
%24 = load i64, i64* %6
%25 = load i64, i64* %5
%26 = sub nsw i64 %24, %25
%27 = sitofp i64 %26 to double
%28 = load i64, i64* @CLOCKS_PER_SEC
%29 = sitofp i64 %28 to double
%30 = fdiv double %27, %29
%31 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), double %30)
%32 = call i64 (...) @clock()
store i64 %32, i64* %5
store i32 0, i32* %2
br label %33
33: ; preds = %39, %22
%34 = load i32, i32* %2
%35 = icmp slt i32 %34, 1000000
br i1 %35, label %36, label %42
36: ; preds = %33
%37 = load double, double* %3
%38 = call double @pow(double %37, i32 4)
store double %38, double* %4
br label %39
39: ; preds = %36
%40 = load i32, i32* %2
%41 = add nsw i32 %40, 1
store i32 %41, i32* %2
br label %33
42: ; preds = %33
%43 = call i64 (...) @clock()
store i64 %43, i64* %6
%44 = load i64, i64* %6
%45 = load i64, i64* %5
%46 = sub nsw i64 %44, %45
%47 = sitofp i64 %46 to double
%48 = load i64, i64* @CLOCKS_PER_SEC
%49 = sitofp i64 %48 to double
%50 = fdiv double %47, %49
%51 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), double %50)
ret i32 0
}

LLVM IR (-O2):
@.str = [53 x i8] c"CPU time needed to evaluate a*a*a*a: %f microsecs\0A\00"
@CLOCKS_PER_SEC = global i64 0
@.str.1 = [54 x i8] c"CPU time needed to evaluate pow(a, 4.): %f microsecs\0A\00"
define i32 @main() {
%1 = tail call i64 (...) @clock()
%2 = tail call i64 (...) @clock()
%3 = sub nsw i64 %2, %1
%4 = sitofp i64 %3 to double
%5 = load i64, i64* @CLOCKS_PER_SEC
%6 = sitofp i64 %5 to double
%7 = fdiv double %4, %6
%8 = tail call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), double %7)
%9 = tail call i64 (...) @clock()
br label %10
10: ; preds = %10, %0
%11 = phi i32 [ 0, %0 ], [ %22, %10 ]
%12 = tail call double @pow(double 0x4343F4E3D625DD60, i32 4)
%13 = tail call double @pow(double 0x4343F4E3D625DD60, i32 4)
%14 = tail call double @pow(double 0x4343F4E3D625DD60, i32 4)
%15 = tail call double @pow(double 0x4343F4E3D625DD60, i32 4)
%16 = tail call double @pow(double 0x4343F4E3D625DD60, i32 4)
%17 = tail call double @pow(double 0x4343F4E3D625DD60, i32 4)
%18 = tail call double @pow(double 0x4343F4E3D625DD60, i32 4)
%19 = tail call double @pow(double 0x4343F4E3D625DD60, i32 4)
%20 = tail call double @pow(double 0x4343F4E3D625DD60, i32 4)
%21 = tail call double @pow(double 0x4343F4E3D625DD60, i32 4)
%22 = add nuw nsw i32 %11, 10
%23 = icmp eq i32 %22, 1000000
br i1 %23, label %24, label %10
24: ; preds = %10
%25 = tail call i64 (...) @clock()
%26 = sub nsw i64 %25, %9
%27 = sitofp i64 %26 to double
%28 = load i64, i64* @CLOCKS_PER_SEC
%29 = sitofp i64 %28 to double
%30 = fdiv double %27, %29
%31 = tail call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), double %30)
ret i32 0
}