#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 /*<<< orphan*/ time_t;

/* Variables and functions */
scalar_t__ malloc(int);
int rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int *initializeRandomizedBuffer(int bufferSize, int range) {
  time_t t;
  srand((unsigned)time(&t));
  int *buffer = (int *)malloc(sizeof(int) * bufferSize);
  for (int i = 0; i < bufferSize; ++i)
    buffer[i] = rand() % range;
  return buffer;
}


x86 assembly (clang, -O0):
<initializeRandomizedBuffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0xc(%rbp),%rdi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a8 <initializeRandomizedBuffer+0x68>
mov    $0x0,%al
call   1060 <rand@plt>
cltd
idivl  -0x8(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1178 <initializeRandomizedBuffer+0x38>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initializeRandomizedBuffer>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r15d
mov    %edi,%r14d
lea    0xc(%rsp),%rdi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
lea    0x0(,%r14,4),%edi
call   1050 <malloc@plt>
mov    %rax,%r12
test   %r14d,%r14d
jle    1198 <initializeRandomizedBuffer+0x58>
mov    %r14d,%ebp
xor    %ebx,%ebx
nopl   (%rax)
xor    %eax,%eax
call   1060 <rand@plt>
cltd
idiv   %r15d
mov    %edx,(%r12,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1180 <initializeRandomizedBuffer+0x40>
mov    %r12,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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