#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 {
  unsigned long tv_usec;
  unsigned long tv_sec;
};
typedef int /*<<< orphan*/ fd_set;

/* Variables and functions */
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ Select(int /*<<< orphan*/, int /*<<< orphan*/ *,
                          int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                          struct timeval *);
void Usleep(unsigned long usec) {
  fd_set rset, wset, eset;
  struct timeval tv;
  tv.tv_usec = usec % 1000000;
  tv.tv_sec = usec / 1000000;
  FD_ZERO(&rset);
  FD_ZERO(&wset);
  FD_ZERO(&eset);
  Select(0, &rset, &wset, &eset, &tv);
}


x86 assembly (clang, -O0):
<Usleep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    $0xf4240,%ecx
xor    %edx,%edx
div    %rcx
mov    %rdx,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    $0xf4240,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x20(%rbp)
lea    -0xc(%rbp),%rdi
call   1030 <FD_ZERO@plt>
lea    -0x10(%rbp),%rdi
call   1030 <FD_ZERO@plt>
lea    -0x14(%rbp),%rdi
call   1030 <FD_ZERO@plt>
xor    %edi,%edi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
lea    -0x28(%rbp),%r8
call   1040 <Select@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Usleep>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movabs $0x431bde82d7b634db,%rcx
de 1b 43
mov    %rdi,%rax
mul    %rcx
shr    $0x12,%rdx
imul   $0xf4240,%rdx,%rax
sub    %rax,%rdi
mov    %rdi,0x10(%rsp)
mov    %rdx,0x18(%rsp)
lea    0xc(%rsp),%r14
mov    %r14,%rdi
call   1030 <FD_ZERO@plt>
lea    0x8(%rsp),%r15
mov    %r15,%rdi
call   1030 <FD_ZERO@plt>
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <FD_ZERO@plt>
lea    0x10(%rsp),%r8
xor    %edi,%edi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
call   1040 <Select@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
define void @Usleep(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.timeval
store i64 %0, i64* %2
%7 = load i64, i64* %2
%8 = urem i64 %7, 1000000
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
store i64 %8, i64* %9
%10 = load i64, i64* %2
%11 = udiv i64 %10, 1000000
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
store i64 %11, i64* %12
%13 = call i32 @FD_ZERO(i32* %3)
%14 = call i32 @FD_ZERO(i32* %4)
%15 = call i32 @FD_ZERO(i32* %5)
%16 = call i32 @Select(i32 0, i32* %3, i32* %4, i32* %5, %struct.timeval* %6)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
define void @Usleep(i64 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.timeval
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast %struct.timeval* %5 to i8*
%10 = urem i64 %0, 1000000
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
store i64 %10, i64* %11
%12 = udiv i64 %0, 1000000
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 1
store i64 %12, i64* %13
%14 = call i32 @FD_ZERO(i32* %2)
%15 = call i32 @FD_ZERO(i32* %3)
%16 = call i32 @FD_ZERO(i32* %4)
%17 = call i32 @Select(i32 0, i32* %2, i32* %3, i32* %4, %struct.timeval* %5)
ret void
}