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

/* Variables and functions */
float CLOCKS_PER_SEC;
int INT_MAX;
int clock();
int /*<<< orphan*/ printf(char *, int, float);
void time_your_program() {
  clock_t start, end, elapsed;
  start = clock();
  for (int i = 0; i < INT_MAX; i++) {
  }
  end = clock();
  elapsed = end - start;
  printf("It took me %d clicks (%f seconds).\n", elapsed,
         ((float)elapsed) / CLOCKS_PER_SEC);
}


x86 assembly (clang, -O0):
<time_your_program>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    0x2ea5(%rip),%rcx
cmp    (%rcx),%eax
jge    115e <time_your_program+0x3e>
jmp    1150 <time_your_program+0x30>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1139 <time_your_program+0x19>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
cvtsi2ssl -0xc(%rbp),%xmm0
mov    0x2e60(%rip),%rax
divss  (%rax),%xmm0
lea    0xe75(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_your_program>:
push   %rbx
xor    %eax,%eax
call   1030 <clock@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <clock@plt>
sub    %ebx,%eax
cvtsi2ss %eax,%xmm0
mov    0x2eaa(%rip),%rcx
divss  (%rcx),%xmm0
lea    0xeb7(%rip),%rdi
mov    %eax,%esi
pop    %rbx
jmp    1040 <printf@plt>

LLVM IR (-O0):
@INT_MAX = global i32 0
@.str = [36 x i8] c"It took me %d clicks (%f seconds).\0A\00"
@CLOCKS_PER_SEC = global float 0.000000e+00
define void @time_your_program() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = call i32 (...) @clock()
store i32 %5, i32* %1
store i32 0, i32* %4
br label %6
6: ; preds = %11, %0
%7 = load i32, i32* %4
%8 = load i32, i32* @INT_MAX
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %14
10: ; preds = %6
br label %11
11: ; preds = %10
%12 = load i32, i32* %4
%13 = add nsw i32 %12, 1
store i32 %13, i32* %4
br label %6
14: ; preds = %6
%15 = call i32 (...) @clock()
store i32 %15, i32* %2
%16 = load i32, i32* %2
%17 = load i32, i32* %1
%18 = sub nsw i32 %16, %17
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = load i32, i32* %3
%21 = sitofp i32 %20 to float
%22 = load float, float* @CLOCKS_PER_SEC
%23 = fdiv float %21, %22
%24 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %19, float %23)
ret void
}

LLVM IR (-O2):
@INT_MAX = global i32 0
@.str = [36 x i8] c"It took me %d clicks (%f seconds).\0A\00"
@CLOCKS_PER_SEC = global float 0.000000e+00
define void @time_your_program() {
%1 = tail call i32 (...) @clock()
%2 = tail call i32 (...) @clock()
%3 = sub nsw i32 %2, %1
%4 = sitofp i32 %3 to float
%5 = load float, float* @CLOCKS_PER_SEC
%6 = fdiv float %4, %5
%7 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %3, float %6)
ret void
}