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

/* Variables and functions */
int /*<<< orphan*/ bcm2835_st_delay(int, int);
int bcm2835_st_read();
int /*<<< orphan*/ nanosleep(struct timespec *, int /*<<< orphan*/ *);
void delayMicroseconds(uint64_t micros) {
  struct timespec t1;
  uint64_t start;
  start = bcm2835_st_read();
  if (micros > 450) {
    t1.tv_sec = 0;
    t1.tv_nsec = 1000 * (long)(micros - 200);
    nanosleep(&t1, NULL);
  }
  bcm2835_st_delay(start, micros);
}


x86 assembly (clang, -O0):
<delayMicroseconds>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1030 <bcm2835_st_read@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1c2,-0x4(%rbp)
jle    117b <delayMicroseconds+0x4b>
movq   $0x0,-0x10(%rbp)
mov    -0x4(%rbp),%eax
sub    $0xc8,%eax
cltq
imul   $0x3e8,%rax,%rax
mov    %eax,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <nanosleep@plt>
mov    -0x1c(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1050 <bcm2835_st_delay@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delayMicroseconds>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
xor    %eax,%eax
call   1030 <bcm2835_st_read@plt>
mov    %eax,%ebp
cmp    $0x1c3,%ebx
jl     116d <delayMicroseconds+0x3d>
movq   $0x0,0x10(%rsp)
imul   $0x3e8,%ebx,%eax
add    $0xfffcf2c0,%eax
mov    %eax,0x8(%rsp)
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1040 <nanosleep@plt>
mov    %ebp,%edi
mov    %ebx,%esi
call   1050 <bcm2835_st_delay@plt>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

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

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