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

/* Variables and functions */
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int open(char *, int /*<<< orphan*/);
int read(int, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
void seedrand(char *seed) {
  char buf[16];
  int fd, i;
  fd = open("/dev/urandom", 0);
  if (fd == -1)
    exit(1);
  if (read(fd, buf, sizeof buf) != sizeof buf)
    exit(2);
  close(fd);
  for (i = 0; i < 16 - 1; i++) {
    if (buf[i] == 'n' || buf[i] == 's' || buf[i] == '$' || buf[i] == 'S' ||
        buf[i] == '\0')
      buf[i] = ' ';
  }
  buf[i] = 0;
  strcpy(seed, buf);
}


x86 assembly (clang, -O0):
<seedrand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe9d(%rip),%rdi
xor    %esi,%esi
call   1060 <open@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1181 <seedrand+0x31>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x24(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x10,%edx
call   1050 <read@plt>
cltq
cmp    $0x10,%rax
je     11a8 <seedrand+0x58>
mov    $0x2,%edi
call   1070 <exit@plt>
mov    -0x24(%rbp),%edi
call   1040 <close@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0xf,-0x28(%rbp)
jge    1237 <seedrand+0xe7>
movslq -0x28(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x6e,%eax
je     121b <seedrand+0xcb>
movslq -0x28(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x73,%eax
je     121b <seedrand+0xcb>
movslq -0x28(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x24,%eax
je     121b <seedrand+0xcb>
movslq -0x28(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x53,%eax
je     121b <seedrand+0xcb>
movslq -0x28(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x0,%eax
jne    1224 <seedrand+0xd4>
movslq -0x28(%rbp),%rax
movb   $0x20,-0x20(%rbp,%rax,1)
jmp    1229 <seedrand+0xd9>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11b7 <seedrand+0x67>
movslq -0x28(%rbp),%rax
movb   $0x0,-0x20(%rbp,%rax,1)
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seedrand>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
lea    0xea0(%rip),%rdi
xor    %esi,%esi
call   1060 <open@plt>
cmp    $0xffffffff,%eax
je     13bd <seedrand+0x26d>
mov    %eax,%ebp
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0x10,%edx
call   1050 <read@plt>
cmp    $0x10,%eax
jne    13c7 <seedrand+0x277>
mov    %ebp,%edi
call   1040 <close@plt>
mov    (%rsp),%cl
lea    -0x53(%rcx),%edx
movabs $0x108000001,%rax
cmp    $0x20,%dl
ja     11af <seedrand+0x5f>
movzbl %dl,%edx
bt     %rdx,%rax
jb     11b8 <seedrand+0x68>
cmp    $0x24,%cl
je     11b8 <seedrand+0x68>
test   %cl,%cl
jne    11bc <seedrand+0x6c>
movb   $0x20,(%rsp)
mov    0x1(%rsp),%cl
lea    -0x53(%rcx),%edx
cmp    $0x20,%dl
ja     11d1 <seedrand+0x81>
movzbl %dl,%edx
bt     %rdx,%rax
jb     11da <seedrand+0x8a>
cmp    $0x24,%cl
je     11da <seedrand+0x8a>
test   %cl,%cl
jne    11df <seedrand+0x8f>
movb   $0x20,0x1(%rsp)
mov    0x2(%rsp),%cl
lea    -0x53(%rcx),%edx
cmp    $0x20,%dl
ja     11f4 <seedrand+0xa4>
movzbl %dl,%edx
bt     %rdx,%rax
jb     11fd <seedrand+0xad>
cmp    $0x24,%cl
je     11fd <seedrand+0xad>
test   %cl,%cl
jne    1202 <seedrand+0xb2>
movb   $0x20,0x2(%rsp)
mov    0x3(%rsp),%cl
lea    -0x53(%rcx),%edx
cmp    $0x20,%dl
ja     1217 <seedrand+0xc7>
movzbl %dl,%edx
bt     %rdx,%rax
jb     1220 <seedrand+0xd0>
cmp    $0x24,%cl
je     1220 <seedrand+0xd0>
test   %cl,%cl
jne    1225 <seedrand+0xd5>
movb   $0x20,0x3(%rsp)
mov    0x4(%rsp),%cl
lea    -0x53(%rcx),%edx
cmp    $0x20,%dl
ja     123a <seedrand+0xea>
movzbl %dl,%edx
bt     %rdx,%rax
jb     1243 <seedrand+0xf3>
cmp    $0x24,%cl
je     1243 <seedrand+0xf3>
test   %cl,%cl
jne    1248 <seedrand+0xf8>
movb   $0x20,0x4(%rsp)
mov    0x5(%rsp),%cl
lea    -0x53(%rcx),%edx
cmp    $0x20,%dl
ja     125d <seedrand+0x10d>
movzbl %dl,%edx
bt     %rdx,%rax
jb     1266 <seedrand+0x116>
cmp    $0x24,%cl
je     1266 <seedrand+0x116>
test   %cl,%cl
jne    126b <seedrand+0x11b>
movb   $0x20,0x5(%rsp)
mov    0x6(%rsp),%cl
lea    -0x53(%rcx),%edx
cmp    $0x20,%dl
ja     1280 <seedrand+0x130>
movzbl %dl,%edx
bt     %rdx,%rax
jb     1289 <seedrand+0x139>
cmp    $0x24,%cl
je     1289 <seedrand+0x139>
test   %cl,%cl
jne    128e <seedrand+0x13e>
movb   $0x20,0x6(%rsp)
mov    0x7(%rsp),%cl
lea    -0x53(%rcx),%edx
cmp    $0x20,%dl
ja     12a3 <seedrand+0x153>
movzbl %dl,%edx
bt     %rdx,%rax
jb     12ac <seedrand+0x15c>
cmp    $0x24,%cl
je     12ac <seedrand+0x15c>
test   %cl,%cl
jne    12b1 <seedrand+0x161>
movb   $0x20,0x7(%rsp)
mov    0x8(%rsp),%cl
lea    -0x53(%rcx),%edx
cmp    $0x20,%dl
ja     12c6 <seedrand+0x176>
movzbl %dl,%edx
bt     %rdx,%rax
jb     12cf <seedrand+0x17f>
cmp    $0x24,%cl
je     12cf <seedrand+0x17f>
test   %cl,%cl
jne    12d4 <seedrand+0x184>
movb   $0x20,0x8(%rsp)
mov    0x9(%rsp),%cl
lea    -0x53(%rcx),%edx
cmp    $0x20,%dl
ja     12e9 <seedrand+0x199>
movzbl %dl,%edx
bt     %rdx,%rax
jb     12f2 <seedrand+0x1a2>
cmp    $0x24,%cl
je     12f2 <seedrand+0x1a2>
test   %cl,%cl
jne    12f7 <seedrand+0x1a7>
movb   $0x20,0x9(%rsp)
mov    0xa(%rsp),%cl
lea    -0x53(%rcx),%edx
cmp    $0x20,%dl
ja     130c <seedrand+0x1bc>
movzbl %dl,%edx
bt     %rdx,%rax
jb     1315 <seedrand+0x1c5>
cmp    $0x24,%cl
je     1315 <seedrand+0x1c5>
test   %cl,%cl
jne    131a <seedrand+0x1ca>
movb   $0x20,0xa(%rsp)
mov    0xb(%rsp),%cl
lea    -0x53(%rcx),%edx
cmp    $0x20,%dl
ja     132f <seedrand+0x1df>
movzbl %dl,%edx
bt     %rdx,%rax
jb     1338 <seedrand+0x1e8>
cmp    $0x24,%cl
je     1338 <seedrand+0x1e8>
test   %cl,%cl
jne    133d <seedrand+0x1ed>
movb   $0x20,0xb(%rsp)
mov    0xc(%rsp),%cl
lea    -0x53(%rcx),%edx
cmp    $0x20,%dl
ja     1352 <seedrand+0x202>
movzbl %dl,%edx
bt     %rdx,%rax
jb     135b <seedrand+0x20b>
cmp    $0x24,%cl
je     135b <seedrand+0x20b>
test   %cl,%cl
jne    1360 <seedrand+0x210>
movb   $0x20,0xc(%rsp)
mov    0xd(%rsp),%cl
lea    -0x53(%rcx),%edx
cmp    $0x20,%dl
ja     1375 <seedrand+0x225>
movzbl %dl,%edx
bt     %rdx,%rax
jb     137e <seedrand+0x22e>
cmp    $0x24,%cl
je     137e <seedrand+0x22e>
test   %cl,%cl
jne    1383 <seedrand+0x233>
movb   $0x20,0xd(%rsp)
mov    0xe(%rsp),%cl
lea    -0x53(%rcx),%edx
cmp    $0x20,%dl
ja     1398 <seedrand+0x248>
movzbl %dl,%edx
bt     %rdx,%rax
jb     13a1 <seedrand+0x251>
cmp    $0x24,%cl
je     13a1 <seedrand+0x251>
test   %cl,%cl
jne    13a6 <seedrand+0x256>
movb   $0x20,0xe(%rsp)
movb   $0x0,0xf(%rsp)
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret
mov    $0x1,%edi
call   1070 <exit@plt>
mov    $0x2,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"/dev/urandom\00"
define void @seedrand(i8* %0) {
%2 = alloca i8*
%3 = alloca [16 x i8]
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 0)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %1
%12 = load i32, i32* %4
%13 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%14 = call i32 @read(i32 %12, i8* %13, i32 16)
%15 = sext i32 %14 to i64
%16 = icmp ne i64 %15, 16
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = call i32 @exit(i32 2)
unreachable
19: ; preds = %11
%20 = load i32, i32* %4
%21 = call i32 @close(i32 %20)
store i32 0, i32* %5
br label %22
22: ; preds = %65, %19
%23 = load i32, i32* %5
%24 = icmp slt i32 %23, 15
br i1 %24, label %25, label %68
25: ; preds = %22
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 110
br i1 %31, label %60, label %32
32: ; preds = %25
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 115
br i1 %38, label %60, label %39
39: ; preds = %32
%40 = load i32, i32* %5
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 36
br i1 %45, label %60, label %46
46: ; preds = %39
%47 = load i32, i32* %5
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 %48
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 83
br i1 %52, label %60, label %53
53: ; preds = %46
%54 = load i32, i32* %5
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 %55
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %64
60: ; preds = %53, %46, %39, %32, %25
%61 = load i32, i32* %5
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 %62
store i8 32, i8* %63
br label %64
64: ; preds = %60, %53
br label %65
65: ; preds = %64
%66 = load i32, i32* %5
%67 = add nsw i32 %66, 1
store i32 %67, i32* %5
br label %22
68: ; preds = %22
%69 = load i32, i32* %5
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 %70
store i8 0, i8* %71
%72 = load i8*, i8** %2
%73 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%74 = call i32 @strcpy(i8* %72, i8* %73)
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"/dev/urandom\00"
define void @seedrand(i8* %0) {
%2 = alloca [16 x i8]
%3 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 0)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %1
%9 = call i32 @read(i32 %4, i8* %3, i32 16)
%10 = icmp eq i32 %9, 16
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = tail call i32 @exit(i32 2)
unreachable
13: ; preds = %8
%14 = tail call i32 @close(i32 %4)
%15 = load i8, i8* %3
switch i8 %15, label %17 [
i8 110, label %16
i8 115, label %16
i8 36, label %16
i8 83, label %16
i8 0, label %16
]
16: ; preds = %13, %13, %13, %13, %13
store i8 32, i8* %3
br label %17
17: ; preds = %13, %16
%18 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 1
%19 = load i8, i8* %18
switch i8 %19, label %21 [
i8 110, label %20
i8 115, label %20
i8 36, label %20
i8 83, label %20
i8 0, label %20
]
20: ; preds = %17, %17, %17, %17, %17
store i8 32, i8* %18
br label %21
21: ; preds = %20, %17
%22 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 2
%23 = load i8, i8* %22
switch i8 %23, label %25 [
i8 110, label %24
i8 115, label %24
i8 36, label %24
i8 83, label %24
i8 0, label %24
]
24: ; preds = %21, %21, %21, %21, %21
store i8 32, i8* %22
br label %25
25: ; preds = %24, %21
%26 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 3
%27 = load i8, i8* %26
switch i8 %27, label %29 [
i8 110, label %28
i8 115, label %28
i8 36, label %28
i8 83, label %28
i8 0, label %28
]
28: ; preds = %25, %25, %25, %25, %25
store i8 32, i8* %26
br label %29
29: ; preds = %28, %25
%30 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 4
%31 = load i8, i8* %30
switch i8 %31, label %33 [
i8 110, label %32
i8 115, label %32
i8 36, label %32
i8 83, label %32
i8 0, label %32
]
32: ; preds = %29, %29, %29, %29, %29
store i8 32, i8* %30
br label %33
33: ; preds = %32, %29
%34 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 5
%35 = load i8, i8* %34
switch i8 %35, label %37 [
i8 110, label %36
i8 115, label %36
i8 36, label %36
i8 83, label %36
i8 0, label %36
]
36: ; preds = %33, %33, %33, %33, %33
store i8 32, i8* %34
br label %37
37: ; preds = %36, %33
%38 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 6
%39 = load i8, i8* %38
switch i8 %39, label %41 [
i8 110, label %40
i8 115, label %40
i8 36, label %40
i8 83, label %40
i8 0, label %40
]
40: ; preds = %37, %37, %37, %37, %37
store i8 32, i8* %38
br label %41
41: ; preds = %40, %37
%42 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 7
%43 = load i8, i8* %42
switch i8 %43, label %45 [
i8 110, label %44
i8 115, label %44
i8 36, label %44
i8 83, label %44
i8 0, label %44
]
44: ; preds = %41, %41, %41, %41, %41
store i8 32, i8* %42
br label %45
45: ; preds = %44, %41
%46 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 8
%47 = load i8, i8* %46
switch i8 %47, label %49 [
i8 110, label %48
i8 115, label %48
i8 36, label %48
i8 83, label %48
i8 0, label %48
]
48: ; preds = %45, %45, %45, %45, %45
store i8 32, i8* %46
br label %49
49: ; preds = %48, %45
%50 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 9
%51 = load i8, i8* %50
switch i8 %51, label %53 [
i8 110, label %52
i8 115, label %52
i8 36, label %52
i8 83, label %52
i8 0, label %52
]
52: ; preds = %49, %49, %49, %49, %49
store i8 32, i8* %50
br label %53
53: ; preds = %52, %49
%54 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 10
%55 = load i8, i8* %54
switch i8 %55, label %57 [
i8 110, label %56
i8 115, label %56
i8 36, label %56
i8 83, label %56
i8 0, label %56
]
56: ; preds = %53, %53, %53, %53, %53
store i8 32, i8* %54
br label %57
57: ; preds = %56, %53
%58 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 11
%59 = load i8, i8* %58
switch i8 %59, label %61 [
i8 110, label %60
i8 115, label %60
i8 36, label %60
i8 83, label %60
i8 0, label %60
]
60: ; preds = %57, %57, %57, %57, %57
store i8 32, i8* %58
br label %61
61: ; preds = %60, %57
%62 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 12
%63 = load i8, i8* %62
switch i8 %63, label %65 [
i8 110, label %64
i8 115, label %64
i8 36, label %64
i8 83, label %64
i8 0, label %64
]
64: ; preds = %61, %61, %61, %61, %61
store i8 32, i8* %62
br label %65
65: ; preds = %64, %61
%66 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 13
%67 = load i8, i8* %66
switch i8 %67, label %69 [
i8 110, label %68
i8 115, label %68
i8 36, label %68
i8 83, label %68
i8 0, label %68
]
68: ; preds = %65, %65, %65, %65, %65
store i8 32, i8* %66
br label %69
69: ; preds = %68, %65
%70 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 14
%71 = load i8, i8* %70
switch i8 %71, label %73 [
i8 110, label %72
i8 115, label %72
i8 36, label %72
i8 83, label %72
i8 0, label %72
]
72: ; preds = %69, %69, %69, %69, %69
store i8 32, i8* %70
br label %73
73: ; preds = %72, %69
%74 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 15
store i8 0, i8* %74
%75 = call i32 @strcpy(i8* %0, i8* %3)
ret void
}