#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 */
int /*<<< orphan*/ free_rng(int *);
double get_rn_dbl(int *);
int *init_rng(int, int, int, int /*<<< orphan*/);
int make_new_seed();
int /*<<< orphan*/ print_rng(int *);
int /*<<< orphan*/ printf(char *, ...);
main() {
  int streamnum, nstreams, seed, *stream, i;
  double rn;
  streamnum = 0;
  nstreams = 1;
  seed = make_new_seed();
  stream = init_rng(streamnum, nstreams, seed, 0);
  printf(" Printing information about new stream\n");
  print_rng(stream);
  printf(" Printing 3 random numbers in [0,1):\n");
  for (i = 0; i < 3; i++) {
    rn = get_rn_dbl(stream);
    printf("%f\n", rn);
  }
  free_rng(stream);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    $0x0,%al
call   1050 <make_new_seed@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
xor    %ecx,%ecx
call   1040 <init_rng@plt>
mov    %rax,-0x18(%rbp)
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1070 <print_rng@plt>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    1200 <main+0xa0>
mov    -0x18(%rbp),%rdi
call   1080 <get_rn_dbl@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
lea    0xe63(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c7 <main+0x67>
mov    -0x18(%rbp),%rdi
call   1060 <free_rng@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <make_new_seed@plt>
xor    %edi,%edi
mov    $0x1,%esi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <init_rng@plt>
mov    %rax,%rbx
lea    0xe6f(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1080 <print_rng@plt>
lea    0xe82(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1090 <get_rn_dbl@plt>
lea    0xe43(%rip),%r14
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1090 <get_rn_dbl@plt>
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1090 <get_rn_dbl@plt>
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1070 <free_rng@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [40 x i8] c" Printing information about new stream\0A\00"
@.str.1 = [38 x i8] c" Printing 3 random numbers in [0,1):\0A\00"
@.str.2 = [4 x i8] c"%f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca double
store i32 0, i32* %1
store i32 0, i32* %2
store i32 1, i32* %3
%8 = call i32 (...) @make_new_seed()
store i32 %8, i32* %4
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = call i32* @init_rng(i32 %9, i32 %10, i32 %11, i32 0)
store i32* %12, i32** %5
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%14 = load i32*, i32** %5
%15 = call i32 @print_rng(i32* %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %6
br label %17
17: ; preds = %25, %0
%18 = load i32, i32* %6
%19 = icmp slt i32 %18, 3
br i1 %19, label %20, label %28
20: ; preds = %17
%21 = load i32*, i32** %5
%22 = call double @get_rn_dbl(i32* %21)
store double %22, double* %7
%23 = load double, double* %7
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %23)
br label %25
25: ; preds = %20
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %17
28: ; preds = %17
%29 = load i32*, i32** %5
%30 = call i32 @free_rng(i32* %29)
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@.str.2 = [4 x i8] c"%f\0A\00"
@str = [39 x i8] c" Printing information about new stream\00"
@str.3 = [37 x i8] c" Printing 3 random numbers in [0,1):\00"
define i32 @main() {
%1 = tail call i32 (...) @make_new_seed()
%2 = tail call i32* @init_rng(i32 0, i32 1, i32 %1, i32 0)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @print_rng(i32* %2)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.3, i64 0, i64 0))
%6 = tail call double @get_rn_dbl(i32* %2)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %6)
%8 = tail call double @get_rn_dbl(i32* %2)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %8)
%10 = tail call double @get_rn_dbl(i32* %2)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %10)
%12 = tail call i32 @free_rng(i32* %2)
ret i32 0
}