#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 *, struct timespec *);
void delayMicrosecondsWPi(unsigned int howLong) {
  struct timespec sleeper, dummy;
  if (howLong == 0)
    return;
  else if (howLong < 100)
    delayMicrosecondsHard(howLong);
  else {
    sleeper.tv_sec = 0;
    sleeper.tv_nsec = (long)(howLong * 1000);
    nanosleep(&sleeper, &dummy);
  }
}


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

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

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

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