#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_int(int);
int /*<<< orphan*/ swap_uint(unsigned int *, unsigned int *);
void randomize_uivector(unsigned int *v, int n) {
  int rpos = 0;
  for (int i = 0; i < n; i++) {
    rpos = random_int(n - 1);
    swap_uint(&v[rpos], &v[i]);
  }
}


x86 assembly (clang, -O0):
<randomize_uivector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1188 <randomize_uivector+0x68>
mov    -0xc(%rbp),%edi
sub    $0x1,%edi
call   1040 <random_int@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
call   1030 <swap_uint@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113d <randomize_uivector+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randomize_uivector>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
jle    1160 <randomize_uivector+0x40>
mov    %esi,%r15d
mov    %rdi,%r14
mov    %esi,%ebp
add    $0xffffffff,%r15d
mov    %rdi,%rbx
nopw   0x0(%rax,%rax,1)
mov    %r15d,%edi
call   1040 <random_int@plt>
cltq
lea    (%r14,%rax,4),%rdi
mov    %rbx,%rsi
call   1030 <swap_uint@plt>
add    $0x4,%rbx
add    $0xffffffffffffffff,%rbp
jne    1140 <randomize_uivector+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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