#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 size_t uint;

/* Variables and functions */
int random();
int *fillArrayI_rand(int *arr, uint sz, int lo, int hi) {
  for (uint i = 0; i < sz; ++i) {
    arr[i] = lo + random() % (hi - lo);
  }
  return arr;
}


x86 assembly (clang, -O0):
<fillArrayI_rand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1175 <fillArrayI_rand+0x65>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    $0x0,%al
call   1030 <random@plt>
mov    -0x18(%rbp),%ecx
sub    -0x14(%rbp),%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    -0x24(%rbp),%edx
add    %eax,%edx
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    112e <fillArrayI_rand+0x1e>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fillArrayI_rand>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r12
test   %rsi,%rsi
je     114b <fillArrayI_rand+0x3b>
mov    %ecx,%r15d
mov    %edx,%r14d
mov    %rsi,%rbx
sub    %edx,%r15d
xor    %ebp,%ebp
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <random@plt>
cltd
idiv   %r15d
add    %r14d,%edx
mov    %edx,(%r12,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1130 <fillArrayI_rand+0x20>
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32* @fillArrayI_rand(i32* %0, i64 %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
store i32* %0, i32** %5
store i64 %1, i64* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i64 0, i64* %9
br label %10
10: ; preds = %25, %4
%11 = load i64, i64* %9
%12 = load i64, i64* %6
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %28
14: ; preds = %10
%15 = load i32, i32* %7
%16 = call i32 (...) @random()
%17 = load i32, i32* %8
%18 = load i32, i32* %7
%19 = sub nsw i32 %17, %18
%20 = srem i32 %16, %19
%21 = add nsw i32 %15, %20
%22 = load i32*, i32** %5
%23 = load i64, i64* %9
%24 = getelementptr inbounds i32, i32* %22, i64 %23
store i32 %21, i32* %24
br label %25
25: ; preds = %14
%26 = load i64, i64* %9
%27 = add i64 %26, 1
store i64 %27, i64* %9
br label %10
28: ; preds = %10
%29 = load i32*, i32** %5
ret i32* %29
}

LLVM IR (-O2):
define i32* @fillArrayI_rand(i32* returned writeonly %0, i64 %1, i32 %2, i32 %3) {
%5 = icmp eq i64 %1, 0
br i1 %5, label %8, label %6
6: ; preds = %4
%7 = sub nsw i32 %3, %2
br label %9
8: ; preds = %9, %4
ret i32* %0
9: ; preds = %6, %9
%10 = phi i64 [ 0, %6 ], [ %15, %9 ]
%11 = tail call i32 (...) @random()
%12 = srem i32 %11, %7
%13 = add nsw i32 %12, %2
%14 = getelementptr inbounds i32, i32* %0, i64 %10
store i32 %13, i32* %14
%15 = add nuw i64 %10, 1
%16 = icmp eq i64 %15, %1
br i1 %16, label %8, label %9
}