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

/* Variables and functions */
int /*<<< orphan*/ nanosleep(struct timespec *, struct timespec *);
void slp_usleep(unsigned long int useconds) {
  struct timespec treq, trem;
  treq.tv_sec = (time_t)(useconds / 1e6);
  treq.tv_nsec = (long)((useconds * 1e3) - (treq.tv_sec * 1e9));
  nanosleep(&treq, &trem);
}


x86 assembly (clang, -O0):
<slp_usleep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movq   -0x8(%rbp),%xmm0
movaps 0xef8(%rip),%xmm2
punpckldq %xmm2,%xmm0
movapd 0xefc(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm3
unpckhpd %xmm0,%xmm0
addsd  %xmm3,%xmm0
movsd  0xec5(%rip),%xmm3
divsd  %xmm3,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x18(%rbp)
movq   -0x8(%rbp),%xmm0
punpckldq %xmm2,%xmm0
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
movsd  0xe8d(%rip),%xmm2
mulsd  %xmm2,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xe62(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <nanosleep@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<slp_usleep>:
sub    $0x28,%rsp
movq   %rdi,%xmm0
punpckldq 0xedf(%rip),%xmm0
subpd  0xee7(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
divsd  0xedf(%rip),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,0x8(%rsp)
cvttpd2dq %xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
mulsd  0xecf(%rip),%xmm0
mulsd  0xecf(%rip),%xmm1
addsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rax
mov    %rax,0x10(%rsp)
lea    0x8(%rsp),%rdi
lea    0x18(%rsp),%rsi
call   1030 <nanosleep@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.timespec = type { i32, i64 }
define void @slp_usleep(i64 %0) {
%2 = alloca i64
%3 = alloca %struct.timespec
%4 = alloca %struct.timespec
store i64 %0, i64* %2
%5 = load i64, i64* %2
%6 = uitofp i64 %5 to double
%7 = fdiv double %6, 1.000000e+06
%8 = fptosi double %7 to i32
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 0
store i32 %8, i32* %9
%10 = load i64, i64* %2
%11 = uitofp i64 %10 to double
%12 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 0
%13 = load i32, i32* %12
%14 = sitofp i32 %13 to double
%15 = fmul double %14, 1.000000e+09
%16 = fneg double %15
%17 = call double @llvm.fmuladd.f64(double %11, double 1.000000e+03, double %16)
%18 = fptosi double %17 to i64
%19 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 1
store i64 %18, i64* %19
%20 = call i32 @nanosleep(%struct.timespec* %3, %struct.timespec* %4)
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i32, i64 }
define void @slp_usleep(i64 %0) {
%2 = alloca %struct.timespec
%3 = alloca %struct.timespec
%4 = bitcast %struct.timespec* %2 to i8*
%5 = bitcast %struct.timespec* %3 to i8*
%6 = uitofp i64 %0 to double
%7 = fdiv double %6, 1.000000e+06
%8 = fptosi double %7 to i32
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
store i32 %8, i32* %9
%10 = sitofp i32 %8 to double
%11 = fmul double %10, -1.000000e+09
%12 = tail call double @llvm.fmuladd.f64(double %6, double 1.000000e+03, double %11)
%13 = fptosi double %12 to i64
%14 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 1
store i64 %13, i64* %14
%15 = call i32 @nanosleep(%struct.timespec* %2, %struct.timespec* %3)
ret void
}