#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*/ printf(char *, int, int);
int rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int *getRandom() {
  static int r[10];
  int i;
  srand((unsigned)time(NULL));
  for (i = 0; i < 10; ++i) {
    r[i] = rand();
    printf("r[%d] = %d\n", i, r[i]);
  }
  return r;
}


x86 assembly (clang, -O0):
<getRandom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    11ab <getRandom+0x6b>
mov    $0x0,%al
call   1060 <rand@plt>
mov    %eax,%edx
movslq -0x4(%rbp),%rcx
lea    0x2ed3(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    -0x4(%rbp),%esi
movslq -0x4(%rbp),%rcx
lea    0x2ec2(%rip),%rax
mov    (%rax,%rcx,4),%edx
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    115f <getRandom+0x1f>
lea    0x2e9e(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getRandom>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x2ef1(%rip)
lea    0x2eea(%rip),%r14
lea    0xe93(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x2ece(%rip)
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x2eb6(%rip)
mov    %rbx,%rdi
mov    $0x2,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x2e9e(%rip)
mov    %rbx,%rdi
mov    $0x3,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x2e86(%rip)
mov    %rbx,%rdi
mov    $0x4,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x2e6e(%rip)
mov    %rbx,%rdi
mov    $0x5,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x2e56(%rip)
mov    %rbx,%rdi
mov    $0x6,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x2e3e(%rip)
mov    %rbx,%rdi
mov    $0x7,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x2e26(%rip)
mov    %rbx,%rdi
mov    $0x8,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x2e0e(%rip)
mov    %rbx,%rdi
mov    $0x9,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@getRandom.r = internal global [10 x i32] zeroinitializer
@.str = [12 x i8] c"r[%d] = %d\0A\00"
define i32* @getRandom() {
%1 = alloca i32
%2 = call i64 @time(i32* null)
%3 = trunc i64 %2 to i32
%4 = call i32 @srand(i32 %3)
store i32 0, i32* %1
br label %5
5: ; preds = %19, %0
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 10
br i1 %7, label %8, label %22
8: ; preds = %5
%9 = call i32 (...) @rand()
%10 = load i32, i32* %1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [10 x i32], [10 x i32]* @getRandom.r, i64 0, i64 %11
store i32 %9, i32* %12
%13 = load i32, i32* %1
%14 = load i32, i32* %1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [10 x i32], [10 x i32]* @getRandom.r, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %17)
br label %19
19: ; preds = %8
%20 = load i32, i32* %1
%21 = add nsw i32 %20, 1
store i32 %21, i32* %1
br label %5
22: ; preds = %5
ret i32* getelementptr inbounds ([10 x i32], [10 x i32]* @getRandom.r, i64 0, i64 0)
}

LLVM IR (-O2):
@getRandom.r = internal global [10 x i32] zeroinitializer
@.str = [12 x i8] c"r[%d] = %d\0A\00"
define i32* @getRandom() {
%1 = tail call i64 @time(i32* null)
%2 = trunc i64 %1 to i32
%3 = tail call i32 @srand(i32 %2)
%4 = tail call i32 (...) @rand()
store i32 %4, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @getRandom.r, i64 0, i64 0)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 0, i32 %4)
%6 = tail call i32 (...) @rand()
store i32 %6, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @getRandom.r, i64 0, i64 1)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 1, i32 %6)
%8 = tail call i32 (...) @rand()
store i32 %8, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @getRandom.r, i64 0, i64 2)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 2, i32 %8)
%10 = tail call i32 (...) @rand()
store i32 %10, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @getRandom.r, i64 0, i64 3)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 3, i32 %10)
%12 = tail call i32 (...) @rand()
store i32 %12, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @getRandom.r, i64 0, i64 4)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 4, i32 %12)
%14 = tail call i32 (...) @rand()
store i32 %14, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @getRandom.r, i64 0, i64 5)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 5, i32 %14)
%16 = tail call i32 (...) @rand()
store i32 %16, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @getRandom.r, i64 0, i64 6)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 6, i32 %16)
%18 = tail call i32 (...) @rand()
store i32 %18, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @getRandom.r, i64 0, i64 7)
%19 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 7, i32 %18)
%20 = tail call i32 (...) @rand()
store i32 %20, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @getRandom.r, i64 0, i64 8)
%21 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 8, i32 %20)
%22 = tail call i32 (...) @rand()
store i32 %22, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @getRandom.r, i64 0, i64 9)
%23 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 9, i32 %22)
ret i32* getelementptr inbounds ([10 x i32], [10 x i32]* @getRandom.r, i64 0, i64 0)
}