#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 mint_random_int(int /*<<< orphan*/, int);
void mint_random_permutation(int *perm, int n) {
  int i, j, m;
  for (i = n - 1; i > 0; i--) {
    j = mint_random_int(0, i + 1);
    m = perm[j];
    perm[j] = perm[i];
    perm[i] = m;
  }
}


x86 assembly (clang, -O0):
<mint_random_permutation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    1182 <mint_random_permutation+0x72>
mov    -0x10(%rbp),%esi
add    $0x1,%esi
xor    %edi,%edi
call   1030 <mint_random_int@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1128 <mint_random_permutation+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mint_random_permutation>:
push   %r15
push   %r14
push   %rbx
cmp    $0x2,%esi
jl     114b <mint_random_permutation+0x3b>
mov    %rdi,%r14
mov    %esi,%ebx
nop
lea    -0x1(%rbx),%r15
xor    %edi,%edi
mov    %ebx,%esi
call   1030 <mint_random_int@plt>
cltq
mov    (%r14,%rax,4),%ecx
mov    %r15d,%edx
mov    (%r14,%rdx,4),%esi
mov    %esi,(%r14,%rax,4)
mov    %ecx,(%r14,%rdx,4)
cmp    $0x2,%rbx
mov    %r15,%rbx
ja     1120 <mint_random_permutation+0x10>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @mint_random_permutation(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
%8 = load i32, i32* %4
%9 = sub nsw i32 %8, 1
store i32 %9, i32* %5
br label %10
10: ; preds = %36, %2
%11 = load i32, i32* %5
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %39
13: ; preds = %10
%14 = load i32, i32* %5
%15 = add nsw i32 %14, 1
%16 = call i32 @mint_random_int(i32 0, i32 %15)
store i32 %16, i32* %6
%17 = load i32*, i32** %3
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %20
store i32 %21, i32* %7
%22 = load i32*, i32** %3
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = load i32, i32* %25
%27 = load i32*, i32** %3
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
store i32 %26, i32* %30
%31 = load i32, i32* %7
%32 = load i32*, i32** %3
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
store i32 %31, i32* %35
br label %36
36: ; preds = %13
%37 = load i32, i32* %5
%38 = add nsw i32 %37, -1
store i32 %38, i32* %5
br label %10
39: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @mint_random_permutation(i32* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 1
br i1 %3, label %4, label %18
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ %5, %4 ], [ %8, %6 ]
%8 = add nsw i64 %7, -1
%9 = trunc i64 %7 to i32
%10 = tail call i32 @mint_random_int(i32 0, i32 %9)
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i32, i32* %0, i64 %11
%13 = load i32, i32* %12
%14 = and i64 %8, 4294967295
%15 = getelementptr inbounds i32, i32* %0, i64 %14
%16 = load i32, i32* %15
store i32 %16, i32* %12
store i32 %13, i32* %15
%17 = icmp ugt i64 %7, 2
br i1 %17, label %6, label %18
18: ; preds = %6, %2
ret void
}