#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 gettime();
double getclockticks() {
  static double clockticks;
  static char setclockticks = (0);
  if (!setclockticks) {
    double time = gettime();
    while (time == gettime())
      ;
    clockticks = 1.0 / (gettime() - time);
    setclockticks = (1);
  }
  return (clockticks);
}


x86 assembly (clang, -O0):
<getclockticks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
cmpb   $0x0,0x2f19(%rip)
jne    1189 <getclockticks+0x79>
mov    $0x0,%al
call   1030 <gettime@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <gettime@plt>
movaps %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jne    115f <getclockticks+0x4f>
jp     115f <getclockticks+0x4f>
jmp    1131 <getclockticks+0x21>
mov    $0x0,%al
call   1030 <gettime@plt>
movaps %xmm0,%xmm1
subsd  -0x8(%rbp),%xmm1
movsd  0xe8a(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x2eae(%rip)
movb   $0x1,0x2eaf(%rip)
movsd  0x2e9f(%rip),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getclockticks>:
push   %rax
cmpb   $0x1,0x2f20(%rip)
jne    1124 <getclockticks+0x14>
movsd  0x2f0e(%rip),%xmm0
pop    %rax
ret
xor    %eax,%eax
call   1030 <gettime@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <gettime@plt>
movsd  (%rsp),%xmm1
ucomisd %xmm0,%xmm1
jne    1144 <getclockticks+0x34>
jnp    1130 <getclockticks+0x20>
xor    %eax,%eax
call   1030 <gettime@plt>
movapd %xmm0,%xmm1
subsd  (%rsp),%xmm1
movsd  0xea4(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x2ec8(%rip)
movb   $0x1,0x2ec9(%rip)
pop    %rax
ret

LLVM IR (-O0):
@getclockticks.clockticks = internal global double 0.000000e+00
@getclockticks.setclockticks = internal global i8 0
define double @getclockticks() {
%1 = alloca double
%2 = load i8, i8* @getclockticks.setclockticks
%3 = icmp ne i8 %2, 0
br i1 %3, label %16, label %4
4: ; preds = %0
%5 = call double (...) @gettime()
store double %5, double* %1
br label %6
6: ; preds = %10, %4
%7 = load double, double* %1
%8 = call double (...) @gettime()
%9 = fcmp oeq double %7, %8
br i1 %9, label %10, label %11
10: ; preds = %6
br label %6
11: ; preds = %6
%12 = call double (...) @gettime()
%13 = load double, double* %1
%14 = fsub double %12, %13
%15 = fdiv double 1.000000e+00, %14
store double %15, double* @getclockticks.clockticks
store i8 1, i8* @getclockticks.setclockticks
br label %16
16: ; preds = %11, %0
%17 = load double, double* @getclockticks.clockticks
ret double %17
}

LLVM IR (-O2):
@getclockticks.clockticks = internal unnamed_addr global double 0.000000e+00
@getclockticks.setclockticks = internal unnamed_addr global i1 false
define double @getclockticks() {
%1 = load i1, i1* @getclockticks.setclockticks
br i1 %1, label %2, label %4
2: ; preds = %0
%3 = load double, double* @getclockticks.clockticks
br label %13
4: ; preds = %0
%5 = tail call double (...) @gettime()
br label %6
6: ; preds = %6, %4
%7 = tail call double (...) @gettime()
%8 = fcmp oeq double %5, %7
br i1 %8, label %6, label %9
9: ; preds = %6
%10 = tail call double (...) @gettime()
%11 = fsub double %10, %5
%12 = fdiv double 1.000000e+00, %11
store double %12, double* @getclockticks.clockticks
store i1 true, i1* @getclockticks.setclockticks
br label %13
13: ; preds = %2, %9
%14 = phi double [ %3, %2 ], [ %12, %9 ]
ret double %14
}