#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 strlen(char *);
size_t uniform_random_zu(size_t);
char *strfry(char *anagram) {
  size_t i, j;
  char t;
  if (anagram == NULL)
    return NULL;
  for (i = strlen(anagram); i--;) {
    j = uniform_random_zu(i);
    t = anagram[i], anagram[i] = anagram[j], anagram[j] = t;
  }
  return anagram;
}


x86 assembly (clang, -O0):
<strfry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1144 <strfry+0x24>
movq   $0x0,-0x8(%rbp)
jmp    11b6 <strfry+0x96>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
cmp    $0x0,%rax
je     11ae <strfry+0x8e>
mov    -0x18(%rbp),%rdi
call   1040 <uniform_random_zu@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x21(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x21(%rbp),%dl
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1151 <strfry+0x31>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strfry>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
test   %rdi,%rdi
je     1160 <strfry+0x40>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %rax,%rax
je     1160 <strfry+0x40>
mov    %rax,%rbx
add    $0xffffffffffffffff,%rbx
mov    %rbx,%rdi
call   1040 <uniform_random_zu@plt>
movzbl (%r14,%rbx,1),%ecx
movzbl (%r14,%rax,1),%edx
mov    %dl,(%r14,%rbx,1)
mov    %cl,(%r14,%rax,1)
add    $0xffffffffffffffff,%rbx
jb     1140 <strfry+0x20>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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