#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 */

/* Variables and functions */
double CurrentTimeInSeconds();
bool CalcTime(int *times, double *start) {
  if (*times == 0) {
    *start = CurrentTimeInSeconds();
  } else {
    double elapsed = CurrentTimeInSeconds() - *start;
    if (*times == 10) {
      *start = elapsed / *times;
      return false;
    }
  }
  (*times)++;
  return true;
}


x86 assembly (clang, -O0):
<CalcTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jne    1141 <CalcTime+0x31>
mov    $0x0,%al
call   1030 <CurrentTimeInSeconds@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    118c <CalcTime+0x7c>
mov    $0x0,%al
call   1030 <CurrentTimeInSeconds@plt>
mov    -0x18(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0xa,(%rax)
jne    1187 <CalcTime+0x77>
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
cvtsi2sdl (%rax),%xmm1
divsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    119e <CalcTime+0x8e>
jmp    118c <CalcTime+0x7c>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CalcTime>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%ebp
xor    %eax,%eax
call   1030 <CurrentTimeInSeconds@plt>
test   %ebp,%ebp
je     1144 <CalcTime+0x34>
mov    (%rbx),%eax
cmp    $0xa,%eax
jne    114b <CalcTime+0x3b>
subsd  (%r14),%xmm0
divsd  0xec5(%rip),%xmm0
movsd  %xmm0,(%r14)
xor    %eax,%eax
jmp    1155 <CalcTime+0x45>
movsd  %xmm0,(%r14)
mov    (%rbx),%eax
add    $0x1,%eax
mov    %eax,(%rbx)
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @CalcTime(i32* %0, double* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca double*
%6 = alloca double
store i32* %0, i32** %4
store double* %1, double** %5
%7 = load i32*, i32** %4
%8 = load i32, i32* %7
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = call double (...) @CurrentTimeInSeconds()
%12 = load double*, double** %5
store double %11, double* %12
br label %29
13: ; preds = %2
%14 = call double (...) @CurrentTimeInSeconds()
%15 = load double*, double** %5
%16 = load double, double* %15
%17 = fsub double %14, %16
store double %17, double* %6
%18 = load i32*, i32** %4
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, 10
br i1 %20, label %21, label %28
21: ; preds = %13
%22 = load double, double* %6
%23 = load i32*, i32** %4
%24 = load i32, i32* %23
%25 = sitofp i32 %24 to double
%26 = fdiv double %22, %25
%27 = load double*, double** %5
store double %26, double* %27
store i32 0, i32* %3
br label %33
28: ; preds = %13
br label %29
29: ; preds = %28, %10
%30 = load i32*, i32** %4
%31 = load i32, i32* %30
%32 = add nsw i32 %31, 1
store i32 %32, i32* %30
store i32 1, i32* %3
br label %33
33: ; preds = %29, %21
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
define i32 @CalcTime(i32* nocapture %0, double* nocapture %1) {
%3 = load i32, i32* %0
%4 = icmp eq i32 %3, 0
%5 = tail call double (...) @CurrentTimeInSeconds()
br i1 %4, label %6, label %8
6: ; preds = %2
store double %5, double* %1
%7 = load i32, i32* %0
br label %15
8: ; preds = %2
%9 = load i32, i32* %0
%10 = icmp eq i32 %9, 10
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = load double, double* %1
%13 = fsub double %5, %12
%14 = fdiv double %13, 1.000000e+01
store double %14, double* %1
br label %18
15: ; preds = %8, %6
%16 = phi i32 [ %9, %8 ], [ %7, %6 ]
%17 = add nsw i32 %16, 1
store i32 %17, i32* %0
br label %18
18: ; preds = %11, %15
%19 = phi i32 [ 1, %15 ], [ 0, %11 ]
ret i32 %19
}