#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 (elapsed > 0.1f) {
      *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    1196 <CalcTime+0x86>
mov    $0x0,%al
call   1030 <CurrentTimeInSeconds@plt>
mov    -0x18(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe9e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1191 <CalcTime+0x81>
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    11a8 <CalcTime+0x98>
jmp    1196 <CalcTime+0x86>
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     1147 <CalcTime+0x37>
subsd  (%r14),%xmm0
ucomisd 0xecc(%rip),%xmm0
jbe    114c <CalcTime+0x3c>
cvtsi2sdl (%rbx),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%r14)
xor    %eax,%eax
jmp    1154 <CalcTime+0x44>
movsd  %xmm0,(%r14)
addl   $0x1,(%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 %28
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 double, double* %6
%19 = fcmp ogt double %18, 0x3FB99999A0000000
br i1 %19, label %20, label %27
20: ; preds = %13
%21 = load double, double* %6
%22 = load i32*, i32** %4
%23 = load i32, i32* %22
%24 = sitofp i32 %23 to double
%25 = fdiv double %21, %24
%26 = load double*, double** %5
store double %25, double* %26
store i32 0, i32* %3
br label %32
27: ; preds = %13
br label %28
28: ; preds = %27, %10
%29 = load i32*, i32** %4
%30 = load i32, i32* %29
%31 = add nsw i32 %30, 1
store i32 %31, i32* %29
store i32 1, i32* %3
br label %32
32: ; preds = %28, %20
%33 = load i32, i32* %3
ret i32 %33
}

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 %7
6: ; preds = %2
store double %5, double* %1
br label %15
7: ; preds = %2
%8 = load double, double* %1
%9 = fsub double %5, %8
%10 = fcmp ogt double %9, 0x3FB99999A0000000
br i1 %10, label %11, label %15
11: ; preds = %7
%12 = load i32, i32* %0
%13 = sitofp i32 %12 to double
%14 = fdiv double %9, %13
store double %14, double* %1
br label %18
15: ; preds = %7, %6
%16 = load i32, i32* %0
%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
}