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

/* Variables and functions */
double CLOCKS_PER_SEC;
int EXIT_SUCCESS;
double clock();
int /*<<< orphan*/ printf(char *, int, double);
int main(void) {
  clock_t before;
  double after;
  before = clock();
  for (int i = 0; i < 10000000; i++)
    ;
  after = clock() - before;
  printf("for loop of \'%d\' elements used \'%f\' seconds.\n", 10000000,
         after / CLOCKS_PER_SEC);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x989680,-0x1c(%rbp)
jge    1162 <main+0x42>
jmp    1154 <main+0x34>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1142 <main+0x22>
mov    $0x0,%al
call   1030 <clock@plt>
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    0x2e69(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe76(%rip),%rdi
mov    $0x989680,%esi
call   1040 <printf@plt>
mov    0x2e3d(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1030 <clock@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <clock@plt>
subsd  (%rsp),%xmm0
mov    0x2ea8(%rip),%rax
divsd  (%rax),%xmm0
lea    0xeb5(%rip),%rdi
mov    $0x989680,%esi
call   1040 <printf@plt>
mov    0x2e7c(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [46 x i8] c"for loop of '%d' elements used '%f' seconds.\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@EXIT_SUCCESS = global i32 0
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 i32 0, i32* %4
br label %6
6: ; preds = %10, %0
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 10000000
br i1 %8, label %9, label %13
9: ; preds = %6
br label %10
10: ; preds = %9
%11 = load i32, i32* %4
%12 = add nsw i32 %11, 1
store i32 %12, i32* %4
br label %6
13: ; preds = %6
%14 = call double (...) @clock()
%15 = load double, double* %2
%16 = fsub double %14, %15
store double %16, double* %3
%17 = load double, double* %3
%18 = load double, double* @CLOCKS_PER_SEC
%19 = fdiv double %17, %18
%20 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 10000000, double %19)
%21 = load i32, i32* @EXIT_SUCCESS
ret i32 %21
}

LLVM IR (-O2):
@.str = [46 x i8] c"for loop of '%d' elements used '%f' seconds.\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call double (...) @clock()
%2 = tail call double (...) @clock()
%3 = fsub double %2, %1
%4 = load double, double* @CLOCKS_PER_SEC
%5 = fdiv double %3, %4
%6 = tail call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 10000000, double %5)
%7 = load i32, i32* @EXIT_SUCCESS
ret i32 %7
}