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

/* Variables and functions */
int /*<<< orphan*/ *malloc(int);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, ...);
int rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
void *init_seed(char *seed) {
  uint32_t *digest;
  int tbuf[8];
  if (!(digest = malloc(sizeof(uint32_t) * 4))) {
    return (NULL);
  }
  if (!seed) {
    srand((unsigned int)time(NULL));
    for (int loop = 0; loop < 8; loop++)
      tbuf[loop] = rand();
    memcpy(digest, tbuf, 16);
  } else {
    memcpy(digest, seed, 16);
  }
  return ((void *)digest);
}


x86 assembly (clang, -O0):
<init_seed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x10,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1181 <init_seed+0x31>
movq   $0x0,-0x8(%rbp)
jmp    1201 <init_seed+0xb1>
cmpq   $0x0,-0x10(%rbp)
jne    11e5 <init_seed+0x95>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0x8,-0x44(%rbp)
jge    11cc <init_seed+0x7c>
mov    $0x0,%al
call   1070 <rand@plt>
mov    %eax,%ecx
movslq -0x44(%rbp),%rax
mov    %ecx,-0x40(%rbp,%rax,4)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11a3 <init_seed+0x53>
mov    -0x18(%rbp),%rdi
lea    -0x40(%rbp),%rsi
xor    %eax,%eax
mov    $0x10,%edx
call   1040 <memcpy@plt>
jmp    11f9 <init_seed+0xa9>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    $0x10,%edx
call   1040 <memcpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_seed>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%rbx
mov    $0x10,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     1179 <init_seed+0x29>
mov    %rax,%r14
test   %rbx,%rbx
je     117e <init_seed+0x2e>
mov    %r14,%rdi
mov    %rbx,%rsi
jmp    11e9 <init_seed+0x99>
xor    %r14d,%r14d
jmp    11f5 <init_seed+0xa5>
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,0x4(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,0x8(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,0xc(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,0x10(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,0x14(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,0x18(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,0x1c(%rsp)
mov    %rsp,%rsi
mov    %r14,%rdi
mov    $0x10,%edx
xor    %eax,%eax
call   1040 <memcpy@plt>
mov    %r14,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @init_seed(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [8 x i32]
%6 = alloca i32
store i8* %0, i8** %3
%7 = call i32* @malloc(i32 16)
store i32* %7, i32** %4
%8 = icmp ne i32* %7, null
br i1 %8, label %10, label %9
9: ; preds = %1
store i8* null, i8** %2
br label %39
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = icmp ne i8* %11, null
br i1 %12, label %32, label %13
13: ; preds = %10
%14 = call i64 @time(i32* null)
%15 = trunc i64 %14 to i32
%16 = call i32 @srand(i32 %15)
store i32 0, i32* %6
br label %17
17: ; preds = %25, %13
%18 = load i32, i32* %6
%19 = icmp slt i32 %18, 8
br i1 %19, label %20, label %28
20: ; preds = %17
%21 = call i32 (...) @rand()
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 %23
store i32 %21, i32* %24
br label %25
25: ; preds = %20
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %17
28: ; preds = %17
%29 = load i32*, i32** %4
%30 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 0
%31 = call i32 (i32*, ...) @memcpy(i32* %29, i32* %30, i32 16)
br label %36
32: ; preds = %10
%33 = load i32*, i32** %4
%34 = load i8*, i8** %3
%35 = call i32 (i32*, ...) @memcpy(i32* %33, i8* %34, i32 16)
br label %36
36: ; preds = %32, %28
%37 = load i32*, i32** %4
%38 = bitcast i32* %37 to i8*
store i8* %38, i8** %2
br label %39
39: ; preds = %36, %9
%40 = load i8*, i8** %2
ret i8* %40
}

LLVM IR (-O2):
define i8* @init_seed(i8* %0) {
%2 = alloca [8 x i32]
%3 = bitcast [8 x i32]* %2 to i8*
%4 = tail call i32* @malloc(i32 16)
%5 = icmp eq i32* %4, null
br i1 %5, label %33, label %6
6: ; preds = %1
%7 = icmp eq i8* %0, null
br i1 %7, label %8, label %29
8: ; preds = %6
%9 = tail call i64 @time(i32* null)
%10 = trunc i64 %9 to i32
%11 = tail call i32 @srand(i32 %10)
%12 = tail call i32 (...) @rand()
%13 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 0
store i32 %12, i32* %13
%14 = tail call i32 (...) @rand()
%15 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 1
store i32 %14, i32* %15
%16 = tail call i32 (...) @rand()
%17 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 2
store i32 %16, i32* %17
%18 = tail call i32 (...) @rand()
%19 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 3
store i32 %18, i32* %19
%20 = tail call i32 (...) @rand()
%21 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 4
store i32 %20, i32* %21
%22 = tail call i32 (...) @rand()
%23 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 5
store i32 %22, i32* %23
%24 = tail call i32 (...) @rand()
%25 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 6
store i32 %24, i32* %25
%26 = tail call i32 (...) @rand()
%27 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 7
store i32 %26, i32* %27
%28 = call i32 (i32*, ...) @memcpy(i32* %4, i32* %13, i32 16)
br label %31
29: ; preds = %6
%30 = tail call i32 (i32*, ...) @memcpy(i32* %4, i8* %0, i32 16)
br label %31
31: ; preds = %29, %8
%32 = bitcast i32* %4 to i8*
br label %33
33: ; preds = %1, %31
%34 = phi i8* [ %32, %31 ], [ null, %1 ]
ret i8* %34
}