#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 randto(size_t);
void shuffle_signed(signed *x, size_t n) {
  while (--n) {
    size_t j = randto(n + 1);
    signed tmp = x[n];
    x[n] = x[j];
    x[j] = tmp;
  }
}


x86 assembly (clang, -O0):
<shuffle_signed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     117e <shuffle_signed+0x6e>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1030 <randto@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    1120 <shuffle_signed+0x10>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shuffle_signed>:
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%rsi
je     1144 <shuffle_signed+0x34>
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rbx,%rdi
call   1030 <randto@plt>
mov    -0x4(%r14,%rbx,4),%ecx
mov    (%r14,%rax,4),%edx
mov    %edx,-0x4(%r14,%rbx,4)
mov    %ecx,(%r14,%rax,4)
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
jne    1120 <shuffle_signed+0x10>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @shuffle_signed(i32* nocapture %0, i64 %1) {
%3 = add i64 %1, -1
%4 = icmp eq i64 %3, 0
br i1 %4, label %15, label %5
5: ; preds = %2, %5
%6 = phi i64 [ %13, %5 ], [ %3, %2 ]
%7 = phi i64 [ %6, %5 ], [ %1, %2 ]
%8 = tail call i64 @randto(i64 %7)
%9 = getelementptr inbounds i32, i32* %0, i64 %6
%10 = load i32, i32* %9
%11 = getelementptr inbounds i32, i32* %0, i64 %8
%12 = load i32, i32* %11
store i32 %12, i32* %9
store i32 %10, i32* %11
%13 = add i64 %6, -1
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %5
15: ; preds = %5, %2
ret void
}