#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;
double clock();
int /*<<< orphan*/ printf(char *, ...);
int main() {
  clock_t start_t, end_t, total_t;
  int i;
  start_t = clock();
  printf("Starting of the program, start_t = %ld\n", start_t);
  printf("Going to scan a big loop, start_t = %ld\n", start_t);
  for (i = 0; i < 10000000; i++)
    ;
  end_t = clock();
  printf("End of the big loop, end_t = %ld\n", end_t);
  total_t = (double)(end_t - start_t) / CLOCKS_PER_SEC;
  total_t = (double)(end_t - start_t);
  printf("CLOCKS_PER_SEC = %ld\n", CLOCKS_PER_SEC);
  printf("Total time taken by CPU: %f\n", (double)total_t);
  printf("Exiting of the program...\n");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
lea    0xeb9(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x10(%rbp),%xmm0
lea    0xece(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x989680,-0x24(%rbp)
jge    1188 <main+0x68>
jmp    117a <main+0x5a>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1168 <main+0x48>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xeb1(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
mov    0x2e30(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    0x2e11(%rip),%rax
movsd  (%rax),%xmm0
lea    0xe91(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xe94(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,0x10(%rsp)
lea    0xeb8(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xed2(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xeda(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x8(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x2e51(%rip),%rax
movsd  (%rax),%xmm0
lea    0xed1(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xed9(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xee2(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [40 x i8] c"Starting of the program, start_t = %ld\0A\00"
@.str.1 = [41 x i8] c"Going to scan a big loop, start_t = %ld\0A\00"
@.str.2 = [34 x i8] c"End of the big loop, end_t = %ld\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.3 = [22 x i8] c"CLOCKS_PER_SEC = %ld\0A\00"
@.str.4 = [29 x i8] c"Total time taken by CPU: %f\0A\00"
@.str.5 = [27 x i8] c"Exiting of the program...\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i32
store i32 0, i32* %1
%6 = call double (...) @clock()
store double %6, double* %2
%7 = load double, double* %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), double %7)
%9 = load double, double* %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), double %9)
store i32 0, i32* %5
br label %11
11: ; preds = %15, %0
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 10000000
br i1 %13, label %14, label %18
14: ; preds = %11
br label %15
15: ; preds = %14
%16 = load i32, i32* %5
%17 = add nsw i32 %16, 1
store i32 %17, i32* %5
br label %11
18: ; preds = %11
%19 = call double (...) @clock()
store double %19, double* %3
%20 = load double, double* %3
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), double %20)
%22 = load double, double* %3
%23 = load double, double* %2
%24 = fsub double %22, %23
%25 = load double, double* @CLOCKS_PER_SEC
%26 = fdiv double %24, %25
store double %26, double* %4
%27 = load double, double* %3
%28 = load double, double* %2
%29 = fsub double %27, %28
store double %29, double* %4
%30 = load double, double* @CLOCKS_PER_SEC
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), double %30)
%32 = load double, double* %4
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), double %32)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [40 x i8] c"Starting of the program, start_t = %ld\0A\00"
@.str.1 = [41 x i8] c"Going to scan a big loop, start_t = %ld\0A\00"
@.str.2 = [34 x i8] c"End of the big loop, end_t = %ld\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.3 = [22 x i8] c"CLOCKS_PER_SEC = %ld\0A\00"
@.str.4 = [29 x i8] c"Total time taken by CPU: %f\0A\00"
@str = [26 x i8] c"Exiting of the program...\00"
define i32 @main() {
%1 = tail call double (...) @clock()
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), double %1)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), double %1)
%4 = tail call double (...) @clock()
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), double %4)
%6 = fsub double %4, %1
%7 = load double, double* @CLOCKS_PER_SEC
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), double %7)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), double %6)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
ret i32 0
}