#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 */
struct timeval {
  double tv_sec;
  double tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, double);
int main(int argc, char **argv) {
  int i = 0;
  int iterations = 10000000;
  struct timeval start, end;
  gettimeofday(&start, NULL);
  for (i; i < iterations; i++) {
    ;
  }
  gettimeofday(&end, NULL);
  printf("%f\n", ((end.tv_sec - start.tv_sec) +
                  ((end.tv_usec - start.tv_usec) / 1000000.0)));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x989680,-0x18(%rbp)
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1170 <main+0x50>
jmp    1162 <main+0x42>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1151 <main+0x31>
lea    -0x38(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
movsd  -0x38(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
movsd  0xe67(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    %rsp,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
movapd (%rsp),%xmm1
subpd  0x10(%rsp),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
divsd  0xeab(%rip),%xmm0
addsd  %xmm1,%xmm0
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.timeval = type { double, double }
@.str = [4 x i8] c"%f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.timeval
%9 = alloca %struct.timeval
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 10000000, i32* %7
%10 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%11 = load i32, i32* %6
br label %12
12: ; preds = %17, %2
%13 = load i32, i32* %6
%14 = load i32, i32* %7
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %20
16: ; preds = %12
br label %17
17: ; preds = %16
%18 = load i32, i32* %6
%19 = add nsw i32 %18, 1
store i32 %19, i32* %6
br label %12
20: ; preds = %12
%21 = call i32 @gettimeofday(%struct.timeval* %9, i32* null)
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 0
%23 = load double, double* %22
%24 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%25 = load double, double* %24
%26 = fsub double %23, %25
%27 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 1
%28 = load double, double* %27
%29 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 1
%30 = load double, double* %29
%31 = fsub double %28, %30
%32 = fdiv double %31, 1.000000e+06
%33 = fadd double %26, %32
%34 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %33)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { double, double }
@.str = [4 x i8] c"%f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca <2 x double>
%4 = bitcast <2 x double>* %3 to %struct.timeval*
%5 = alloca <2 x double>
%6 = bitcast <2 x double>* %5 to %struct.timeval*
%7 = bitcast <2 x double>* %3 to i8*
%8 = bitcast <2 x double>* %5 to i8*
%9 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%10 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%11 = load <2 x double>, <2 x double>* %5
%12 = load <2 x double>, <2 x double>* %3
%13 = fsub <2 x double> %11, %12
%14 = extractelement <2 x double> %13, i64 1
%15 = fdiv double %14, 1.000000e+06
%16 = extractelement <2 x double> %13, i64 0
%17 = fadd double %16, %15
%18 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %17)
ret i32 0
}