#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 _random_int_range(int, int, int);
scalar_t__ malloc(int);
int time(int /*<<< orphan*/ *);
int *random_int_range_array(int _min, int _max, int _count) {
  int last = time(NULL);
  int i = 0;
  int *array = (int *)malloc(_count * sizeof(int));
  if (!array)
    return NULL;
  for (; i < _count; i++)
    last = array[i] = _random_int_range(_min, _max, last);
  return array;
}


x86 assembly (clang, -O0):
<random_int_range_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1030 <time@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    117f <random_int_range_array+0x4f>
movq   $0x0,-0x8(%rbp)
jmp    11c2 <random_int_range_array+0x92>
jmp    1184 <random_int_range_array+0x54>
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ba <random_int_range_array+0x8a>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1050 <_random_int_range@plt>
mov    -0x28(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
mov    %eax,(%rcx,%rdx,4)
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1184 <random_int_range_array+0x54>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_int_range_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r12d
mov    %esi,%r14d
mov    %edi,%r15d
xor    %ebx,%ebx
xor    %edi,%edi
call   1030 <time@plt>
mov    %eax,%ebp
lea    0x0(,%r12,4),%edi
call   1040 <malloc@plt>
test   %rax,%rax
je     1190 <random_int_range_array+0x60>
mov    %rax,%r13
test   %r12d,%r12d
jle    118d <random_int_range_array+0x5d>
mov    %r12d,%r12d
xor    %ebx,%ebx
xchg   %ax,%ax
mov    %r15d,%edi
mov    %r14d,%esi
mov    %ebp,%edx
call   1050 <_random_int_range@plt>
mov    %eax,%ebp
mov    %eax,0x0(%r13,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1170 <random_int_range_array+0x40>
mov    %r13,%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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