#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 */
int /*<<< orphan*/ printf(char *, long double);
unsigned long long rdtsc();
int main(int argc, char **argv) {
  unsigned long long x;
  unsigned long long y;
  int i = 0;
  int iterations = 10000000;
  x = rdtsc();
  for (i; i < iterations; i++) {
    ;
  }
  y = rdtsc();
  long double time = (long double)(y - x) / 2600000000;
  printf("It took this time to do the for-loop: %Lf \n", time);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x989680,-0x28(%rbp)
mov    $0x0,%al
call   1040 <rdtsc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    116e <main+0x4e>
jmp    1160 <main+0x40>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114f <main+0x2f>
xor    %eax,%eax
call   1040 <rdtsc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x48(%rbp)
sets   %al
movzbl %al,%eax
mov    %eax,%ecx
fildll -0x48(%rbp)
lea    0xe66(%rip),%rax
flds   (%rax,%rcx,4)
faddp  %st,%st(1)
flds   0xe63(%rip)
fdivrp %st,%st(1)
fstpt  -0x40(%rbp)
fldt   -0x40(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
xor    %eax,%eax
call   1040 <rdtsc@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <rdtsc@plt>
xor    %ecx,%ecx
sub    %rbx,%rax
mov    %rax,0x18(%rsp)
sets   %cl
fildll 0x18(%rsp)
lea    0xeb2(%rip),%rax
fadds  (%rax,%rcx,4)
fdivs  0xeb1(%rip)
fstpt  (%rsp)
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [44 x i8] c"It took this time to do the for-loop: %Lf \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca x86_fp80
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 10000000, i32* %9
%11 = call i64 (...) @rdtsc()
store i64 %11, i64* %6
%12 = load i32, i32* %8
br label %13
13: ; preds = %18, %2
%14 = load i32, i32* %8
%15 = load i32, i32* %9
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %21
17: ; preds = %13
br label %18
18: ; preds = %17
%19 = load i32, i32* %8
%20 = add nsw i32 %19, 1
store i32 %20, i32* %8
br label %13
21: ; preds = %13
%22 = call i64 (...) @rdtsc()
store i64 %22, i64* %7
%23 = load i64, i64* %7
%24 = load i64, i64* %6
%25 = sub i64 %23, %24
%26 = uitofp i64 %25 to x86_fp80
%27 = fdiv x86_fp80 %26, 0xK401E9AF8DA0000000000
store x86_fp80 %27, x86_fp80* %10
%28 = load x86_fp80, x86_fp80* %10
%29 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), x86_fp80 %28)
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@.str = [44 x i8] c"It took this time to do the for-loop: %Lf \0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 (...) @rdtsc()
%4 = tail call i64 (...) @rdtsc()
%5 = sub i64 %4, %3
%6 = uitofp i64 %5 to x86_fp80
%7 = fdiv x86_fp80 %6, 0xK401E9AF8DA0000000000
%8 = tail call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), x86_fp80 %7)
ret i32 0
}