#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_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
double jmlist_test_time(bool stop) {
  static struct timeval ts, te;
  if (stop) {
    gettimeofday(&te, 0);
    return (te.tv_usec - ts.tv_usec);
  }
  gettimeofday(&ts, 0);
  return 0;
}


x86 assembly (clang, -O0):
<jmlist_test_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     114d <jmlist_test_time+0x3d>
lea    0x2f0c(%rip),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
movsd  0x2efd(%rip),%xmm0
subsd  0x2eed(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1163 <jmlist_test_time+0x53>
lea    0x2edc(%rip),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jmlist_test_time>:
push   %rax
test   %edi,%edi
je     1135 <jmlist_test_time+0x25>
lea    0x2f1c(%rip),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
movsd  0x2f0d(%rip),%xmm0
subsd  0x2efd(%rip),%xmm0
pop    %rax
ret
lea    0x2ef4(%rip),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
xorps  %xmm0,%xmm0
pop    %rax
ret

LLVM IR (-O0):
%struct.timeval = type { double }
@jmlist_test_time.ts = internal global %struct.timeval zeroinitializer
@jmlist_test_time.te = internal global %struct.timeval zeroinitializer
define double @jmlist_test_time(i32 %0) {
%2 = alloca double
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %1
%7 = call i32 @gettimeofday(%struct.timeval* @jmlist_test_time.te, i32 0)
%8 = load double, double* getelementptr inbounds (%struct.timeval, %struct.timeval* @jmlist_test_time.te, i32 0, i32 0)
%9 = load double, double* getelementptr inbounds (%struct.timeval, %struct.timeval* @jmlist_test_time.ts, i32 0, i32 0)
%10 = fsub double %8, %9
store double %10, double* %2
br label %13
11: ; preds = %1
%12 = call i32 @gettimeofday(%struct.timeval* @jmlist_test_time.ts, i32 0)
store double 0.000000e+00, double* %2
br label %13
13: ; preds = %11, %6
%14 = load double, double* %2
ret double %14
}

LLVM IR (-O2):
%struct.timeval = type { double }
@jmlist_test_time.ts = internal global %struct.timeval zeroinitializer
@jmlist_test_time.te = internal global %struct.timeval zeroinitializer
define double @jmlist_test_time(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %8, label %3
3: ; preds = %1
%4 = tail call i32 @gettimeofday(%struct.timeval* @jmlist_test_time.te, i32 0)
%5 = load double, double* getelementptr inbounds (%struct.timeval, %struct.timeval* @jmlist_test_time.te, i64 0, i32 0)
%6 = load double, double* getelementptr inbounds (%struct.timeval, %struct.timeval* @jmlist_test_time.ts, i64 0, i32 0)
%7 = fsub double %5, %6
br label %10
8: ; preds = %1
%9 = tail call i32 @gettimeofday(%struct.timeval* @jmlist_test_time.ts, i32 0)
br label %10
10: ; preds = %8, %3
%11 = phi double [ %7, %3 ], [ 0.000000e+00, %8 ]
ret double %11
}