#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free_sprng(int *);
int *init_sprng(int, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ print_sprng(int *);
int /*<<< orphan*/ printf(char *, ...);
double sprng(int *);
int /*<<< orphan*/ stderr;
main() {
  int streamnum, nstreams, *stream;
  double rn;
  int i;
  streamnum = 0;
  nstreams = 1;
  stream = init_sprng(streamnum, nstreams, 985456376, 0);
  printf("Print information about random number stream:\n");
  print_sprng(stream);
  printf("Printing 3 random numbers in [0,1):\n");
  for (i = 0; i < 3; i++) {
    rn = sprng(stream);
    printf("%f\n", rn);
  }
  free_sprng(stream);
  fprintf(stderr,
          "Expect a SPRNG error message on the use of an invalid stream ID\n");
  rn = sprng(stream);
  printf("sprng returns %f on being given an invalid stream ID\n", rn);
}


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   1080 <init_sprng@plt>
mov    %rax,-0x18(%rbp)
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <print_sprng@plt>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jge    11f8 <main+0x98>
mov    -0x18(%rbp),%rdi
call   1060 <sprng@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
lea    0xe71(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11bf <main+0x5f>
mov    -0x18(%rbp),%rdi
call   1070 <free_sprng@plt>
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
lea    0xe47(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1060 <sprng@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
lea    0xe69(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@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   1090 <init_sprng@plt>
mov    %rax,%rbx
lea    0xeea(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <print_sprng@plt>
lea    0xf04(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1070 <sprng@plt>
lea    0xe47(%rip),%r14
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1070 <sprng@plt>
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1070 <sprng@plt>
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1080 <free_sprng@plt>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
lea    0xe05(%rip),%rsi
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1070 <sprng@plt>
lea    0xe32(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [47 x i8] c"Print information about random number stream:\0A\00"
@.str.1 = [37 x i8] c"Printing 3 random numbers in [0,1):\0A\00"
@.str.2 = [4 x i8] c"%f\0A\00"
@stderr = global i32 0
@.str.3 = [65 x i8] c"Expect a SPRNG error message on the use of an invalid stream ID\0A\00"
@.str.4 = [54 x i8] c"sprng returns %f on being given an invalid stream ID\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 0, i32* %2
store i32 1, i32* %3
%7 = load i32, i32* %2
%8 = load i32, i32* %3
%9 = call i32* @init_sprng(i32 %7, i32 %8, i32 985456376, i32 0)
store i32* %9, i32** %4
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%11 = load i32*, i32** %4
%12 = call i32 @print_sprng(i32* %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %6
br label %14
14: ; preds = %22, %0
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 3
br i1 %16, label %17, label %25
17: ; preds = %14
%18 = load i32*, i32** %4
%19 = call double @sprng(i32* %18)
store double %19, double* %5
%20 = load double, double* %5
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %20)
br label %22
22: ; preds = %17
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 1
store i32 %24, i32* %6
br label %14
25: ; preds = %14
%26 = load i32*, i32** %4
%27 = call i32 @free_sprng(i32* %26)
%28 = load i32, i32* @stderr
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.3, i64 0, i64 0))
%30 = load i32*, i32** %4
%31 = call double @sprng(i32* %30)
store double %31, double* %5
%32 = load double, double* %5
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0), double %32)
%34 = load i32, i32* %1
ret i32 %34
}

LLVM IR (-O2):
@.str.2 = [4 x i8] c"%f\0A\00"
@stderr = global i32 0
@.str.3 = [65 x i8] c"Expect a SPRNG error message on the use of an invalid stream ID\0A\00"
@.str.4 = [54 x i8] c"sprng returns %f on being given an invalid stream ID\0A\00"
@str = [46 x i8] c"Print information about random number stream:\00"
@str.5 = [36 x i8] c"Printing 3 random numbers in [0,1):\00"
define i32 @main() {
%1 = tail call i32* @init_sprng(i32 0, i32 1, i32 985456376, i32 0)
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @print_sprng(i32* %1)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.5, i64 0, i64 0))
%5 = tail call double @sprng(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 @sprng(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 @sprng(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 @free_sprng(i32* %1)
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.3, i64 0, i64 0))
%14 = tail call double @sprng(i32* %1)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0), double %14)
ret i32 0
}