#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 atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(int *, int, int, int /*<<< orphan*/ *);
int time(int /*<<< orphan*/ *);
int acquire_seed(char *seed_from_argument) {
  int seed;
  FILE *dev_random;
  if (seed_from_argument != NULL) {
    seed = atoi(seed_from_argument);
  } else if ((dev_random = fopen("/dev/random", "rb")) != NULL) {
    fread(&seed, sizeof(seed), 1, dev_random);
    fclose(dev_random);
  } else {
    seed = time(NULL);
  }
  return seed;
}


x86 assembly (clang, -O0):
<acquire_seed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1178 <acquire_seed+0x28>
mov    -0x8(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0xc(%rbp)
jmp    11cf <acquire_seed+0x7f>
lea    0xe81(%rip),%rdi
lea    0xe86(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11be <acquire_seed+0x6e>
mov    -0x18(%rbp),%rcx
lea    -0xc(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
jmp    11ca <acquire_seed+0x7a>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0xc(%rbp)
jmp    11cf <acquire_seed+0x7f>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<acquire_seed>:
push   %rbx
sub    $0x10,%rsp
test   %rdi,%rdi
je     1164 <acquire_seed+0x14>
add    $0x10,%rsp
pop    %rbx
jmp    1070 <atoi@plt>
lea    0xe95(%rip),%rdi
lea    0xe9a(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11a8 <acquire_seed+0x58>
mov    %rax,%rbx
lea    0xc(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
ret
xor    %edi,%edi
add    $0x10,%rsp
pop    %rbx
jmp    1050 <time@plt>

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

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