#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 */
double RAND_MAX;
int /*<<< orphan*/ printf(char *, double);
scalar_t__ rand();
main() {
  int i = 0;
  while (i++ < 5) {
    printf("%f\n", ((double)rand() / (RAND_MAX + 1.0)));
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x5,%eax
jge    117e <main+0x5e>
mov    $0x0,%al
call   1040 <rand@plt>
cvtsi2sd %rax,%xmm0
movsd  0xea2(%rip),%xmm1
mov    0x2e83(%rip),%rax
addsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
jmp    1136 <main+0x16>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2eb1(%rip),%r14
movsd  (%r14),%xmm1
addsd  0xebc(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xeb9(%rip),%rbx
mov    %rbx,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%r14),%xmm1
addsd  0xe8d(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    %rbx,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%r14),%xmm1
addsd  0xe65(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    %rbx,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%r14),%xmm1
addsd  0xe3d(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    %rbx,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0xe1a(%rip),%xmm1
addsd  (%r14),%xmm1
divsd  %xmm1,%xmm0
mov    %rbx,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%f\0A\00"
@RAND_MAX = global double 0.000000e+00
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %3
3: ; preds = %7, %0
%4 = load i32, i32* %2
%5 = add nsw i32 %4, 1
store i32 %5, i32* %2
%6 = icmp slt i32 %4, 5
br i1 %6, label %7, label %14
7: ; preds = %3
%8 = call i64 (...) @rand()
%9 = sitofp i64 %8 to double
%10 = load double, double* @RAND_MAX
%11 = fadd double %10, 1.000000e+00
%12 = fdiv double %9, %11
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %12)
br label %3
14: ; preds = %3
%15 = load i32, i32* %1
ret i32 %15
}

LLVM IR (-O2):
@.str = [4 x i8] c"%f\0A\00"
@RAND_MAX = global double 0.000000e+00
define i32 @main() {
%1 = tail call i64 (...) @rand()
%2 = sitofp i64 %1 to double
%3 = load double, double* @RAND_MAX
%4 = fadd double %3, 1.000000e+00
%5 = fdiv double %2, %4
%6 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %5)
%7 = tail call i64 (...) @rand()
%8 = sitofp i64 %7 to double
%9 = load double, double* @RAND_MAX
%10 = fadd double %9, 1.000000e+00
%11 = fdiv double %8, %10
%12 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %11)
%13 = tail call i64 (...) @rand()
%14 = sitofp i64 %13 to double
%15 = load double, double* @RAND_MAX
%16 = fadd double %15, 1.000000e+00
%17 = fdiv double %14, %16
%18 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %17)
%19 = tail call i64 (...) @rand()
%20 = sitofp i64 %19 to double
%21 = load double, double* @RAND_MAX
%22 = fadd double %21, 1.000000e+00
%23 = fdiv double %20, %22
%24 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %23)
%25 = tail call i64 (...) @rand()
%26 = sitofp i64 %25 to double
%27 = load double, double* @RAND_MAX
%28 = fadd double %27, 1.000000e+00
%29 = fdiv double %26, %28
%30 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %29)
ret i32 0
}