#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 timespec {
  long tv_nsec;
  scalar_t__ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ delayMicrosecondsHard(unsigned int);
int /*<<< orphan*/ nanosleep(struct timespec *, int /*<<< orphan*/ *);
void delayMicroseconds(unsigned int howLong) {
  struct timespec sleeper;
  if (howLong == 0)
    return;
  else if (howLong < 100)
    delayMicrosecondsHard(howLong);
  else {
    sleeper.tv_sec = 0;
    sleeper.tv_nsec = (long)(howLong * 1000);
    nanosleep(&sleeper, NULL);
  }
}


x86 assembly (clang, -O0):
<delayMicroseconds>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    113a <delayMicroseconds+0x1a>
jmp    1178 <delayMicroseconds+0x58>
cmpl   $0x64,-0x4(%rbp)
jae    1151 <delayMicroseconds+0x31>
mov    -0x4(%rbp),%edi
call   1040 <delayMicrosecondsHard@plt>
jmp    1173 <delayMicroseconds+0x53>
movq   $0x0,-0x10(%rbp)
imul   $0x3e8,-0x4(%rbp),%eax
mov    %eax,%eax
mov    %rax,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <nanosleep@plt>
jmp    1178 <delayMicroseconds+0x58>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delayMicroseconds>:
test   %edi,%edi
je     1156 <delayMicroseconds+0x36>
cmp    $0x63,%edi
ja     112e <delayMicroseconds+0xe>
jmp    1040 <delayMicrosecondsHard@plt>
sub    $0x18,%rsp
movq   $0x0,0x10(%rsp)
imul   $0x3e8,%edi,%eax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1030 <nanosleep@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.timespec = type { i64, i64 }
define void @delayMicroseconds(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.timespec
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %1
br label %21
7: ; preds = %1
%8 = load i32, i32* %2
%9 = icmp ult i32 %8, 100
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = load i32, i32* %2
%12 = call i32 @delayMicrosecondsHard(i32 %11)
br label %20
13: ; preds = %7
%14 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 1
store i64 0, i64* %14
%15 = load i32, i32* %2
%16 = mul i32 %15, 1000
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 0
store i64 %17, i64* %18
%19 = call i32 @nanosleep(%struct.timespec* %3, i32* null)
br label %20
20: ; preds = %13, %10
br label %21
21: ; preds = %6, %20
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i64, i64 }
define void @delayMicroseconds(i32 %0) {
%2 = alloca %struct.timespec
%3 = bitcast %struct.timespec* %2 to i8*
%4 = icmp eq i32 %0, 0
br i1 %4, label %15, label %5
5: ; preds = %1
%6 = icmp ult i32 %0, 100
br i1 %6, label %7, label %9
7: ; preds = %5
%8 = tail call i32 @delayMicrosecondsHard(i32 %0)
br label %15
9: ; preds = %5
%10 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 1
store i64 0, i64* %10
%11 = mul i32 %0, 1000
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
store i64 %12, i64* %13
%14 = call i32 @nanosleep(%struct.timespec* %2, i32* null)
br label %15
15: ; preds = %9, %7, %1
ret void
}