#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 */
struct marker {
  int dummy;
};

/* Variables and functions */
unsigned int rand();
void randomise_order(unsigned n, struct marker **marray) {
  unsigned i, j;
  struct marker *mtmp = NULL;
  for (i = 0; i < n; i++) {
    j = rand() % n;
    (mtmp) = (marray[i]), (marray[i]) = (marray[j]), (marray[j]) = (mtmp);
  }
}


x86 assembly (clang, -O0):
<randomise_order>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    118b <randomise_order+0x7b>
mov    $0x0,%al
call   1030 <rand@plt>
xor    %edx,%edx
divl   -0x4(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    (%rax,%rcx,8),%rdx
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112e <randomise_order+0x1e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randomise_order>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
je     1155 <randomise_order+0x45>
mov    %rsi,%rbx
mov    %edi,%r15d
mov    %edi,%r14d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <rand@plt>
xor    %edx,%edx
div    %r15d
mov    (%rbx,%rbp,8),%rax
mov    (%rbx,%rdx,8),%rcx
mov    %rcx,(%rbx,%rbp,8)
mov    %rax,(%rbx,%rdx,8)
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1130 <randomise_order+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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