#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;
  scalar_t__ tv_usec;
};

/* Variables and functions */
int doit();
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, double);
void rep(int n) {
  struct timeval t1, t2;
  double d1, d2;
  int r;
  while (n > 0) {
    gettimeofday(&t1, NULL);
    r = doit();
    gettimeofday(&t2, NULL);
    d1 = t1.tv_sec + (double)t1.tv_usec / 1000000;
    d2 = t2.tv_sec + (double)t2.tv_usec / 1000000;
    printf(" - {result: %d, time: %.6f}\n", r, d2 - d1);
    n--;
  }
}


x86 assembly (clang, -O0):
<rep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    11d0 <rep+0xa0>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    $0x0,%al
call   1050 <doit@plt>
mov    %eax,-0x3c(%rbp)
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
movsd  -0x18(%rbp),%xmm0
cvtsi2sdq -0x10(%rbp),%xmm1
movsd  0xe84(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
cvtsi2sdq -0x20(%rbp),%xmm1
movsd  0xe64(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x3c(%rbp),%esi
movsd  -0x38(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    113b <rep+0xb>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rep>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
test   %edi,%edi
jle    11d5 <rep+0xa5>
mov    %edi,%ebx
add    $0x1,%ebx
mov    %rsp,%r14
lea    0x10(%rsp),%r15
lea    0xeb8(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
xor    %eax,%eax
call   1050 <doit@plt>
mov    %eax,%ebp
mov    %r15,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
movdqa 0x10(%rsp),%xmm0
movdqa %xmm0,%xmm1
xorps  %xmm2,%xmm2
cvtsi2sdq 0x8(%rsp),%xmm2
punpckhqdq %xmm0,%xmm1
movq   %xmm1,%rax
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
unpcklpd %xmm2,%xmm1
movhpd (%rsp),%xmm0
divpd  0xe4d(%rip),%xmm1
addpd  %xmm1,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
subsd  %xmm1,%xmm0
mov    %r12,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
ja     1160 <rep+0x30>
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.timeval = type { double, i64 }
@.str = [29 x i8] c" - {result: %d, time: %.6f}\0A\00"
define void @rep(i32 %0) {
%2 = alloca %struct.timeval
%3 = alloca <2 x double>
%4 = bitcast <2 x double>* %3 to %struct.timeval*
%5 = bitcast %struct.timeval* %2 to i8*
%6 = bitcast <2 x double>* %3 to i8*
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %32
8: ; preds = %1
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
br label %11
11: ; preds = %8, %11
%12 = phi i32 [ %0, %8 ], [ %30, %11 ]
%13 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%14 = tail call i32 (...) @doit()
%15 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%16 = load double, double* %9
%17 = load i64, i64* %10
%18 = load <2 x double>, <2 x double>* %3
%19 = bitcast <2 x double> %18 to <2 x i64>
%20 = shufflevector <2 x i64> %19, <2 x i64> poison, <2 x i32> <i32 1, i32 undef>
%21 = insertelement <2 x i64> %20, i64 %17, i64 1
%22 = sitofp <2 x i64> %21 to <2 x double>
%23 = fdiv <2 x double> %22, <double 1.000000e+06, double 1.000000e+06>
%24 = insertelement <2 x double> %18, double %16, i64 1
%25 = fadd <2 x double> %24, %23
%26 = shufflevector <2 x double> %25, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%27 = fsub <2 x double> %25, %26
%28 = extractelement <2 x double> %27, i64 0
%29 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %14, double %28)
%30 = add nsw i32 %12, -1
%31 = icmp ugt i32 %12, 1
br i1 %31, label %11, label %32
32: ; preds = %11, %1
ret void
}