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

/* Variables and functions */
int RAND_MAX;
int /*<<< orphan*/ generate_random(int *, int, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int, ...);
int main(int argc, char *argv[]) {
  uint32_t data[30];
  uint32_t i = 0;
  printf("%d\n", RAND_MAX);
  generate_random(data, 30, 0, 10);
  for (i = 0; i < 30; i++)
    printf("data[%d] = %d\n", i, data[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x94(%rbp)
mov    0x2e9e(%rip),%rax
mov    (%rax),%esi
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    $0x1e,%esi
xor    %edx,%edx
mov    $0xa,%ecx
call   1040 <generate_random@plt>
movl   $0x0,-0x94(%rbp)
cmpl   $0x1e,-0x94(%rbp)
jge    11bf <main+0x9f>
mov    -0x94(%rbp),%esi
movslq -0x94(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%edx
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    117c <main+0x5c>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x78,%rsp
mov    0x2eba(%rip),%rax
mov    (%rax),%esi
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rsp,%rdi
mov    $0x1e,%esi
xor    %edx,%edx
mov    $0xa,%ecx
call   1040 <generate_random@plt>
lea    0xea7(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%rsp,%rbx,4),%edx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    $0x1e,%rbx
jne    1160 <main+0x40>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@RAND_MAX = global i32 0
@.str.1 = [15 x i8] c"data[%d] = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [30 x i32]
%4 = bitcast [30 x i32]* %3 to i8*
%5 = load i32, i32* @RAND_MAX
%6 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 0
%8 = call i32 @generate_random(i32* %7, i32 30, i32 0, i32 10)
br label %9
9: ; preds = %2, %9
%10 = phi i64 [ 0, %2 ], [ %15, %9 ]
%11 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 %10
%12 = load i32, i32* %11
%13 = trunc i64 %10 to i32
%14 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 %12)
%15 = add nuw nsw i64 %10, 1
%16 = icmp eq i64 %15, 30
br i1 %16, label %17, label %9
17: ; preds = %9
ret i32 0
}