#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 timeval {
  long tv_sec;
  long tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ select(int /*<<< orphan*/, int /*<<< orphan*/ *,
                          int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                          struct timeval *);
void microsecSleep(long ms) {
  struct timeval delay;
  delay.tv_sec = ms * 1e-6;
  delay.tv_usec = ms - 1e6 * delay.tv_sec;
  select(0, NULL, NULL, NULL, &delay);
}


x86 assembly (clang, -O0):
<microsecSleep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cvtsi2sdq -0x8(%rbp),%xmm0
movsd  0xede(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x18(%rbp)
cvtsi2sdq -0x8(%rbp),%xmm1
cvtsi2sdq -0x18(%rbp),%xmm0
movsd  0xeb5(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x10(%rbp)
xor    %edi,%edi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x18(%rbp),%r8
mov    %rcx,%rsi
mov    %rcx,%rdx
call   1030 <select@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<microsecSleep>:
sub    $0x18,%rsp
cvtsi2sd %rdi,%xmm0
movsd  0xedf(%rip),%xmm1
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rax
mov    %rax,0x8(%rsp)
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
mulsd  0xec9(%rip),%xmm1
addsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rax
mov    %rax,0x10(%rsp)
lea    0x8(%rsp),%r8
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <select@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
define void @microsecSleep(i64 %0) {
%2 = alloca i64
%3 = alloca %struct.timeval
store i64 %0, i64* %2
%4 = load i64, i64* %2
%5 = sitofp i64 %4 to double
%6 = fmul double %5, 0x3EB0C6F7A0B5ED8D
%7 = fptosi double %6 to i64
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
store i64 %7, i64* %8
%9 = load i64, i64* %2
%10 = sitofp i64 %9 to double
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%12 = load i64, i64* %11
%13 = sitofp i64 %12 to double
%14 = call double @llvm.fmuladd.f64(double -1.000000e+06, double %13, double %10)
%15 = fptosi double %14 to i64
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 1
store i64 %15, i64* %16
%17 = call i32 @select(i32 0, i32* null, i32* null, i32* null, %struct.timeval* %3)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
define void @microsecSleep(i64 %0) {
%2 = alloca %struct.timeval
%3 = bitcast %struct.timeval* %2 to i8*
%4 = sitofp i64 %0 to double
%5 = fmul double %4, 0x3EB0C6F7A0B5ED8D
%6 = fptosi double %5 to i64
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
store i64 %6, i64* %7
%8 = sitofp i64 %6 to double
%9 = tail call double @llvm.fmuladd.f64(double %8, double -1.000000e+06, double %4)
%10 = fptosi double %9 to i64
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
store i64 %10, i64* %11
%12 = call i32 @select(i32 0, i32* null, i32* null, i32* null, %struct.timeval* %2)
ret void
}