#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 randNormalize();
void randomiceArray(int arrayInicial[], int dim) {
  int j, randNum1, randNum2, oldElement;
  for (j = 0; j < (dim * 3); j++) {
    randNum1 = (int)(randNormalize() * (dim));
    randNum2 = (int)(randNormalize() * (dim));
    oldElement = arrayInicial[randNum2];
    arrayInicial[randNum2] = arrayInicial[randNum1];
    arrayInicial[randNum1] = oldElement;
  }
}


x86 assembly (clang, -O0):
<randomiceArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
imul   $0x3,-0xc(%rbp),%ecx
cmp    %ecx,%eax
jge    1191 <randomiceArray+0x81>
mov    $0x0,%al
call   1030 <randNormalize@plt>
imul   -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1030 <randNormalize@plt>
imul   -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <randomiceArray+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randomiceArray>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
jle    1162 <randomiceArray+0x52>
mov    %esi,%r14d
mov    %rdi,%r15
lea    (%r14,%r14,2),%eax
cmp    $0x2,%eax
mov    $0x1,%ebx
cmovge %eax,%ebx
xor    %eax,%eax
call   1030 <randNormalize@plt>
mov    %eax,%ebp
imul   %r14d,%ebp
xor    %eax,%eax
call   1030 <randNormalize@plt>
imul   %r14d,%eax
cltq
mov    (%r15,%rax,4),%ecx
movslq %ebp,%rdx
mov    (%r15,%rdx,4),%esi
mov    %esi,(%r15,%rax,4)
mov    %ecx,(%r15,%rdx,4)
add    $0xffffffff,%ebx
jne    1130 <randomiceArray+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @randomiceArray(i32* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %21
4: ; preds = %2
%5 = mul i32 %1, 3
%6 = call i32 @llvm.smax.i32(i32 %5, i32 1)
br label %7
7: ; preds = %4, %7
%8 = phi i32 [ %19, %7 ], [ 0, %4 ]
%9 = tail call i32 (...) @randNormalize()
%10 = mul nsw i32 %9, %1
%11 = tail call i32 (...) @randNormalize()
%12 = mul nsw i32 %11, %1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %0, i64 %13
%15 = load i32, i32* %14
%16 = sext i32 %10 to i64
%17 = getelementptr inbounds i32, i32* %0, i64 %16
%18 = load i32, i32* %17
store i32 %18, i32* %14
store i32 %15, i32* %17
%19 = add nuw nsw i32 %8, 1
%20 = icmp eq i32 %19, %6
br i1 %20, label %21, label %7
21: ; preds = %7, %2
ret void
}