#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 *);
void StrShuffle(char *s1, char *s2) {
  int len;
  int pos;
  char c;
  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;
  }
}


x86 assembly (clang, -O0):
<StrShuffle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
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    11bb <StrShuffle+0x8b>
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    1159 <StrShuffle+0x29>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<StrShuffle>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     1180 <StrShuffle+0x50>
mov    %eax,%ebx
nopl   0x0(%rax,%rax,1)
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     1150 <StrShuffle+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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