#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 random();
void gt_rbtree_permuteintarray(unsigned long *arr) {
  unsigned long i, j, c;
  for (i = 0; i < (unsigned long)100; ++i) {
    j = (unsigned long)(random() % 100);
    c = arr[i];
    arr[i] = arr[j];
    arr[j] = c;
  }
}


x86 assembly (clang, -O0):
<gt_rbtree_permuteintarray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
cmpq   $0x64,-0x10(%rbp)
jae    118e <gt_rbtree_permuteintarray+0x7e>
mov    $0x0,%al
call   1030 <random@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1124 <gt_rbtree_permuteintarray+0x14>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gt_rbtree_permuteintarray>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <random@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
cltq
mov    (%r14,%rbx,8),%rcx
mov    (%r14,%rax,8),%rdx
mov    %rdx,(%r14,%rbx,8)
mov    %rcx,(%r14,%rax,8)
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1120 <gt_rbtree_permuteintarray+0x10>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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