#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 tms {
  double tms_utime;
};
typedef double clock_t;

/* Variables and functions */
int /*<<< orphan*/ _SC_CLK_TCK;
long sysconf(int /*<<< orphan*/);
double times(struct tms *);
double app_tminterval(int stop, int usertime) {
  double ret = 0;
  struct tms rus;
  clock_t now = times(&rus);
  static clock_t tmstart;
  if (usertime)
    now = rus.tms_utime;
  if (stop == 0)
    tmstart = now;
  else {
    long int tck = sysconf(_SC_CLK_TCK);
    ret = (now - tmstart) / (double)tck;
  }
  return (ret);
}


x86 assembly (clang, -O0):
<app_tminterval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
call   1030 <times@plt>
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1158 <app_tminterval+0x38>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1174 <app_tminterval+0x54>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,0x2ec9(%rip)
jmp    11a2 <app_tminterval+0x82>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
call   1040 <sysconf@plt>
mov    %rax,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  0x2ea5(%rip),%xmm0
cvtsi2sdq -0x28(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<app_tminterval>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebp
mov    %edi,%ebx
lea    0x10(%rsp),%rdi
call   1030 <times@plt>
test   %ebp,%ebp
je     113e <app_tminterval+0x1e>
movsd  0x10(%rsp),%xmm0
test   %ebx,%ebx
je     116f <app_tminterval+0x4f>
mov    0x2e97(%rip),%rax
mov    (%rax),%edi
movsd  %xmm0,0x8(%rsp)
call   1040 <sysconf@plt>
movsd  0x8(%rsp),%xmm0
subsd  0x2ed4(%rip),%xmm0
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%xmm0
jmp    117b <app_tminterval+0x5b>
movsd  %xmm0,0x2ec1(%rip)
xorpd  %xmm0,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.tms = type { double }
@app_tminterval.tmstart = internal global double 0.000000e+00
@_SC_CLK_TCK = global i32 0
define double @app_tminterval(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca %struct.tms
%7 = alloca double
%8 = alloca i64
store i32 %0, i32* %3
store i32 %1, i32* %4
store double 0.000000e+00, double* %5
%9 = call double @times(%struct.tms* %6)
store double %9, double* %7
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = getelementptr inbounds %struct.tms, %struct.tms* %6, i32 0, i32 0
%14 = load double, double* %13
store double %14, double* %7
br label %15
15: ; preds = %12, %2
%16 = load i32, i32* %3
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = load double, double* %7
store double %19, double* @app_tminterval.tmstart
br label %29
20: ; preds = %15
%21 = load i32, i32* @_SC_CLK_TCK
%22 = call i64 @sysconf(i32 %21)
store i64 %22, i64* %8
%23 = load double, double* %7
%24 = load double, double* @app_tminterval.tmstart
%25 = fsub double %23, %24
%26 = load i64, i64* %8
%27 = sitofp i64 %26 to double
%28 = fdiv double %25, %27
store double %28, double* %5
br label %29
29: ; preds = %20, %18
%30 = load double, double* %5
ret double %30
}

LLVM IR (-O2):
%struct.tms = type { double }
@app_tminterval.tmstart = internal unnamed_addr global double 0.000000e+00
@_SC_CLK_TCK = global i32 0
define double @app_tminterval(i32 %0, i32 %1) {
%3 = alloca %struct.tms
%4 = bitcast %struct.tms* %3 to i8*
%5 = call double @times(%struct.tms* %3)
%6 = icmp eq i32 %1, 0
%7 = getelementptr inbounds %struct.tms, %struct.tms* %3, i64 0, i32 0
%8 = load double, double* %7
%9 = select i1 %6, double %5, double %8
%10 = icmp eq i32 %0, 0
br i1 %10, label %11, label %12
11: ; preds = %2
store double %9, double* @app_tminterval.tmstart
br label %19
12: ; preds = %2
%13 = load i32, i32* @_SC_CLK_TCK
%14 = tail call i64 @sysconf(i32 %13)
%15 = load double, double* @app_tminterval.tmstart
%16 = fsub double %9, %15
%17 = sitofp i64 %14 to double
%18 = fdiv double %16, %17
br label %19
19: ; preds = %12, %11
%20 = phi double [ 0.000000e+00, %11 ], [ %18, %12 ]
ret double %20
}