#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*/ uint32_t;
typedef int /*<<< orphan*/ seed_array;
typedef scalar_t__ int32_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
char *dsfmt_get_idstring();
int /*<<< orphan*/ dsfmt_gv_init_by_array(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ exit(int);
scalar_t__ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
int fread(int /*<<< orphan*/ **, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ get_rand();
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
void initialize_rand(const char *seedfile) {
  uint32_t seed_array[624];
  FILE *f;
  assert(NULL != seedfile);
  f = fopen(seedfile, "r");
  if (NULL == f) {
    fprintf(stderr,
            "Error: could not open random number generator"
            " seed file %s - exiting!\n",
            seedfile);
    exit(-1);
  }
  if (fread(&seed_array, sizeof(int), 624, f) != 624) {
    fprintf(stderr,
            "Error: could not read %lu bytes from %s - "
            "exiting!\n",
            sizeof(seed_array), seedfile);
    exit(-1);
  }
  if (0 != fclose(f)) {
    fprintf(stderr,
            "Could not close %s, but we have the data we "
            "wanted anyways...\n",
            seedfile);
  }
  dsfmt_gv_init_by_array(seed_array, 624);
  do {
    if (1) {
      fflush(stdout);
      fputc('#', stderr);
      fprintf(stderr, "Using random number generator %s\n",
              dsfmt_get_idstring());
    }
  } while (0);
  ;
  int32_t Nrands = 1E6;
  for (int32_t i = 0; i < Nrands; ++i) {
    get_rand();
  }
}


x86 assembly (clang, -O0):
<initialize_rand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9f0,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
cmp    -0x8(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xe23(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x9d8(%rbp)
xor    %eax,%eax
cmp    -0x9d8(%rbp),%rax
jne    121d <initialize_rand+0x6d>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xdf6(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
lea    -0x9d0(%rbp),%rdi
mov    -0x9d8(%rbp),%rcx
mov    $0x4,%esi
mov    $0x270,%edx
call   1040 <fread@plt>
cmp    $0x270,%eax
je     126f <initialize_rand+0xbf>
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rcx
lea    0xdf0(%rip),%rsi
mov    $0x9c0,%edx
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    -0x9d8(%rbp),%rdi
call   1050 <fclose@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     12a4 <initialize_rand+0xf4>
mov    0x2d50(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xde0(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
lea    -0x9d0(%rbp),%rdi
mov    $0x270,%esi
call   1030 <dsfmt_gv_init_by_array@plt>
mov    0x2d1c(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    0x2d16(%rip),%rax
mov    (%rax),%esi
mov    $0x23,%edi
call   1070 <fputc@plt>
mov    0x2d03(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x9ec(%rbp)
mov    $0x0,%al
call   10c0 <dsfmt_get_idstring@plt>
mov    -0x9ec(%rbp),%edi
mov    %rax,%rdx
lea    0xdc0(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movq   $0xf4240,-0x9e0(%rbp)
movq   $0x0,-0x9e8(%rbp)
mov    -0x9e8(%rbp),%rax
cmp    -0x9e0(%rbp),%rax
jge    134b <initialize_rand+0x19b>
mov    $0x0,%al
call   1060 <get_rand@plt>
mov    -0x9e8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x9e8(%rbp)
jmp    1319 <initialize_rand+0x169>
add    $0x9f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initialize_rand>:
push   %r14
push   %rbx
sub    $0x9c8,%rsp
mov    %rdi,%r14
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1080 <assert@plt>
lea    0xe2e(%rip),%rsi
mov    %r14,%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1298 <initialize_rand+0xe8>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x4,%esi
mov    $0x270,%edx
mov    %rax,%rcx
call   1040 <fread@plt>
cmp    $0x270,%eax
jne    12bc <initialize_rand+0x10c>
mov    %rbx,%rdi
call   1050 <fclose@plt>
test   %rax,%rax
je     122d <initialize_rand+0x7d>
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
lea    0xe5a(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %rsp,%rdi
mov    $0x270,%esi
call   1030 <dsfmt_gv_init_by_array@plt>
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    0x2d91(%rip),%rbx
mov    (%rbx),%esi
mov    $0x23,%edi
call   1070 <fputc@plt>
mov    (%rbx),%ebx
xor    %eax,%eax
call   10c0 <dsfmt_get_idstring@plt>
lea    0xe51(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0xf4240,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <get_rand@plt>
add    $0xffffffffffffffff,%rbx
jne    1280 <initialize_rand+0xd0>
add    $0x9c8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2d41(%rip),%rax
mov    (%rax),%edi
lea    0xd5a(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    0x2d1d(%rip),%rax
mov    (%rax),%edi
lea    0xd7d(%rip),%rsi
mov    $0x9c0,%edx
mov    %r14,%rcx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [71 x i8] c"Error: could not open random number generator seed file %s - exiting!\0A\00"
@.str.2 = [52 x i8] c"Error: could not read %lu bytes from %s - exiting!\0A\00"
@.str.3 = [63 x i8] c"Could not close %s, but we have the data we wanted anyways...\0A\00"
@stdout = global i32 0
@.str.4 = [34 x i8] c"Using random number generator %s\0A\00"
define void @initialize_rand(i8* %0) {
%2 = alloca i8*
%3 = alloca [624 x i32]
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i64
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = icmp ne i8* null, %7
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = load i8*, i8** %2
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %4
%13 = load i32*, i32** %4
%14 = icmp eq i32* null, %13
br i1 %14, label %15, label %20
15: ; preds = %1
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %2
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 -1)
unreachable
20: ; preds = %1
%21 = bitcast [624 x i32]* %3 to i32**
%22 = load i32*, i32** %4
%23 = call i32 @fread(i32** %21, i32 4, i32 624, i32* %22)
%24 = icmp ne i32 %23, 624
br i1 %24, label %25, label %30
25: ; preds = %20
%26 = load i32, i32* @stderr
%27 = load i8*, i8** %2
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i64 2496, i8* %27)
%29 = call i32 @exit(i32 -1)
unreachable
30: ; preds = %20
%31 = load i32*, i32** %4
%32 = call i64 @fclose(i32* %31)
%33 = icmp ne i64 0, %32
br i1 %33, label %34, label %38
34: ; preds = %30
%35 = load i32, i32* @stderr
%36 = load i8*, i8** %2
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.3, i64 0, i64 0), i8* %36)
br label %38
38: ; preds = %34, %30
%39 = getelementptr inbounds [624 x i32], [624 x i32]* %3, i64 0, i64 0
%40 = call i32 @dsfmt_gv_init_by_array(i32* %39, i32 624)
br label %41
41: ; preds = %38
%42 = load i32, i32* @stdout
%43 = call i32 @fflush(i32 %42)
%44 = load i32, i32* @stderr
%45 = call i32 @fputc(i8 signext 35, i32 %44)
%46 = load i32, i32* @stderr
%47 = call i8* (...) @dsfmt_get_idstring()
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* %47)
br label %49
49: ; preds = %41
store i64 1000000, i64* %5
store i64 0, i64* %6
br label %50
50: ; preds = %56, %49
%51 = load i64, i64* %6
%52 = load i64, i64* %5
%53 = icmp slt i64 %51, %52
br i1 %53, label %54, label %59
54: ; preds = %50
%55 = call i32 (...) @get_rand()
br label %56
56: ; preds = %54
%57 = load i64, i64* %6
%58 = add nsw i64 %57, 1
store i64 %58, i64* %6
br label %50
59: ; preds = %50
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [71 x i8] c"Error: could not open random number generator seed file %s - exiting!\0A\00"
@.str.2 = [52 x i8] c"Error: could not read %lu bytes from %s - exiting!\0A\00"
@.str.3 = [63 x i8] c"Could not close %s, but we have the data we wanted anyways...\0A\00"
@stdout = global i32 0
@.str.4 = [34 x i8] c"Using random number generator %s\0A\00"
define void @initialize_rand(i8* %0) {
%2 = alloca [624 x i32]
%3 = bitcast [624 x i32]* %2 to i8*
%4 = icmp ne i8* %0, null
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%12 = tail call i32 @exit(i32 -1)
unreachable
13: ; preds = %1
%14 = bitcast [624 x i32]* %2 to i32**
%15 = call i32 @fread(i32** %14, i32 4, i32 624, i32* %7)
%16 = icmp eq i32 %15, 624
br i1 %16, label %21, label %17
17: ; preds = %13
%18 = load i32, i32* @stderr
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i64 2496, i8* %0)
%20 = tail call i32 @exit(i32 -1)
unreachable
21: ; preds = %13
%22 = tail call i64 @fclose(i32* %7)
%23 = icmp eq i64 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = load i32, i32* @stderr
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %27
27: ; preds = %24, %21
%28 = getelementptr inbounds [624 x i32], [624 x i32]* %2, i64 0, i64 0
%29 = call i32 @dsfmt_gv_init_by_array(i32* %28, i32 624)
%30 = load i32, i32* @stdout
%31 = call i32 @fflush(i32 %30)
%32 = load i32, i32* @stderr
%33 = call i32 @fputc(i8 signext 35, i32 %32)
%34 = load i32, i32* @stderr
%35 = call i8* (...) @dsfmt_get_idstring()
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* %35)
br label %38
37: ; preds = %38
ret void
38: ; preds = %27, %38
%39 = phi i64 [ 0, %27 ], [ %41, %38 ]
%40 = call i32 (...) @get_rand()
%41 = add nuw nsw i64 %39, 1
%42 = icmp eq i64 %41, 1000000
br i1 %42, label %37, label %38
}