#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*/ swap(int *, int *);
void shuffleArray(int *arr, int num) {
  int ind1, ind2, ind3;
  for (ind1 = 0; ind1 < 1000; ind1++) {
    ind2 = rand() % num;
    ind3 = rand() % num;
    swap(&arr[ind2], &arr[ind3]);
  }
}


x86 assembly (clang, -O0):
<shuffleArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x3e8,-0x10(%rbp)
jge    1190 <shuffleArray+0x70>
mov    $0x0,%al
call   1040 <rand@plt>
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x14(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
call   1030 <swap@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1136 <shuffleArray+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shuffleArray>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%r15
mov    $0x3e8,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <rand@plt>
cltd
idiv   %r14d
mov    %edx,%ebp
xor    %eax,%eax
call   1040 <rand@plt>
cltd
idiv   %r14d
movslq %ebp,%rax
lea    (%r15,%rax,4),%rdi
movslq %edx,%rax
lea    (%r15,%rax,4),%rsi
call   1030 <swap@plt>
add    $0xffffffff,%ebx
jne    1140 <shuffleArray+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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