#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 scalar_t__ time_t;
typedef int /*<<< orphan*/ now;

/* Variables and functions */
scalar_t__ ENOENT;
int /*<<< orphan*/ F_OK;
int /*<<< orphan*/ RAND_seed(scalar_t__ *, int);
int /*<<< orphan*/ RAND_status();
scalar_t__ access(char *, int /*<<< orphan*/);
scalar_t__ getpid();
scalar_t__ time(int /*<<< orphan*/ *);
int seed_prng_init(void) {
  if (access("/dev/urandom", F_OK) != ENOENT) {
  } else {
    time_t now = time(NULL) + getpid();
    RAND_seed(&now, sizeof(now));
  }
  if (!RAND_status()) {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<seed_prng_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2e71(%rip),%rax
mov    (%rax),%esi
lea    0xe98(%rip),%rdi
call   1070 <access@plt>
mov    0x2e64(%rip),%rcx
cmp    (%rcx),%rax
je     1182 <seed_prng_init+0x32>
jmp    11b2 <seed_prng_init+0x62>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1050 <getpid@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
mov    $0x8,%esi
call   1040 <RAND_seed@plt>
mov    $0x0,%al
call   1030 <RAND_status@plt>
cmp    $0x0,%eax
jne    11ce <seed_prng_init+0x7e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d5 <seed_prng_init+0x85>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seed_prng_init>:
push   %rbx
sub    $0x10,%rsp
mov    0x2e74(%rip),%rax
mov    (%rax),%esi
lea    0xe9b(%rip),%rdi
call   1070 <access@plt>
mov    0x2e67(%rip),%rcx
cmp    (%rcx),%rax
jne    119e <seed_prng_init+0x4e>
xor    %edi,%edi
call   1060 <time@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1050 <getpid@plt>
add    %rbx,%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
mov    $0x8,%esi
call   1040 <RAND_seed@plt>
xor    %eax,%eax
call   1030 <RAND_status@plt>
cmp    $0x1,%eax
sbb    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"/dev/urandom\00"
@F_OK = global i32 0
@ENOENT = global i64 0
define i32 @seed_prng_init() {
%1 = alloca i32
%2 = alloca i64
%3 = load i32, i32* @F_OK
%4 = call i64 @access(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = load i64, i64* @ENOENT
%6 = icmp ne i64 %4, %5
br i1 %6, label %7, label %8
7: ; preds = %0
br label %13
8: ; preds = %0
%9 = call i64 @time(i32* null)
%10 = call i64 (...) @getpid()
%11 = add nsw i64 %9, %10
store i64 %11, i64* %2
%12 = call i32 @RAND_seed(i64* %2, i32 8)
br label %13
13: ; preds = %8, %7
%14 = call i32 (...) @RAND_status()
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %13
store i32 -1, i32* %1
br label %18
17: ; preds = %13
store i32 0, i32* %1
br label %18
18: ; preds = %17, %16
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@.str = [13 x i8] c"/dev/urandom\00"
@F_OK = global i32 0
@ENOENT = global i64 0
define i32 @seed_prng_init() {
%1 = alloca i64
%2 = load i32, i32* @F_OK
%3 = tail call i64 @access(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = load i64, i64* @ENOENT
%5 = icmp eq i64 %3, %4
br i1 %5, label %6, label %12
6: ; preds = %0
%7 = bitcast i64* %1 to i8*
%8 = tail call i64 @time(i32* null)
%9 = tail call i64 (...) @getpid()
%10 = add nsw i64 %9, %8
store i64 %10, i64* %1
%11 = call i32 @RAND_seed(i64* %1, i32 8)
br label %12
12: ; preds = %0, %6
%13 = call i32 (...) @RAND_status()
%14 = icmp eq i32 %13, 0
%15 = sext i1 %14 to i32
ret i32 %15
}