#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*/ randValue;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
size_t fread(int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ srand(int);
int time(int /*<<< orphan*/ *);
void randInitializer(void) {
  FILE *f;
  size_t bytes_read = 0;
  f = fopen("/dev/urandom", "r");
  if (f) {
    int randValue;
    bytes_read = fread(&randValue, sizeof(randValue), 1, f);
    fclose(f);
    if (bytes_read)
      srand(randValue);
    else
      srand(time(NULL));
  } else
    srand(time(NULL));
}


x86 assembly (clang, -O0):
<randInitializer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x10(%rbp)
lea    0xe99(%rip),%rdi
lea    0xe9f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11d3 <randInitializer+0x83>
mov    -0x8(%rbp),%rcx
lea    -0x14(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
cmpq   $0x0,-0x10(%rbp)
je     11be <randInitializer+0x6e>
mov    -0x14(%rbp),%edi
call   1050 <srand@plt>
jmp    11ce <randInitializer+0x7e>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
jmp    11e3 <randInitializer+0x93>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randInitializer>:
push   %r14
push   %rbx
push   %rax
lea    0xea5(%rip),%rdi
lea    0xeab(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     119c <randInitializer+0x4c>
mov    %rax,%rbx
lea    0x4(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <fclose@plt>
test   %r14,%r14
je     119c <randInitializer+0x4c>
mov    0x4(%rsp),%edi
jmp    11a5 <randInitializer+0x55>
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <srand@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"/dev/urandom\00"
@.str.1 = [2 x i8] c"r\00"
define void @randInitializer() {
%1 = alloca i32*
%2 = alloca i64
%3 = alloca i32
store i64 0, i64* %2
%4 = 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* %4, i32** %1
%5 = load i32*, i32** %1
%6 = icmp ne i32* %5, null
br i1 %6, label %7, label %21
7: ; preds = %0
%8 = load i32*, i32** %1
%9 = call i64 @fread(i32* %3, i32 4, i32 1, i32* %8)
store i64 %9, i64* %2
%10 = load i32*, i32** %1
%11 = call i32 @fclose(i32* %10)
%12 = load i64, i64* %2
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %7
%15 = load i32, i32* %3
%16 = call i32 @srand(i32 %15)
br label %20
17: ; preds = %7
%18 = call i32 @time(i32* null)
%19 = call i32 @srand(i32 %18)
br label %20
20: ; preds = %17, %14
br label %24
21: ; preds = %0
%22 = call i32 @time(i32* null)
%23 = call i32 @srand(i32 %22)
br label %24
24: ; preds = %21, %20
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"/dev/urandom\00"
@.str.1 = [2 x i8] c"r\00"
define void @randInitializer() {
%1 = alloca i32
%2 = 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))
%3 = icmp eq i32* %2, null
br i1 %3, label %16, label %4
4: ; preds = %0
%5 = bitcast i32* %1 to i8*
%6 = call i64 @fread(i32* %1, i32 4, i32 1, i32* %2)
%7 = tail call i32 @fclose(i32* %2)
%8 = icmp eq i64 %6, 0
br i1 %8, label %11, label %9
9: ; preds = %4
%10 = load i32, i32* %1
br label %13
11: ; preds = %4
%12 = tail call i32 @time(i32* null)
br label %13
13: ; preds = %11, %9
%14 = phi i32 [ %12, %11 ], [ %10, %9 ]
%15 = tail call i32 @srand(i32 %14)
br label %19
16: ; preds = %0
%17 = tail call i32 @time(i32* null)
%18 = tail call i32 @srand(i32 %17)
br label %19
19: ; preds = %16, %13
ret void
}