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

/* Variables and functions */
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, double);
char *test0();
char *test1();
main() {
  char *dat;
  struct timeval tv1, tv2;
  size_t i = 0;
  dat = test0();
  free(dat);
  dat = test1();
  free(dat);
  double us = 0;
  double s = 0;
  for (i = 0; i < 10; i++) {
    gettimeofday(&tv1, NULL);
    dat = test0();
    gettimeofday(&tv2, NULL);
    free(dat);
    us += tv2.tv_usec - tv1.tv_usec;
    s += tv2.tv_sec - tv1.tv_sec;
  }
  printf("Total time = %f seconds\n",
         (double)us / 10 / 1000000 + (double)s / 10);
  us = 0;
  s = 0;
  for (i = 0; i < 10; i++) {
    gettimeofday(&tv1, NULL);
    dat = test1();
    gettimeofday(&tv2, NULL);
    free(dat);
    us += tv2.tv_usec - tv1.tv_usec;
    s += tv2.tv_sec - tv1.tv_sec;
  }
  printf("Total time = %f seconds\n",
         (double)us / 10 / 1000000 + (double)s / 10);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x38(%rbp)
mov    $0x0,%al
call   1070 <test0@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1040 <test1@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movq   $0x0,-0x38(%rbp)
cmpq   $0xa,-0x38(%rbp)
jae    121f <main+0xcf>
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
mov    $0x0,%al
call   1070 <test0@plt>
mov    %rax,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
sub    -0x18(%rbp),%rax
cvtsi2sd %rax,%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x30(%rbp),%rax
sub    -0x20(%rbp),%rax
cvtsi2sd %rax,%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11a7 <main+0x57>
movsd  -0x40(%rbp),%xmm0
movsd  0xdd4(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xdd0(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  0xdb7(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
lea    0xdb8(%rip),%rdi
call   1050 <printf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movq   $0x0,-0x38(%rbp)
cmpq   $0xa,-0x38(%rbp)
jae    12ed <main+0x19d>
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
mov    $0x0,%al
call   1040 <test1@plt>
mov    %rax,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
sub    -0x18(%rbp),%rax
cvtsi2sd %rax,%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x30(%rbp),%rax
sub    -0x20(%rbp),%rax
cvtsi2sd %rax,%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1275 <main+0x125>
movsd  -0x40(%rbp),%xmm0
movsd  0xd06(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xd02(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  0xce9(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
lea    0xcea(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
xor    %eax,%eax
call   1070 <test0@plt>
mov    %rax,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   1040 <test1@plt>
mov    %rax,%rdi
call   1030 <free@plt>
xorpd  %xmm0,%xmm0
mov    $0xa,%ebx
lea    0x20(%rsp),%r14
lea    0x10(%rsp),%r15
nopl   0x0(%rax)
movapd %xmm0,(%rsp)
mov    %r14,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
xor    %eax,%eax
call   1070 <test0@plt>
mov    %rax,%r12
mov    %r15,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    %r12,%rdi
call   1030 <free@plt>
movdqa 0x10(%rsp),%xmm0
psubq  0x20(%rsp),%xmm0
movq   %xmm0,%rax
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
pshufd $0xee,%xmm0,%xmm0
movq   %xmm0,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
unpcklpd %xmm0,%xmm1
movapd (%rsp),%xmm0
addpd  %xmm1,%xmm0
add    $0xffffffffffffffff,%rbx
jne    1190 <main+0x40>
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
divsd  0xdf7(%rip),%xmm1
unpcklpd %xmm0,%xmm1
divpd  0xdfb(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
lea    0xdf8(%rip),%rdi
call   1050 <printf@plt>
xorpd  %xmm0,%xmm0
mov    $0xa,%ebx
lea    0x20(%rsp),%r14
lea    0x10(%rsp),%r15
movapd %xmm0,(%rsp)
mov    %r14,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
xor    %eax,%eax
call   1040 <test1@plt>
mov    %rax,%r12
mov    %r15,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    %r12,%rdi
call   1030 <free@plt>
movdqa 0x10(%rsp),%xmm0
psubq  0x20(%rsp),%xmm0
movq   %xmm0,%rax
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
pshufd $0xee,%xmm0,%xmm0
movq   %xmm0,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
unpcklpd %xmm0,%xmm1
movapd (%rsp),%xmm0
addpd  %xmm1,%xmm0
add    $0xffffffffffffffff,%rbx
jne    1240 <main+0xf0>
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
divsd  0xd47(%rip),%xmm1
unpcklpd %xmm0,%xmm1
divpd  0xd4b(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
lea    0xd48(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
@.str = [25 x i8] c"Total time = %f seconds\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = alloca i64
%6 = alloca double
%7 = alloca double
store i32 0, i32* %1
store i64 0, i64* %5
%8 = call i8* (...) @test0()
store i8* %8, i8** %2
%9 = load i8*, i8** %2
%10 = call i32 @free(i8* %9)
%11 = call i8* (...) @test1()
store i8* %11, i8** %2
%12 = load i8*, i8** %2
%13 = call i32 @free(i8* %12)
store double 0.000000e+00, double* %6
store double 0.000000e+00, double* %7
store i64 0, i64* %5
br label %14
14: ; preds = %39, %0
%15 = load i64, i64* %5
%16 = icmp ult i64 %15, 10
br i1 %16, label %17, label %42
17: ; preds = %14
%18 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%19 = call i8* (...) @test0()
store i8* %19, i8** %2
%20 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%21 = load i8*, i8** %2
%22 = call i32 @free(i8* %21)
%23 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 1
%24 = load i64, i64* %23
%25 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 1
%26 = load i64, i64* %25
%27 = sub nsw i64 %24, %26
%28 = sitofp i64 %27 to double
%29 = load double, double* %6
%30 = fadd double %29, %28
store double %30, double* %6
%31 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
%32 = load i64, i64* %31
%33 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%34 = load i64, i64* %33
%35 = sub nsw i64 %32, %34
%36 = sitofp i64 %35 to double
%37 = load double, double* %7
%38 = fadd double %37, %36
store double %38, double* %7
br label %39
39: ; preds = %17
%40 = load i64, i64* %5
%41 = add i64 %40, 1
store i64 %41, i64* %5
br label %14
42: ; preds = %14
%43 = load double, double* %6
%44 = fdiv double %43, 1.000000e+01
%45 = fdiv double %44, 1.000000e+06
%46 = load double, double* %7
%47 = fdiv double %46, 1.000000e+01
%48 = fadd double %45, %47
%49 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %48)
store double 0.000000e+00, double* %6
store double 0.000000e+00, double* %7
store i64 0, i64* %5
br label %50
50: ; preds = %75, %42
%51 = load i64, i64* %5
%52 = icmp ult i64 %51, 10
br i1 %52, label %53, label %78
53: ; preds = %50
%54 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%55 = call i8* (...) @test1()
store i8* %55, i8** %2
%56 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%57 = load i8*, i8** %2
%58 = call i32 @free(i8* %57)
%59 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 1
%60 = load i64, i64* %59
%61 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 1
%62 = load i64, i64* %61
%63 = sub nsw i64 %60, %62
%64 = sitofp i64 %63 to double
%65 = load double, double* %6
%66 = fadd double %65, %64
store double %66, double* %6
%67 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
%68 = load i64, i64* %67
%69 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%70 = load i64, i64* %69
%71 = sub nsw i64 %68, %70
%72 = sitofp i64 %71 to double
%73 = load double, double* %7
%74 = fadd double %73, %72
store double %74, double* %7
br label %75
75: ; preds = %53
%76 = load i64, i64* %5
%77 = add i64 %76, 1
store i64 %77, i64* %5
br label %50
78: ; preds = %50
%79 = load double, double* %6
%80 = fdiv double %79, 1.000000e+01
%81 = fdiv double %80, 1.000000e+06
%82 = load double, double* %7
%83 = fdiv double %82, 1.000000e+01
%84 = fadd double %81, %83
%85 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %84)
%86 = load i32, i32* %1
ret i32 %86
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
@.str = [25 x i8] c"Total time = %f seconds\0A\00"
define i32 @main() {
%1 = alloca <2 x i64>
%2 = bitcast <2 x i64>* %1 to %struct.timeval*
%3 = alloca <2 x i64>
%4 = bitcast <2 x i64>* %3 to %struct.timeval*
%5 = bitcast <2 x i64>* %1 to i8*
%6 = bitcast <2 x i64>* %3 to i8*
%7 = tail call i8* (...) @test0()
%8 = tail call i32 @free(i8* %7)
%9 = tail call i8* (...) @test1()
%10 = tail call i32 @free(i8* %9)
br label %11
11: ; preds = %0, %11
%12 = phi i64 [ 0, %0 ], [ %23, %11 ]
%13 = phi <2 x double> [ zeroinitializer, %0 ], [ %22, %11 ]
%14 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%15 = tail call i8* (...) @test0()
%16 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%17 = tail call i32 @free(i8* %15)
%18 = load <2 x i64>, <2 x i64>* %3
%19 = load <2 x i64>, <2 x i64>* %1
%20 = sub nsw <2 x i64> %18, %19
%21 = sitofp <2 x i64> %20 to <2 x double>
%22 = fadd <2 x double> %13, %21
%23 = add nuw nsw i64 %12, 1
%24 = icmp eq i64 %23, 10
br i1 %24, label %25, label %11
25: ; preds = %11
%26 = extractelement <2 x double> %22, i64 1
%27 = fdiv double %26, 1.000000e+01
%28 = insertelement <2 x double> poison, double %27, i64 0
%29 = shufflevector <2 x double> %28, <2 x double> %22, <2 x i32> <i32 0, i32 2>
%30 = fdiv <2 x double> %29, <double 1.000000e+06, double 1.000000e+01>
%31 = shufflevector <2 x double> %30, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%32 = fadd <2 x double> %30, %31
%33 = extractelement <2 x double> %32, i64 0
%34 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %33)
br label %35
35: ; preds = %25, %35
%36 = phi i64 [ 0, %25 ], [ %47, %35 ]
%37 = phi <2 x double> [ zeroinitializer, %25 ], [ %46, %35 ]
%38 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%39 = tail call i8* (...) @test1()
%40 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%41 = tail call i32 @free(i8* %39)
%42 = load <2 x i64>, <2 x i64>* %3
%43 = load <2 x i64>, <2 x i64>* %1
%44 = sub nsw <2 x i64> %42, %43
%45 = sitofp <2 x i64> %44 to <2 x double>
%46 = fadd <2 x double> %37, %45
%47 = add nuw nsw i64 %36, 1
%48 = icmp eq i64 %47, 10
br i1 %48, label %49, label %35
49: ; preds = %35
%50 = extractelement <2 x double> %46, i64 1
%51 = fdiv double %50, 1.000000e+01
%52 = insertelement <2 x double> poison, double %51, i64 0
%53 = shufflevector <2 x double> %52, <2 x double> %46, <2 x i32> <i32 0, i32 2>
%54 = fdiv <2 x double> %53, <double 1.000000e+06, double 1.000000e+01>
%55 = shufflevector <2 x double> %54, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%56 = fadd <2 x double> %54, %55
%57 = extractelement <2 x double> %56, i64 0
%58 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %57)
ret i32 0
}