#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 sre_random();
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int StrShuffle(char *s1, char *s2) {
  int len;
  int pos;
  char c;
  if (s1 != s2)
    strcpy(s1, s2);
  for (len = strlen(s1); len > 1; len--) {
    pos = ((int)(sre_random() * (len)));
    c = s1[pos];
    s1[pos] = s1[len - 1];
    s1[len - 1] = c;
  }
  return 1;
}


x86 assembly (clang, -O0):
<StrShuffle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
je     115b <StrShuffle+0x2b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jle    11c9 <StrShuffle+0x99>
mov    $0x0,%al
call   1050 <sre_random@plt>
imul   -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x19(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x19(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1167 <StrShuffle+0x37>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<StrShuffle>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
cmp    %rsi,%rdi
je     1144 <StrShuffle+0x14>
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     1190 <StrShuffle+0x60>
mov    %eax,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1050 <sre_random@plt>
mov    %ebx,%ecx
imul   %eax,%ecx
movslq %ecx,%rax
movzbl (%r14,%rax,1),%edi
lea    -0x1(%rbx),%rdx
mov    %edx,%esi
movzbl (%r14,%rsi,1),%ecx
mov    %cl,(%r14,%rax,1)
mov    %dil,(%r14,%rsi,1)
cmp    $0x2,%rbx
mov    %rdx,%rbx
ja     1160 <StrShuffle+0x30>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @StrShuffle(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = load i8*, i8** %4
%10 = icmp ne i8* %8, %9
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = load i8*, i8** %4
%14 = call i32 @strcpy(i8* %12, i8* %13)
br label %15
15: ; preds = %11, %2
%16 = load i8*, i8** %3
%17 = call i32 @strlen(i8* %16)
store i32 %17, i32* %5
br label %18
18: ; preds = %46, %15
%19 = load i32, i32* %5
%20 = icmp sgt i32 %19, 1
br i1 %20, label %21, label %49
21: ; preds = %18
%22 = call i32 (...) @sre_random()
%23 = load i32, i32* %5
%24 = mul nsw i32 %22, %23
store i32 %24, i32* %6
%25 = load i8*, i8** %3
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
store i8 %29, i8* %7
%30 = load i8*, i8** %3
%31 = load i32, i32* %5
%32 = sub nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %30, i64 %33
%35 = load i8, i8* %34
%36 = load i8*, i8** %3
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
store i8 %35, i8* %39
%40 = load i8, i8* %7
%41 = load i8*, i8** %3
%42 = load i32, i32* %5
%43 = sub nsw i32 %42, 1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %41, i64 %44
store i8 %40, i8* %45
br label %46
46: ; preds = %21
%47 = load i32, i32* %5
%48 = add nsw i32 %47, -1
store i32 %48, i32* %5
br label %18
49: ; preds = %18
ret i32 1
}

LLVM IR (-O2):
define i32 @StrShuffle(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, %1
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @strcpy(i8* %0, i8* %1)
br label %6
6: ; preds = %4, %2
%7 = tail call i32 @strlen(i8* %0)
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %24
9: ; preds = %6
%10 = zext i32 %7 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ %10, %9 ], [ %19, %11 ]
%13 = tail call i32 (...) @sre_random()
%14 = trunc i64 %12 to i32
%15 = mul nsw i32 %13, %14
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %0, i64 %16
%18 = load i8, i8* %17
%19 = add nsw i64 %12, -1
%20 = and i64 %19, 4294967295
%21 = getelementptr inbounds i8, i8* %0, i64 %20
%22 = load i8, i8* %21
store i8 %22, i8* %17
store i8 %18, i8* %21
%23 = icmp ugt i64 %12, 2
br i1 %23, label %11, label %24
24: ; preds = %11, %6
ret i32 1
}