#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 rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void generaArrayMonodimensionali(int array[], int grandezzaArray, int generaDa,
                                 int generaFino) {
  int contatorePosizioni = 0;
  srand(time(NULL));
  while (contatorePosizioni < grandezzaArray) {
    array[contatorePosizioni] = (generaDa + rand() % (generaFino - generaDa));
    contatorePosizioni++;
  }
  return;
}


x86 assembly (clang, -O0):
<generaArrayMonodimensionali>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119e <generaArrayMonodimensionali+0x6e>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
mov    -0x14(%rbp),%ecx
sub    -0x10(%rbp),%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    -0x1c(%rbp),%edx
add    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115c <generaArrayMonodimensionali+0x2c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generaArrayMonodimensionali>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r13d
mov    %edx,%r12d
mov    %esi,%r15d
mov    %rdi,%r14
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
test   %r15d,%r15d
jle    118b <generaArrayMonodimensionali+0x5b>
sub    %r12d,%r13d
mov    %r15d,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <rand@plt>
cltd
idiv   %r13d
add    %r12d,%edx
mov    %edx,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1170 <generaArrayMonodimensionali+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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