#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 */
typedef scalar_t__ clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
scalar_t__ clock();
void delay(double dly) {
  clock_t ticks1, ticks2;
  ticks1 = clock();
  ticks2 = ticks1;
  while (((double)ticks2 / CLOCKS_PER_SEC - (double)ticks1 / CLOCKS_PER_SEC) <
         dly)
    ticks2 = clock();
}


x86 assembly (clang, -O0):
<delay>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
cvtsi2sdq -0x18(%rbp),%xmm1
mov    0x2eab(%rip),%rax
divsd  (%rax),%xmm1
cvtsi2sdq -0x10(%rbp),%xmm0
mov    0x2e9a(%rip),%rax
divsd  (%rax),%xmm0
subsd  %xmm0,%xmm1
movsd  -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1175 <delay+0x65>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x18(%rbp)
jmp    1130 <delay+0x20>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delay>:
push   %rbx
sub    $0x20,%rsp
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1030 <clock@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mov    0x2eb7(%rip),%rbx
movapd %xmm0,%xmm1
divsd  (%rbx),%xmm1
subsd  %xmm1,%xmm1
movsd  0x8(%rsp),%xmm2
ucomisd %xmm1,%xmm2
jbe    1196 <delay+0x86>
unpcklpd %xmm0,%xmm0
movapd %xmm0,0x10(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1030 <clock@plt>
movapd 0x10(%rsp),%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rbx),%xmm1
unpcklpd %xmm1,%xmm1
divpd  %xmm1,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
subsd  %xmm1,%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
ja     1160 <delay+0x50>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@CLOCKS_PER_SEC = global double 0.000000e+00
define void @delay(double %0) {
%2 = alloca double
%3 = alloca i64
%4 = alloca i64
store double %0, double* %2
%5 = call i64 (...) @clock()
store i64 %5, i64* %3
%6 = load i64, i64* %3
store i64 %6, i64* %4
br label %7
7: ; preds = %19, %1
%8 = load i64, i64* %4
%9 = sitofp i64 %8 to double
%10 = load double, double* @CLOCKS_PER_SEC
%11 = fdiv double %9, %10
%12 = load i64, i64* %3
%13 = sitofp i64 %12 to double
%14 = load double, double* @CLOCKS_PER_SEC
%15 = fdiv double %13, %14
%16 = fsub double %11, %15
%17 = load double, double* %2
%18 = fcmp olt double %16, %17
br i1 %18, label %19, label %21
19: ; preds = %7
%20 = call i64 (...) @clock()
store i64 %20, i64* %4
br label %7
21: ; preds = %7
ret void
}

LLVM IR (-O2):
@CLOCKS_PER_SEC = global double 0.000000e+00
define void @delay(double %0) {
%2 = tail call i64 (...) @clock()
%3 = sitofp i64 %2 to double
%4 = load double, double* @CLOCKS_PER_SEC
%5 = fdiv double %3, %4
%6 = fsub double %5, %5
%7 = fcmp olt double %6, %0
br i1 %7, label %8, label %22
8: ; preds = %1
%9 = insertelement <2 x double> poison, double %3, i64 1
br label %10
10: ; preds = %8, %10
%11 = tail call i64 (...) @clock()
%12 = sitofp i64 %11 to double
%13 = load double, double* @CLOCKS_PER_SEC
%14 = insertelement <2 x double> %9, double %12, i64 0
%15 = insertelement <2 x double> poison, double %13, i64 0
%16 = shufflevector <2 x double> %15, <2 x double> poison, <2 x i32> zeroinitializer
%17 = fdiv <2 x double> %14, %16
%18 = shufflevector <2 x double> %17, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%19 = fsub <2 x double> %17, %18
%20 = extractelement <2 x double> %19, i64 0
%21 = fcmp olt double %20, %0
br i1 %21, label %10, label %22
22: ; preds = %10, %1
ret void
}