#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 prandOne(int, int *, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int prand(int nums, int max) {
  int r, x = 0;
  int numarr[13];
  srand(time(NULL));
  for (x = 0; x < nums; x++) {
    r = prandOne(max, numarr, nums);
    numarr[x] = r;
    printf("\x1B[37m"
           "\n %d"
           "\033[0m",
           r);
  }
  return 0;
}


x86 assembly (clang, -O0):
<prand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b2 <prand+0x72>
mov    -0x8(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    -0x4(%rbp),%edx
call   1060 <prandOne@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
movslq -0x10(%rbp),%rax
mov    %ecx,-0x50(%rbp,%rax,4)
mov    -0xc(%rbp),%esi
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116c <prand+0x2c>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prand>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %esi,%r12d
mov    %edi,%r13d
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
test   %r13d,%r13d
jle    11a4 <prand+0x64>
mov    %r13d,%ebx
xor    %ebp,%ebp
mov    %rsp,%r14
lea    0xe8a(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
mov    %r12d,%edi
mov    %r14,%rsi
mov    %r13d,%edx
call   1060 <prandOne@plt>
mov    %eax,(%rsp,%rbp,4)
mov    %r15,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1180 <prand+0x40>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [14 x i8] c"\1B[37m\0A %d\1B[0m\00"
define i32 @prand(i32 %0, i32 %1) {
%3 = alloca [13 x i32]
%4 = bitcast [13 x i32]* %3 to i8*
%5 = tail call i32 @time(i32* null)
%6 = tail call i32 @srand(i32 %5)
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %18
8: ; preds = %2
%9 = getelementptr inbounds [13 x i32], [13 x i32]* %3, i64 0, i64 0
%10 = zext i32 %0 to i64
br label %11
11: ; preds = %8, %11
%12 = phi i64 [ 0, %8 ], [ %16, %11 ]
%13 = call i32 @prandOne(i32 %1, i32* %9, i32 %0)
%14 = getelementptr inbounds [13 x i32], [13 x i32]* %3, i64 0, i64 %12
store i32 %13, i32* %14
%15 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %13)
%16 = add nuw nsw i64 %12, 1
%17 = icmp eq i64 %16, %10
br i1 %17, label %18, label %11
18: ; preds = %11, %2
ret i32 0
}