#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 = (n << 3) + (n << 1);
  }
  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    1197 <main+0x67>
mov    -0x8(%rbp),%eax
shl    $0x3,%eax
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
add    %ecx,%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    0xe47(%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 = %23, %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 %26
17: ; preds = %13
%18 = load i32, i32* %2
%19 = shl i32 %18, 3
%20 = load i32, i32* %2
%21 = shl i32 %20, 1
%22 = add nsw i32 %19, %21
store i32 %22, i32* %4
br label %23
23: ; preds = %17
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 1
store i32 %25, i32* %2
br label %13
26: ; preds = %13
%27 = call i32 @gettimeofday(%struct.timeval* %9, i32* null)
%28 = call i32 @timeval_subtract(double* %10, %struct.timeval* %9, %struct.timeval* %8)
%29 = load double, double* %10
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %29)
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
}