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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(unsigned int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ srand(unsigned int);
void VARZRandReseed() {
  FILE *infile;
  unsigned seed;
  infile = fopen("/dev/random", "rb");
  assert(infile);
  assert(fread(&seed, 1, sizeof(seed), infile) == 1);
  fclose(infile);
  srand(seed);
}


x86 assembly (clang, -O0):
<VARZRandReseed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
lea    0xea6(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rcx
lea    -0xc(%rbp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0xc(%rbp),%edi
call   1050 <srand@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<VARZRandReseed>:
push   %rbx
sub    $0x10,%rsp
lea    0xea4(%rip),%rdi
lea    0xea9(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
mov    %ebx,%edi
call   1060 <assert@plt>
lea    0xc(%rsp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0xc(%rsp),%edi
add    $0x10,%rsp
pop    %rbx
jmp    1050 <srand@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"/dev/random\00"
@.str.1 = [3 x i8] c"rb\00"
define void @VARZRandReseed() {
%1 = alloca i32*
%2 = alloca i32
%3 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %1
%4 = load i32*, i32** %1
%5 = ptrtoint i32* %4 to i32
%6 = call i32 @assert(i32 %5)
%7 = load i32*, i32** %1
%8 = call i32 @fread(i32* %2, i32 1, i32 4, i32* %7)
%9 = icmp eq i32 %8, 1
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load i32*, i32** %1
%13 = call i32 @fclose(i32* %12)
%14 = load i32, i32* %2
%15 = call i32 @srand(i32 %14)
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"/dev/random\00"
@.str.1 = [3 x i8] c"rb\00"
define void @VARZRandReseed() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%4 = ptrtoint i32* %3 to i64
%5 = trunc i64 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = call i32 @fread(i32* %1, i32 1, i32 4, i32* %3)
%8 = icmp eq i32 %7, 1
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = tail call i32 @fclose(i32* %3)
%12 = load i32, i32* %1
%13 = tail call i32 @srand(i32 %12)
ret void
}