#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 */
unsigned long devrandomseed();
int /*<<< orphan*/ printf(char *, unsigned long);
int /*<<< orphan*/ sgenrand(unsigned long);
unsigned long longinitmyrand(unsigned long *inseed) {
  unsigned long seed;
  if (inseed == NULL) {
    seed = devrandomseed();
    printf("in initmyrand, seed is %ld", (long int)seed);
    printf("(%lu)\n", (unsigned long int)seed);
  } else {
    seed = *inseed;
  }
  sgenrand(seed);
  return seed;
}


x86 assembly (clang, -O0):
<longinitmyrand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1177 <longinitmyrand+0x47>
mov    $0x0,%al
call   1050 <devrandomseed@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
jmp    1182 <longinitmyrand+0x52>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <sgenrand@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<longinitmyrand>:
push   %rbx
test   %rdi,%rdi
je     113b <longinitmyrand+0xb>
mov    (%rdi),%rbx
jmp    1163 <longinitmyrand+0x33>
xor    %eax,%eax
call   1050 <devrandomseed@plt>
mov    %rax,%rbx
lea    0xeb4(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <sgenrand@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"in initmyrand, seed is %ld\00"
@.str.1 = [7 x i8] c"(%lu)\0A\00"
define i64 @longinitmyrand(i64* %0) {
%2 = alloca i64*
%3 = alloca i64
store i64* %0, i64** %2
%4 = load i64*, i64** %2
%5 = icmp eq i64* %4, null
br i1 %5, label %6, label %12
6: ; preds = %1
%7 = call i64 (...) @devrandomseed()
store i64 %7, i64* %3
%8 = load i64, i64* %3
%9 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i64 %8)
%10 = load i64, i64* %3
%11 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 %10)
br label %15
12: ; preds = %1
%13 = load i64*, i64** %2
%14 = load i64, i64* %13
store i64 %14, i64* %3
br label %15
15: ; preds = %12, %6
%16 = load i64, i64* %3
%17 = call i32 @sgenrand(i64 %16)
%18 = load i64, i64* %3
ret i64 %18
}

LLVM IR (-O2):
@.str = [27 x i8] c"in initmyrand, seed is %ld\00"
@.str.1 = [7 x i8] c"(%lu)\0A\00"
define i64 @longinitmyrand(i64* %0) {
%2 = icmp eq i64* %0, null
br i1 %2, label %3, label %7
3: ; preds = %1
%4 = tail call i64 (...) @devrandomseed()
%5 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i64 %4)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 %4)
br label %9
7: ; preds = %1
%8 = load i64, i64* %0
br label %9
9: ; preds = %7, %3
%10 = phi i64 [ %4, %3 ], [ %8, %7 ]
%11 = tail call i32 @sgenrand(i64 %10)
ret i64 %10
}