#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 get_rn_int(int *);
int *init_rng(int, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ print_rng(int *);
int /*<<< orphan*/ printf(char *, ...);
main() {
  int streamnum, nstreams, *stream;
  double rn;
  int irn;
  int i;
  streamnum = 0;
  nstreams = 1;
  stream = init_rng(streamnum, nstreams, 985456376, 0);
  printf(" Print 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);
  }
  printf(" Printing 3 random integers in [0,2^31):\n");
  for (i = 0; i < 3; i++) {
    irn = get_rn_int(stream);
    printf("%16d\n", irn);
  }
  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    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    $0x3abcdef8,%edx
xor    %ecx,%ecx
call   1040 <init_rng@plt>
mov    %rax,-0x18(%rbp)
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1070 <print_rng@plt>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0x3,-0x28(%rbp)
jge    11f8 <main+0x98>
mov    -0x18(%rbp),%rdi
call   1080 <get_rn_dbl@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
lea    0xe69(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11bf <main+0x5f>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0x3,-0x28(%rbp)
jge    1242 <main+0xe2>
mov    -0x18(%rbp),%rdi
call   1050 <get_rn_int@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    120d <main+0xad>
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    %edi,%edi
mov    $0x1,%esi
mov    $0x3abcdef8,%edx
xor    %ecx,%ecx
call   1050 <init_rng@plt>
mov    %rax,%rbx
lea    0xe79(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1080 <print_rng@plt>
lea    0xe8a(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1090 <get_rn_dbl@plt>
lea    0xe47(%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>
lea    0xe66(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1060 <get_rn_int@plt>
lea    0xe02(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <get_rn_int@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <get_rn_int@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
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 = [38 x i8] c" Print 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"
@.str.3 = [42 x i8] c" Printing 3 random integers in [0,2^31):\0A\00"
@.str.4 = [6 x i8] c"%16d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 1, i32* %3
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = call i32* @init_rng(i32 %8, i32 %9, i32 985456376, i32 0)
store i32* %10, i32** %4
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%12 = load i32*, i32** %4
%13 = call i32 @print_rng(i32* %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %7
br label %15
15: ; preds = %23, %0
%16 = load i32, i32* %7
%17 = icmp slt i32 %16, 3
br i1 %17, label %18, label %26
18: ; preds = %15
%19 = load i32*, i32** %4
%20 = call double @get_rn_dbl(i32* %19)
store double %20, double* %5
%21 = load double, double* %5
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %21)
br label %23
23: ; preds = %18
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %15
26: ; preds = %15
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %7
br label %28
28: ; preds = %36, %26
%29 = load i32, i32* %7
%30 = icmp slt i32 %29, 3
br i1 %30, label %31, label %39
31: ; preds = %28
%32 = load i32*, i32** %4
%33 = call i32 @get_rn_int(i32* %32)
store i32 %33, i32* %6
%34 = load i32, i32* %6
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %31
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %28
39: ; preds = %28
%40 = load i32*, i32** %4
%41 = call i32 @free_rng(i32* %40)
%42 = load i32, i32* %1
ret i32 %42
}

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