#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 */

/* Variables and functions */
scalar_t__ abs(int);
int /*<<< orphan*/ printf(char *, double);
int rand();
int /*<<< orphan*/ usleep(unsigned int);
int main(int argc, char **argv) {
  for (int i = 0; i < 20; i++) {
    unsigned int wait_time = (unsigned int)abs(rand() % 1000000);
    double sec_wait = (double)wait_time / 1000000;
    printf("Waiting for %e seconds \n", sec_wait);
    usleep(wait_time);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x14,-0x14(%rbp)
jge    11d7 <main+0x97>
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,%edi
movslq %edi,%rax
imul   $0x431bde83,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x32,%rax
add    %ecx,%eax
imul   $0xf4240,%eax,%eax
sub    %eax,%edi
call   1030 <abs@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  0xe59(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
lea    0xe4c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%edi
call   1060 <usleep@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115d <main+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x14,%ebp
lea    0xeb8(%rip),%r14
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rdi
imul   $0x431bde83,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x32,%rax
add    %ecx,%eax
imul   $0xf4240,%eax,%eax
sub    %eax,%edi
call   1030 <abs@plt>
mov    %rax,%rbx
mov    %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  0xe70(%rip),%xmm0
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %ebx,%edi
call   1060 <usleep@plt>
add    $0xffffffff,%ebp
jne    1150 <main+0x10>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Waiting for %e seconds \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %9
9: ; preds = %24, %2
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 20
br i1 %11, label %12, label %27
12: ; preds = %9
%13 = call i32 (...) @rand()
%14 = srem i32 %13, 1000000
%15 = call i64 @abs(i32 %14)
%16 = trunc i64 %15 to i32
store i32 %16, i32* %7
%17 = load i32, i32* %7
%18 = uitofp i32 %17 to double
%19 = fdiv double %18, 1.000000e+06
store double %19, double* %8
%20 = load double, double* %8
%21 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %20)
%22 = load i32, i32* %7
%23 = call i32 @usleep(i32 %22)
br label %24
24: ; preds = %12
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %9
27: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"Waiting for %e seconds \0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %4
3: ; preds = %4
ret i32 0
4: ; preds = %2, %4
%5 = phi i32 [ 0, %2 ], [ %14, %4 ]
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 1000000
%8 = tail call i64 @abs(i32 %7)
%9 = trunc i64 %8 to i32
%10 = uitofp i32 %9 to double
%11 = fdiv double %10, 1.000000e+06
%12 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %11)
%13 = tail call i32 @usleep(i32 %9)
%14 = add nuw nsw i32 %5, 1
%15 = icmp eq i32 %14, 20
br i1 %15, label %3, label %4
}