#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 rand();
char *shuffleKey(char *in) {
  int i, j;
  char temp;
  for (i = 24; i >= 1; i--) {
    j = rand() % (i + 1);
    temp = in[j];
    in[j] = in[i];
    in[i] = temp;
  }
  return in;
}


x86 assembly (clang, -O0):
<shuffleKey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x18,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jl     1180 <shuffleKey+0x70>
mov    $0x0,%al
call   1030 <rand@plt>
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x11(%rbp),%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <shuffleKey+0x13>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shuffleKey>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x19,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <rand@plt>
cltd
idiv   %ebx
movslq %edx,%rax
movzbl (%r14,%rax,1),%ecx
movzbl -0x1(%r14,%rbx,1),%edx
mov    %dl,(%r14,%rax,1)
mov    %cl,-0x1(%r14,%rbx,1)
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1120 <shuffleKey+0x10>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i8* @shuffleKey(i8* returned %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i64 [ 24, %1 ], [ %13, %2 ]
%4 = tail call i32 (...) @rand()
%5 = trunc i64 %3 to i32
%6 = add i32 %5, 1
%7 = srem i32 %4, %6
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = getelementptr inbounds i8, i8* %0, i64 %3
%12 = load i8, i8* %11
store i8 %12, i8* %9
store i8 %10, i8* %11
%13 = add nsw i64 %3, -1
%14 = icmp ugt i64 %3, 1
br i1 %14, label %2, label %15
15: ; preds = %2
ret i8* %0
}