#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(unsigned long *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ init_by_array(unsigned long *, int);
void init_rng() {
  unsigned long seeds[16];
  FILE *fp;
  fp = fopen("/dev/urandom", "r");
  if (fp) {
    fread(seeds, sizeof(unsigned long), 16, fp);
    fclose(fp);
  }
  init_by_array(seeds, 16);
}


x86 assembly (clang, -O0):
<init_rng>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
lea    0xeae(%rip),%rdi
lea    0xeb4(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
je     1199 <init_rng+0x59>
lea    -0x80(%rbp),%rdi
mov    -0x88(%rbp),%rcx
mov    $0x8,%esi
mov    $0x10,%edx
call   1030 <fread@plt>
mov    -0x88(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x80(%rbp),%rdi
mov    $0x10,%esi
call   1050 <init_by_array@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_rng>:
push   %rbx
sub    $0x80,%rsp
lea    0xeb1(%rip),%rdi
lea    0xeb7(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1180 <init_rng+0x40>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x8,%esi
mov    $0x10,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %rsp,%rdi
mov    $0x10,%esi
call   1050 <init_by_array@plt>
add    $0x80,%rsp
pop    %rbx
ret

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

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