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

/* Variables and functions */
double *exprnd(int, double);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ srand(int);
int main() {
  int n = 1000000;
  int rint;
  FILE *fp;
  fp = fopen("/dev/urandom", "r");
  fread(&rint, 1, sizeof(int), fp);
  fclose(fp);
  srand(rint);
  double *arr = exprnd(n, 0.5);
  for (int i = 0; i < n; i++) {
    printf("%.20f\n", arr[i]);
  }
  free(arr);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xf4240,-0x8(%rbp)
lea    0xe7b(%rip),%rdi
lea    0xe81(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
lea    -0xc(%rbp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1040 <fread@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0xc(%rbp),%edi
call   1080 <srand@plt>
mov    -0x8(%rbp),%edi
movsd  0xe30(%rip),%xmm0
call   1070 <exprnd@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1213 <main+0xa3>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe17(%rip),%rdi
call   1060 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11e0 <main+0x70>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe88(%rip),%rdi
lea    0xe8e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
lea    0xc(%rsp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rax,%rcx
call   1040 <fread@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    0xc(%rsp),%edi
call   1080 <srand@plt>
movsd  0xe41(%rip),%xmm0
mov    $0xf4240,%edi
call   1070 <exprnd@plt>
mov    %rax,%r15
xor    %ebx,%ebx
lea    0xe42(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%r15,%rbx,8),%xmm0
mov    %r14,%rdi
call   1060 <printf@plt>
add    $0x1,%rbx
cmp    $0xf4240,%rbx
jne    11e0 <main+0x70>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"/dev/urandom\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [7 x i8] c"%.20f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca double*
%6 = alloca i32
store i32 0, i32* %1
store i32 1000000, i32* %2
%7 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %4
%8 = load i32*, i32** %4
%9 = call i32 @fread(i32* %3, i32 1, i32 4, i32* %8)
%10 = load i32*, i32** %4
%11 = call i32 @fclose(i32* %10)
%12 = load i32, i32* %3
%13 = call i32 @srand(i32 %12)
%14 = load i32, i32* %2
%15 = call double* @exprnd(i32 %14, double 5.000000e-01)
store double* %15, double** %5
store i32 0, i32* %6
br label %16
16: ; preds = %27, %0
%17 = load i32, i32* %6
%18 = load i32, i32* %2
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %30
20: ; preds = %16
%21 = load double*, double** %5
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %21, i64 %23
%25 = load double, double* %24
%26 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %25)
br label %27
27: ; preds = %20
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %16
30: ; preds = %16
%31 = load double*, double** %5
%32 = call i32 @free(double* %31)
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@.str = [13 x i8] c"/dev/urandom\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [7 x i8] c"%.20f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @fread(i32* %1, i32 1, i32 4, i32* %3)
%5 = tail call i32 @fclose(i32* %3)
%6 = load i32, i32* %1
%7 = tail call i32 @srand(i32 %6)
%8 = tail call double* @exprnd(i32 1000000, double 5.000000e-01)
br label %11
9: ; preds = %11
%10 = tail call i32 @free(double* %8)
ret i32 0
11: ; preds = %0, %11
%12 = phi i64 [ 0, %0 ], [ %16, %11 ]
%13 = getelementptr inbounds double, double* %8, i64 %12
%14 = load double, double* %13
%15 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %14)
%16 = add nuw nsw i64 %12, 1
%17 = icmp eq i64 %16, 1000000
br i1 %17, label %9, label %11
}