#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 /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
void srt_init_array(int **array_tmp, int *size) {
  int i = 0;
  int tmp = 0;
  int *array = *array_tmp;
  printf("Enter the number of elements\n");
  scanf("%d", &tmp);
  printf("Size is %d\n", tmp);
  array = (int *)malloc(tmp * sizeof(int));
  for (i = 0; i < tmp; i++) {
    *(array + i) = rand() % 100;
  }
  *size = tmp;
  *array_tmp = array;
}


x86 assembly (clang, -O0):
<srt_init_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea0(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x18(%rbp),%esi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11e6 <srt_init_array+0xa6>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b2 <srt_init_array+0x72>
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<srt_init_array>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
movl   $0x0,0x4(%rsp)
lea    0xea2(%rip),%rdi
call   1030 <puts@plt>
lea    0xe87(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%esi
lea    0xe75(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%edi
shl    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,%r12
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    11e4 <srt_init_array+0x94>
xor    %ebx,%ebx
xchg   %ax,%ax
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,(%r12,%rbx,4)
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
cmp    %rax,%rbx
jl     11b0 <srt_init_array+0x60>
mov    %eax,(%r14)
mov    %r12,(%r15)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Enter the number of elements\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [12 x i8] c"Size is %d\0A\00"
define void @srt_init_array(i32** %0, i32* %1) {
%3 = alloca i32**
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
store i32** %0, i32*** %3
store i32* %1, i32** %4
store i32 0, i32* %5
store i32 0, i32* %6
%8 = load i32**, i32*** %3
%9 = load i32*, i32** %8
store i32* %9, i32** %7
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%12 = load i32, i32* %6
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = mul i64 %15, 4
%17 = trunc i64 %16 to i32
%18 = call i64 @malloc(i32 %17)
%19 = inttoptr i64 %18 to i32*
store i32* %19, i32** %7
store i32 0, i32* %5
br label %20
20: ; preds = %31, %2
%21 = load i32, i32* %5
%22 = load i32, i32* %6
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %34
24: ; preds = %20
%25 = call i32 (...) @rand()
%26 = srem i32 %25, 100
%27 = load i32*, i32** %7
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
store i32 %26, i32* %30
br label %31
31: ; preds = %24
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
br label %20
34: ; preds = %20
%35 = load i32, i32* %6
%36 = load i32*, i32** %4
store i32 %35, i32* %36
%37 = load i32*, i32** %7
%38 = load i32**, i32*** %3
store i32* %37, i32** %38
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [12 x i8] c"Size is %d\0A\00"
@str = [29 x i8] c"Enter the number of elements\00"
define void @srt_init_array(i32** nocapture writeonly %0, i32* nocapture writeonly %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = load i32, i32* %3
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %3
%10 = shl i32 %9, 2
%11 = call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to i32*
%13 = load i32, i32* %3
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %2, %15
%16 = phi i64 [ %20, %15 ], [ 0, %2 ]
%17 = call i32 (...) @rand()
%18 = srem i32 %17, 100
%19 = getelementptr inbounds i32, i32* %12, i64 %16
store i32 %18, i32* %19
%20 = add nuw nsw i64 %16, 1
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %20, %22
br i1 %23, label %15, label %24
24: ; preds = %15, %2
%25 = phi i32 [ %13, %2 ], [ %21, %15 ]
store i32 %25, i32* %1
store i32* %12, i32** %0
ret void
}