#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 /*<<< orphan*/ clockid_t;

/* Variables and functions */
int /*<<< orphan*/ usleep(int);
void bench_usleep(clockid_t clkid) {
  unsigned long loop;
  for (loop = 0; loop < 100000; loop++) {
    (void)usleep(1000);
    (void)usleep(1000);
    (void)usleep(1000);
    (void)usleep(1000);
    (void)usleep(1000);
    (void)usleep(1000);
    (void)usleep(1000);
    (void)usleep(1000);
    (void)usleep(1000);
    (void)usleep(1000);
  }
}


x86 assembly (clang, -O0):
<bench_usleep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
cmpq   $0x186a0,-0x10(%rbp)
jae    11a6 <bench_usleep+0x96>
mov    $0x3e8,%edi
call   1030 <usleep@plt>
mov    $0x3e8,%edi
call   1030 <usleep@plt>
mov    $0x3e8,%edi
call   1030 <usleep@plt>
mov    $0x3e8,%edi
call   1030 <usleep@plt>
mov    $0x3e8,%edi
call   1030 <usleep@plt>
mov    $0x3e8,%edi
call   1030 <usleep@plt>
mov    $0x3e8,%edi
call   1030 <usleep@plt>
mov    $0x3e8,%edi
call   1030 <usleep@plt>
mov    $0x3e8,%edi
call   1030 <usleep@plt>
mov    $0x3e8,%edi
call   1030 <usleep@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1123 <bench_usleep+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bench_usleep>:
push   %rbx
mov    $0x186a0,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    $0x3e8,%edi
call   1030 <usleep@plt>
mov    $0x3e8,%edi
call   1030 <usleep@plt>
mov    $0x3e8,%edi
call   1030 <usleep@plt>
mov    $0x3e8,%edi
call   1030 <usleep@plt>
mov    $0x3e8,%edi
call   1030 <usleep@plt>
mov    $0x3e8,%edi
call   1030 <usleep@plt>
mov    $0x3e8,%edi
call   1030 <usleep@plt>
mov    $0x3e8,%edi
call   1030 <usleep@plt>
mov    $0x3e8,%edi
call   1030 <usleep@plt>
mov    $0x3e8,%edi
call   1030 <usleep@plt>
add    $0xffffffffffffffff,%rbx
jne    1120 <bench_usleep+0x10>
pop    %rbx
ret

LLVM IR (-O0):
define void @bench_usleep(i32 %0) {
%2 = alloca i32
%3 = alloca i64
store i32 %0, i32* %2
store i64 0, i64* %3
br label %4
4: ; preds = %18, %1
%5 = load i64, i64* %3
%6 = icmp ult i64 %5, 100000
br i1 %6, label %7, label %21
7: ; preds = %4
%8 = call i32 @usleep(i32 1000)
%9 = call i32 @usleep(i32 1000)
%10 = call i32 @usleep(i32 1000)
%11 = call i32 @usleep(i32 1000)
%12 = call i32 @usleep(i32 1000)
%13 = call i32 @usleep(i32 1000)
%14 = call i32 @usleep(i32 1000)
%15 = call i32 @usleep(i32 1000)
%16 = call i32 @usleep(i32 1000)
%17 = call i32 @usleep(i32 1000)
br label %18
18: ; preds = %7
%19 = load i64, i64* %3
%20 = add i64 %19, 1
store i64 %20, i64* %3
br label %4
21: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @bench_usleep(i32 %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i64 [ 0, %1 ], [ %14, %2 ]
%4 = tail call i32 @usleep(i32 1000)
%5 = tail call i32 @usleep(i32 1000)
%6 = tail call i32 @usleep(i32 1000)
%7 = tail call i32 @usleep(i32 1000)
%8 = tail call i32 @usleep(i32 1000)
%9 = tail call i32 @usleep(i32 1000)
%10 = tail call i32 @usleep(i32 1000)
%11 = tail call i32 @usleep(i32 1000)
%12 = tail call i32 @usleep(i32 1000)
%13 = tail call i32 @usleep(i32 1000)
%14 = add nuw nsw i64 %3, 1
%15 = icmp eq i64 %14, 100000
br i1 %15, label %16, label %2
16: ; preds = %2
ret void
}