#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 {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ timeval_subtract(double *, struct timeval *,
                                    struct timeval *);
int main() {
  int n, k;
  int i;
  int sum = 0;
  int count = 0;
  int a;
  struct timeval tdr0, tdr1;
  double restime;
  char string[12];
  gettimeofday(&tdr0, NULL);
  for (n = 0; n < 1e8; n++) {
    i = 10 * n;
  }
  gettimeofday(&tdr1, NULL);
  timeval_subtract(&restime, &tdr1, &tdr0);
  printf("%e\n", restime);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
movl   $0x0,-0x8(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xe92(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    118d <main+0x5d>
imul   $0xa,-0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1161 <main+0x31>
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
lea    -0x30(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1050 <timeval_subtract@plt>
movsd  -0x30(%rbp),%xmm0
lea    0xe51(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <timeval_subtract@plt>
movsd  (%rsp),%xmm0
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
@.str = [4 x i8] c"%e\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.timeval
%9 = alloca %struct.timeval
%10 = alloca double
%11 = alloca [12 x i8]
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %6
%12 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
store i32 0, i32* %2
br label %13
13: ; preds = %20, %0
%14 = load i32, i32* %2
%15 = sitofp i32 %14 to double
%16 = fcmp olt double %15, 1.000000e+08
br i1 %16, label %17, label %23
17: ; preds = %13
%18 = load i32, i32* %2
%19 = mul nsw i32 10, %18
store i32 %19, i32* %4
br label %20
20: ; preds = %17
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %13
23: ; preds = %13
%24 = call i32 @gettimeofday(%struct.timeval* %9, i32* null)
%25 = call i32 @timeval_subtract(double* %10, %struct.timeval* %9, %struct.timeval* %8)
%26 = load double, double* %10
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %26)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
@.str = [4 x i8] c"%e\0A\00"
define i32 @main() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timeval
%3 = alloca double
%4 = bitcast %struct.timeval* %1 to i8*
%5 = bitcast %struct.timeval* %2 to i8*
%6 = bitcast double* %3 to i8*
%7 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%8 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%9 = call i32 @timeval_subtract(double* %3, %struct.timeval* %2, %struct.timeval* %1)
%10 = load double, double* %3
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %10)
ret i32 0
}