#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 */

/* Variables and functions */
double CLOCKS_PER_SEC;
int /*<<< orphan*/ abs(double);
double clock();
int /*<<< orphan*/ printf(char *, double);
double sqrt(int /*<<< orphan*/);
int main() {
  double tt = clock();
  double a = 1254125135;
  int cnt1 = 11000000;
  while (cnt1 > 0) {
    cnt1--;
    a = sqrt(abs(a));
  }
  tt = (double)(clock() - tt) / CLOCKS_PER_SEC;
  printf("Cost %.3f seconds!\n", tt);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <clock@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  0xe9d(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0xa7d8c0,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    119d <main+0x5d>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <abs@plt>
mov    %eax,%edi
call   1060 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    116f <main+0x2f>
mov    $0x0,%al
call   1040 <clock@plt>
subsd  -0x10(%rbp),%xmm0
mov    0x2e38(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
lea    0xe43(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xea6(%rip),%xmm0
mov    $0xff582740,%ebx
nop
call   1030 <abs@plt>
mov    %eax,%edi
call   1060 <sqrt@plt>
call   1030 <abs@plt>
mov    %eax,%edi
call   1060 <sqrt@plt>
call   1030 <abs@plt>
mov    %eax,%edi
call   1060 <sqrt@plt>
call   1030 <abs@plt>
mov    %eax,%edi
call   1060 <sqrt@plt>
call   1030 <abs@plt>
mov    %eax,%edi
call   1060 <sqrt@plt>
call   1030 <abs@plt>
mov    %eax,%edi
call   1060 <sqrt@plt>
call   1030 <abs@plt>
mov    %eax,%edi
call   1060 <sqrt@plt>
call   1030 <abs@plt>
mov    %eax,%edi
call   1060 <sqrt@plt>
add    $0x8,%ebx
jne    1160 <main+0x20>
xor    %eax,%eax
call   1040 <clock@plt>
subsd  0x8(%rsp),%xmm0
mov    0x2e0f(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe24(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str = [20 x i8] c"Cost %.3f seconds!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca i32
store i32 0, i32* %1
%5 = call double (...) @clock()
store double %5, double* %2
store double 0x41D2B01B93C00000, double* %3
store i32 11000000, i32* %4
br label %6
6: ; preds = %9, %0
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %6
%10 = load i32, i32* %4
%11 = add nsw i32 %10, -1
store i32 %11, i32* %4
%12 = load double, double* %3
%13 = call i32 @abs(double %12)
%14 = call double @sqrt(i32 %13)
store double %14, double* %3
br label %6
15: ; preds = %6
%16 = call double (...) @clock()
%17 = load double, double* %2
%18 = fsub double %16, %17
%19 = load double, double* @CLOCKS_PER_SEC
%20 = fdiv double %18, %19
store double %20, double* %2
%21 = load double, double* %2
%22 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), double %21)
ret i32 0
}

LLVM IR (-O2):
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str = [20 x i8] c"Cost %.3f seconds!\0A\00"
define i32 @main() {
%1 = tail call double (...) @clock()
br label %2
2: ; preds = %2, %0
%3 = phi i32 [ 11000000, %0 ], [ %19, %2 ]
%4 = phi double [ 0x41D2B01B93C00000, %0 ], [ %21, %2 ]
%5 = tail call i32 @abs(double %4)
%6 = tail call double @sqrt(i32 %5)
%7 = tail call i32 @abs(double %6)
%8 = tail call double @sqrt(i32 %7)
%9 = tail call i32 @abs(double %8)
%10 = tail call double @sqrt(i32 %9)
%11 = tail call i32 @abs(double %10)
%12 = tail call double @sqrt(i32 %11)
%13 = tail call i32 @abs(double %12)
%14 = tail call double @sqrt(i32 %13)
%15 = tail call i32 @abs(double %14)
%16 = tail call double @sqrt(i32 %15)
%17 = tail call i32 @abs(double %16)
%18 = tail call double @sqrt(i32 %17)
%19 = add nsw i32 %3, -8
%20 = tail call i32 @abs(double %18)
%21 = tail call double @sqrt(i32 %20)
%22 = icmp eq i32 %3, 8
br i1 %22, label %23, label %2
23: ; preds = %2
%24 = tail call double (...) @clock()
%25 = fsub double %24, %1
%26 = load double, double* @CLOCKS_PER_SEC
%27 = fdiv double %25, %26
%28 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), double %27)
ret i32 0
}