#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 */
scalar_t__ malloc(int);
int rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/);
void make_array(int **a, int n) {
  int i;
  *a = (int *)malloc(sizeof(int) * n);
  srand((unsigned)time(0));
  for (i = 0; i < n; i++) {
    (*a)[i] = rand() % (8 * n);
  }
}


x86 assembly (clang, -O0):
<make_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b5 <make_array+0x75>
mov    $0x0,%al
call   1060 <rand@plt>
mov    -0xc(%rbp),%ecx
shl    $0x3,%ecx
cltd
idiv   %ecx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    117d <make_array+0x3d>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_array>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %rdi,%r14
lea    0x0(,%r15,4),%edi
call   1050 <malloc@plt>
mov    %rax,(%r14)
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
test   %r15d,%r15d
jle    119a <make_array+0x5a>
mov    %r15d,%r12d
shl    $0x3,%r15d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <rand@plt>
cltd
idiv   %r15d
mov    (%r14),%rax
mov    %edx,(%rax,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1180 <make_array+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @make_array(i32** %0, i32 %1) {
%3 = alloca i32**
%4 = alloca i32
%5 = alloca i32
store i32** %0, i32*** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = sext i32 %6 to i64
%8 = mul i64 4, %7
%9 = trunc i64 %8 to i32
%10 = call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i32*
%12 = load i32**, i32*** %3
store i32* %11, i32** %12
%13 = call i64 @time(i32 0)
%14 = trunc i64 %13 to i32
%15 = call i32 @srand(i32 %14)
store i32 0, i32* %5
br label %16
16: ; preds = %30, %2
%17 = load i32, i32* %5
%18 = load i32, i32* %4
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %33
20: ; preds = %16
%21 = call i32 (...) @rand()
%22 = load i32, i32* %4
%23 = mul nsw i32 8, %22
%24 = srem i32 %21, %23
%25 = load i32**, i32*** %3
%26 = load i32*, i32** %25
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %26, i64 %28
store i32 %24, i32* %29
br label %30
30: ; preds = %20
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %16
33: ; preds = %16
ret void
}

LLVM IR (-O2):
define void @make_array(i32** nocapture %0, i32 %1) {
%3 = shl i32 %1, 2
%4 = tail call i64 @malloc(i32 %3)
%5 = inttoptr i64 %4 to i32*
store i32* %5, i32** %0
%6 = tail call i64 @time(i32 0)
%7 = trunc i64 %6 to i32
%8 = tail call i32 @srand(i32 %7)
%9 = icmp sgt i32 %1, 0
br i1 %9, label %10, label %21
10: ; preds = %2
%11 = shl nsw i32 %1, 3
%12 = zext i32 %1 to i64
br label %13
13: ; preds = %10, %13
%14 = phi i64 [ 0, %10 ], [ %19, %13 ]
%15 = tail call i32 (...) @rand()
%16 = srem i32 %15, %11
%17 = load i32*, i32** %0
%18 = getelementptr inbounds i32, i32* %17, i64 %14
store i32 %16, i32* %18
%19 = add nuw nsw i64 %14, 1
%20 = icmp eq i64 %19, %12
br i1 %20, label %21, label %13
21: ; preds = %13, %2
ret void
}