#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 /*<<< orphan*/ doit(double *, double *);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
double *init_a();
double *init_d();
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/, double);
void rep(int n) {
  struct timeval t1, t2;
  double d1, d2;
  while (n > 0) {
    double *a = init_a();
    double *d = init_d();
    gettimeofday(&t1, NULL);
    doit(a, d);
    gettimeofday(&t2, NULL);
    free(a);
    free(d);
    d1 = t1.tv_sec + (double)t1.tv_usec / 1000000;
    d2 = t2.tv_sec + (double)t2.tv_usec / 1000000;
    printf(" - {result: %d, time: %.6f}\n", 0, d2 - d1);
    n--;
  }
}


x86 assembly (clang, -O0):
<rep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    122a <rep+0xca>
mov    $0x0,%al
call   1080 <init_a@plt>
mov    %rax,-0x40(%rbp)
mov    $0x0,%al
call   1050 <init_d@plt>
mov    %rax,-0x48(%rbp)
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1070 <doit@plt>
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
movsd  -0x18(%rbp),%xmm0
cvtsi2sdq -0x10(%rbp),%xmm1
movsd  0xe29(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
cvtsi2sdq -0x20(%rbp),%xmm1
movsd  0xe09(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
lea    0xdf3(%rip),%rdi
xor    %esi,%esi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    116b <rep+0xb>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rep>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %edi,%edi
jle    122f <rep+0xcf>
mov    %edi,%ebx
add    $0x1,%ebx
mov    %rsp,%r14
lea    0x10(%rsp),%r15
lea    0xe86(%rip),%r12
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <init_a@plt>
mov    %rax,%r13
xor    %eax,%eax
call   1050 <init_d@plt>
mov    %rax,%rbp
mov    %r14,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
call   1070 <doit@plt>
mov    %r15,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@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  0xdf7(%rip),%xmm1
addpd  %xmm1,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
subsd  %xmm1,%xmm0
mov    %r12,%rdi
xor    %esi,%esi
call   1040 <printf@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
ja     1190 <rep+0x30>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
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 double*
%8 = alloca double*
store i32 %0, i32* %2
br label %9
9: ; preds = %12, %1
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %44
12: ; preds = %9
%13 = call double* (...) @init_a()
store double* %13, double** %7
%14 = call double* (...) @init_d()
store double* %14, double** %8
%15 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%16 = load double*, double** %7
%17 = load double*, double** %8
%18 = call i32 @doit(double* %16, double* %17)
%19 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%20 = load double*, double** %7
%21 = call i32 @free(double* %20)
%22 = load double*, double** %8
%23 = call i32 @free(double* %22)
%24 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%25 = load double, double* %24
%26 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 1
%27 = load i64, i64* %26
%28 = sitofp i64 %27 to double
%29 = fdiv double %28, 1.000000e+06
%30 = fadd double %25, %29
store double %30, double* %5
%31 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
%32 = load double, double* %31
%33 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 1
%34 = load i64, i64* %33
%35 = sitofp i64 %34 to double
%36 = fdiv double %35, 1.000000e+06
%37 = fadd double %32, %36
store double %37, double* %6
%38 = load double, double* %6
%39 = load double, double* %5
%40 = fsub double %38, %39
%41 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 0, double %40)
%42 = load i32, i32* %2
%43 = add nsw i32 %42, -1
store i32 %43, i32* %2
br label %9
44: ; preds = %9
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 %36
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 ], [ %34, %11 ]
%13 = tail call double* (...) @init_a()
%14 = tail call double* (...) @init_d()
%15 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%16 = tail call i32 @doit(double* %13, double* %14)
%17 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%18 = tail call i32 @free(double* %13)
%19 = tail call i32 @free(double* %14)
%20 = load double, double* %9
%21 = load i64, i64* %10
%22 = load <2 x double>, <2 x double>* %3
%23 = bitcast <2 x double> %22 to <2 x i64>
%24 = shufflevector <2 x i64> %23, <2 x i64> poison, <2 x i32> <i32 1, i32 undef>
%25 = insertelement <2 x i64> %24, i64 %21, i64 1
%26 = sitofp <2 x i64> %25 to <2 x double>
%27 = fdiv <2 x double> %26, <double 1.000000e+06, double 1.000000e+06>
%28 = insertelement <2 x double> %22, double %20, i64 1
%29 = fadd <2 x double> %28, %27
%30 = shufflevector <2 x double> %29, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%31 = fsub <2 x double> %29, %30
%32 = extractelement <2 x double> %31, i64 0
%33 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 0, double %32)
%34 = add nsw i32 %12, -1
%35 = icmp ugt i32 %12, 1
br i1 %35, label %11, label %36
36: ; preds = %11, %1
ret void
}