#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*/ printf(char *, double);
int main(void) {
  long i = 10000000L;
  clock_t start, finish;
  double duration;
  printf("Time to do %ld empty loops is", i);
  start = clock();
  while (i--)
    ;
  finish = clock();
  duration = (double)(finish - start) / CLOCKS_PER_SEC;
  printf("%f seconds \n", duration);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x989680,-0x10(%rbp)
cvtsi2sdq -0x10(%rbp),%xmm0
lea    0xebc(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
je     1172 <main+0x52>
jmp    1154 <main+0x34>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
sub    -0x18(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2e57(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
lea    0xe78(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xee0(%rip),%rdi
movsd  0xed0(%rip),%xmm0
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <clock@plt>
sub    %rbx,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mov    0x2e90(%rip),%rax
divsd  (%rax),%xmm0
lea    0xec3(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Time to do %ld empty loops is\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.1 = [13 x i8] c"%f seconds \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca double
store i32 0, i32* %1
store i64 10000000, i64* %2
%6 = load i64, i64* %2
%7 = sitofp i64 %6 to double
%8 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), double %7)
%9 = call i64 (...) @clock()
store i64 %9, i64* %3
br label %10
10: ; preds = %14, %0
%11 = load i64, i64* %2
%12 = add nsw i64 %11, -1
store i64 %12, i64* %2
%13 = icmp ne i64 %11, 0
br i1 %13, label %14, label %15
14: ; preds = %10
br label %10
15: ; preds = %10
%16 = call i64 (...) @clock()
store i64 %16, i64* %4
%17 = load i64, i64* %4
%18 = load i64, i64* %3
%19 = sub nsw i64 %17, %18
%20 = sitofp i64 %19 to double
%21 = load double, double* @CLOCKS_PER_SEC
%22 = fdiv double %20, %21
store double %22, double* %5
%23 = load double, double* %5
%24 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [30 x i8] c"Time to do %ld empty loops is\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.1 = [13 x i8] c"%f seconds \0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), double 1.000000e+07)
%2 = tail call i64 (...) @clock()
%3 = tail call i64 (...) @clock()
%4 = sub nsw i64 %3, %2
%5 = sitofp i64 %4 to double
%6 = load double, double* @CLOCKS_PER_SEC
%7 = fdiv double %5, %6
%8 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %7)
ret i32 0
}