#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 *genRandom() {
  static int r[10];
  int i;
  for (i = 0; i < 10; i++) {
    r[i] = rand();
    printf("r[%d] = %d\n", i, r[i]);
  }
  return r;
}


x86 assembly (clang, -O0):
<genRandom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    117b <genRandom+0x5b>
mov    $0x0,%al
call   1040 <rand@plt>
mov    %eax,%edx
movslq -0x4(%rbp),%rcx
lea    0x2ef3(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    -0x4(%rbp),%esi
movslq -0x4(%rbp),%rcx
lea    0x2ee2(%rip),%rax
mov    (%rax,%rcx,4),%edx
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    112f <genRandom+0xf>
lea    0x2ebe(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genRandom>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,0x2f0f(%rip)
lea    0x2f08(%rip),%r14
lea    0xec1(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,0x2eec(%rip)
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,0x2ed4(%rip)
mov    %rbx,%rdi
mov    $0x2,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,0x2ebc(%rip)
mov    %rbx,%rdi
mov    $0x3,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,0x2ea4(%rip)
mov    %rbx,%rdi
mov    $0x4,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,0x2e8c(%rip)
mov    %rbx,%rdi
mov    $0x5,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,0x2e74(%rip)
mov    %rbx,%rdi
mov    $0x6,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,0x2e5c(%rip)
mov    %rbx,%rdi
mov    $0x7,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,0x2e44(%rip)
mov    %rbx,%rdi
mov    $0x8,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,0x2e2c(%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):
@genRandom.r = internal global [10 x i32] zeroinitializer
@.str = [12 x i8] c"r[%d] = %d\0A\00"
define i32* @genRandom() {
%1 = alloca i32
store i32 0, i32* %1
br label %2
2: ; preds = %16, %0
%3 = load i32, i32* %1
%4 = icmp slt i32 %3, 10
br i1 %4, label %5, label %19
5: ; preds = %2
%6 = call i32 (...) @rand()
%7 = load i32, i32* %1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [10 x i32], [10 x i32]* @genRandom.r, i64 0, i64 %8
store i32 %6, i32* %9
%10 = load i32, i32* %1
%11 = load i32, i32* %1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [10 x i32], [10 x i32]* @genRandom.r, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %14)
br label %16
16: ; preds = %5
%17 = load i32, i32* %1
%18 = add nsw i32 %17, 1
store i32 %18, i32* %1
br label %2
19: ; preds = %2
ret i32* getelementptr inbounds ([10 x i32], [10 x i32]* @genRandom.r, i64 0, i64 0)
}

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