#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 */
size_t rand();
void shuffle(void **nodes, size_t n_memb) {
  unsigned int i, j;
  void *t;
  for (i = 0; i < n_memb; ++i) {
    j = rand() % n_memb;
    t = nodes[j];
    nodes[j] = nodes[i];
    nodes[i] = t;
  }
}


x86 assembly (clang, -O0):
<shuffle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%rax
jae    118a <shuffle+0x7a>
mov    $0x0,%al
call   1030 <rand@plt>
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x10(%rbp)
mov    %edx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,8),%rdx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <shuffle+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shuffle>:
push   %r15
push   %r14
push   %rbx
test   %rsi,%rsi
je     1169 <shuffle+0x59>
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
jmp    114f <shuffle+0x3f>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %edx,%edx
div    %r14
mov    %edx,%eax
mov    (%r15,%rax,8),%rcx
mov    (%r15,%rbx,8),%rdx
mov    %rdx,(%r15,%rax,8)
mov    %rcx,(%r15,%rbx,8)
add    $0x1,%ebx
cmp    %r14,%rbx
jae    1169 <shuffle+0x59>
xor    %eax,%eax
call   1030 <rand@plt>
mov    %rax,%rcx
or     %r14,%rcx
shr    $0x20,%rcx
jne    1130 <shuffle+0x20>
xor    %edx,%edx
div    %r14d
jmp    1135 <shuffle+0x25>
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @shuffle(i8** nocapture %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %16, label %4
4: ; preds = %2, %4
%5 = phi i64 [ %14, %4 ], [ 0, %2 ]
%6 = tail call i64 (...) @rand()
%7 = urem i64 %6, %1
%8 = and i64 %7, 4294967295
%9 = getelementptr inbounds i8*, i8** %0, i64 %8
%10 = load i8*, i8** %9
%11 = getelementptr inbounds i8*, i8** %0, i64 %5
%12 = load i8*, i8** %11
store i8* %12, i8** %9
store i8* %10, i8** %11
%13 = add nuw nsw i64 %5, 1
%14 = and i64 %13, 4294967295
%15 = icmp ult i64 %14, %1
br i1 %15, label %4, label %16
16: ; preds = %4, %2
ret void
}