#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 mystrlen(char *);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *mystrfry(char *str) {
  srand(time(NULL));
  int i, no1, no2;
  int j = mystrlen(str);
  char temp;
  for (i = 0; i < j; i++) {
    no1 = rand() % j;
    no2 = rand() % j;
    temp = str[no1];
    str[no1] = str[no2];
    str[no2] = temp;
  }
  return str;
}


x86 assembly (clang, -O0):
<mystrfry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
mov    -0x8(%rbp),%rdi
call   1050 <mystrlen@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11d7 <mystrfry+0x97>
mov    $0x0,%al
call   1060 <rand@plt>
cltd
idivl  -0x18(%rbp)
mov    %edx,-0x10(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
cltd
idivl  -0x18(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x19(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x19(%rbp),%dl
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116f <mystrfry+0x2f>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mystrfry>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
mov    %r15,%rdi
call   1050 <mystrlen@plt>
test   %eax,%eax
jle    11a5 <mystrfry+0x65>
mov    %eax,%r14d
mov    %eax,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <rand@plt>
cltd
idiv   %r14d
mov    %edx,%ebp
xor    %eax,%eax
call   1060 <rand@plt>
cltd
idiv   %r14d
movslq %ebp,%rax
movzbl (%r15,%rax,1),%esi
movslq %edx,%rdx
movzbl (%r15,%rdx,1),%ecx
mov    %cl,(%r15,%rax,1)
mov    %sil,(%r15,%rdx,1)
add    $0xffffffff,%ebx
jne    1170 <mystrfry+0x30>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i8* @mystrfry(i8* returned %0) {
%2 = tail call i32 @time(i32* null)
%3 = tail call i32 @srand(i32 %2)
%4 = tail call i32 @mystrlen(i8* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %20
6: ; preds = %1, %6
%7 = phi i32 [ %18, %6 ], [ 0, %1 ]
%8 = tail call i32 (...) @rand()
%9 = srem i32 %8, %4
%10 = tail call i32 (...) @rand()
%11 = srem i32 %10, %4
%12 = sext i32 %9 to i64
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = sext i32 %11 to i64
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = load i8, i8* %16
store i8 %17, i8* %13
store i8 %14, i8* %16
%18 = add nuw nsw i32 %7, 1
%19 = icmp eq i32 %18, %4
br i1 %19, label %20, label %6
20: ; preds = %6, %1
ret i8* %0
}