#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 rand();
long randomSeed();
int /*<<< orphan*/ srand(long);
long time(int /*<<< orphan*/ *);
long randomLong() {
  long seeds[10];
  for (int i = 0; i < 10; i++) {
    seeds[i] = randomSeed();
  }
  srand(time(NULL));
  int seedIndex = rand() % 10;
  srand(seeds[seedIndex]);
  return (long)rand();
}


x86 assembly (clang, -O0):
<randomLong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x54(%rbp)
cmpl   $0xa,-0x54(%rbp)
jge    117a <randomLong+0x3a>
mov    $0x0,%al
call   1030 <randomSeed@plt>
mov    %rax,%rcx
movslq -0x54(%rbp),%rax
mov    %rcx,-0x50(%rbp,%rax,8)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    114f <randomLong+0xf>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %rax,%rdi
call   1040 <srand@plt>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x58(%rbp)
movslq -0x58(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rdi
call   1040 <srand@plt>
mov    $0x0,%al
call   1060 <rand@plt>
cltq
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randomLong>:
sub    $0x58,%rsp
xor    %eax,%eax
call   1030 <randomSeed@plt>
mov    %rax,(%rsp)
xor    %eax,%eax
call   1030 <randomSeed@plt>
mov    %rax,0x8(%rsp)
xor    %eax,%eax
call   1030 <randomSeed@plt>
mov    %rax,0x10(%rsp)
xor    %eax,%eax
call   1030 <randomSeed@plt>
mov    %rax,0x18(%rsp)
xor    %eax,%eax
call   1030 <randomSeed@plt>
mov    %rax,0x20(%rsp)
xor    %eax,%eax
call   1030 <randomSeed@plt>
mov    %rax,0x28(%rsp)
xor    %eax,%eax
call   1030 <randomSeed@plt>
mov    %rax,0x30(%rsp)
xor    %eax,%eax
call   1030 <randomSeed@plt>
mov    %rax,0x38(%rsp)
xor    %eax,%eax
call   1030 <randomSeed@plt>
mov    %rax,0x40(%rsp)
xor    %eax,%eax
call   1030 <randomSeed@plt>
mov    %rax,0x48(%rsp)
xor    %edi,%edi
call   1050 <time@plt>
mov    %rax,%rdi
call   1040 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
cltq
mov    (%rsp,%rax,8),%rdi
call   1040 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
cltq
add    $0x58,%rsp
ret

LLVM IR (-O0):
define i64 @randomLong() {
%1 = alloca [10 x i64]
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %2
br label %4
4: ; preds = %12, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 10
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = call i64 (...) @randomSeed()
%9 = load i32, i32* %2
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [10 x i64], [10 x i64]* %1, i64 0, i64 %10
store i64 %8, i64* %11
br label %12
12: ; preds = %7
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
store i32 %14, i32* %2
br label %4
15: ; preds = %4
%16 = call i64 @time(i32* null)
%17 = call i32 @srand(i64 %16)
%18 = call i32 (...) @rand()
%19 = srem i32 %18, 10
store i32 %19, i32* %3
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [10 x i64], [10 x i64]* %1, i64 0, i64 %21
%23 = load i64, i64* %22
%24 = call i32 @srand(i64 %23)
%25 = call i32 (...) @rand()
%26 = sext i32 %25 to i64
ret i64 %26
}

LLVM IR (-O2):
define i64 @randomLong() {
%1 = alloca [10 x i64]
%2 = bitcast [10 x i64]* %1 to i8*
%3 = tail call i64 (...) @randomSeed()
%4 = getelementptr inbounds [10 x i64], [10 x i64]* %1, i64 0, i64 0
store i64 %3, i64* %4
%5 = tail call i64 (...) @randomSeed()
%6 = getelementptr inbounds [10 x i64], [10 x i64]* %1, i64 0, i64 1
store i64 %5, i64* %6
%7 = tail call i64 (...) @randomSeed()
%8 = getelementptr inbounds [10 x i64], [10 x i64]* %1, i64 0, i64 2
store i64 %7, i64* %8
%9 = tail call i64 (...) @randomSeed()
%10 = getelementptr inbounds [10 x i64], [10 x i64]* %1, i64 0, i64 3
store i64 %9, i64* %10
%11 = tail call i64 (...) @randomSeed()
%12 = getelementptr inbounds [10 x i64], [10 x i64]* %1, i64 0, i64 4
store i64 %11, i64* %12
%13 = tail call i64 (...) @randomSeed()
%14 = getelementptr inbounds [10 x i64], [10 x i64]* %1, i64 0, i64 5
store i64 %13, i64* %14
%15 = tail call i64 (...) @randomSeed()
%16 = getelementptr inbounds [10 x i64], [10 x i64]* %1, i64 0, i64 6
store i64 %15, i64* %16
%17 = tail call i64 (...) @randomSeed()
%18 = getelementptr inbounds [10 x i64], [10 x i64]* %1, i64 0, i64 7
store i64 %17, i64* %18
%19 = tail call i64 (...) @randomSeed()
%20 = getelementptr inbounds [10 x i64], [10 x i64]* %1, i64 0, i64 8
store i64 %19, i64* %20
%21 = tail call i64 (...) @randomSeed()
%22 = getelementptr inbounds [10 x i64], [10 x i64]* %1, i64 0, i64 9
store i64 %21, i64* %22
%23 = tail call i64 @time(i32* null)
%24 = tail call i32 @srand(i64 %23)
%25 = tail call i32 (...) @rand()
%26 = srem i32 %25, 10
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [10 x i64], [10 x i64]* %1, i64 0, i64 %27
%29 = load i64, i64* %28
%30 = tail call i32 @srand(i64 %29)
%31 = tail call i32 (...) @rand()
%32 = sext i32 %31 to i64
ret i64 %32
}