#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 /*<<< orphan*/ printf(char *, char *);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
char *strdup(char *);
int strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  char *string;
  char c;
  int index = 0;
  int count = 0;
  string = strdup(argv[1]);
  srand(time(0));
  for (index = 0; index < strlen(string); ++index) {
    if (rand() % 20 > 18 + count) {
      if (strlen(string) > 2 && index < strlen(string) - 2 && index > 0) {
        c = string[index];
        string[index] = string[index + 1];
        string[index + 1] = c;
        count++;
      }
    }
  }
  printf("%s\n", string);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x18(%rbp)
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jge    127b <main+0x11b>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x14,%ecx
cltd
idiv   %ecx
mov    -0x24(%rbp),%eax
add    $0x12,%eax
cmp    %eax,%edx
jle    1268 <main+0x108>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jle    1263 <main+0x103>
mov    -0x20(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
sub    $0x2,%ecx
cmp    %ecx,%eax
jge    1263 <main+0x103>
cmpl   $0x0,-0x20(%rbp)
jle    1263 <main+0x103>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x19(%rbp),%dl
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1268 <main+0x108>
jmp    126d <main+0x10d>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11aa <main+0x4a>
mov    -0x18(%rbp),%rsi
lea    0xd7a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    0x8(%rsi),%rdi
call   1070 <strdup@plt>
mov    %rax,%r14
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1210 <main+0xb0>
xor    %ebx,%ebx
xor    %r15d,%r15d
jmp    11b3 <main+0x53>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    1210 <main+0xb0>
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
shl    $0x2,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
lea    0x12(%r15),%ecx
cmp    %ecx,%eax
jle    11a0 <main+0x40>
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    $0x3,%eax
jl     11a0 <main+0x40>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %rbx,%rbx
je     11a0 <main+0x40>
add    $0xfffffffe,%eax
cltq
cmp    %rax,%rbx
jge    11a0 <main+0x40>
rolw   $0x8,(%r14,%rbx,1)
add    $0x1,%r15d
jmp    11a0 <main+0x40>
lea    0xde9(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 0, i32* %9
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i8* @strdup(i8* %12)
store i8* %13, i8** %6
%14 = call i32 @time(i32 0)
%15 = call i32 @srand(i32 %14)
store i32 0, i32* %8
br label %16
16: ; preds = %66, %2
%17 = load i32, i32* %8
%18 = load i8*, i8** %6
%19 = call i32 @strlen(i8* %18)
%20 = icmp slt i32 %17, %19
br i1 %20, label %21, label %69
21: ; preds = %16
%22 = call i32 (...) @rand()
%23 = srem i32 %22, 20
%24 = load i32, i32* %9
%25 = add nsw i32 18, %24
%26 = icmp sgt i32 %23, %25
br i1 %26, label %27, label %65
27: ; preds = %21
%28 = load i8*, i8** %6
%29 = call i32 @strlen(i8* %28)
%30 = icmp sgt i32 %29, 2
br i1 %30, label %31, label %64
31: ; preds = %27
%32 = load i32, i32* %8
%33 = load i8*, i8** %6
%34 = call i32 @strlen(i8* %33)
%35 = sub nsw i32 %34, 2
%36 = icmp slt i32 %32, %35
br i1 %36, label %37, label %64
37: ; preds = %31
%38 = load i32, i32* %8
%39 = icmp sgt i32 %38, 0
br i1 %39, label %40, label %64
40: ; preds = %37
%41 = load i8*, i8** %6
%42 = load i32, i32* %8
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = load i8, i8* %44
store i8 %45, i8* %7
%46 = load i8*, i8** %6
%47 = load i32, i32* %8
%48 = add nsw i32 %47, 1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %46, i64 %49
%51 = load i8, i8* %50
%52 = load i8*, i8** %6
%53 = load i32, i32* %8
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %52, i64 %54
store i8 %51, i8* %55
%56 = load i8, i8* %7
%57 = load i8*, i8** %6
%58 = load i32, i32* %8
%59 = add nsw i32 %58, 1
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %57, i64 %60
store i8 %56, i8* %61
%62 = load i32, i32* %9
%63 = add nsw i32 %62, 1
store i32 %63, i32* %9
br label %64
64: ; preds = %40, %37, %31, %27
br label %65
65: ; preds = %64, %21
br label %66
66: ; preds = %65
%67 = load i32, i32* %8
%68 = add nsw i32 %67, 1
store i32 %68, i32* %8
br label %16
69: ; preds = %16
%70 = load i8*, i8** %6
%71 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %70)
%72 = load i32, i32* %3
ret i32 %72
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i8* @strdup(i8* %4)
%6 = tail call i32 @time(i32 0)
%7 = tail call i32 @srand(i32 %6)
%8 = tail call i32 @strlen(i8* %5)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %40
10: ; preds = %2, %34
%11 = phi i64 [ %36, %34 ], [ 0, %2 ]
%12 = phi i32 [ %35, %34 ], [ 0, %2 ]
%13 = tail call i32 (...) @rand()
%14 = srem i32 %13, 20
%15 = add nsw i32 %12, 18
%16 = icmp sgt i32 %14, %15
br i1 %16, label %17, label %34
17: ; preds = %10
%18 = tail call i32 @strlen(i8* %5)
%19 = icmp sgt i32 %18, 2
br i1 %19, label %20, label %34
20: ; preds = %17
%21 = tail call i32 @strlen(i8* %5)
%22 = add nsw i32 %21, -2
%23 = sext i32 %22 to i64
%24 = icmp slt i64 %11, %23
%25 = icmp ne i64 %11, 0
%26 = and i1 %25, %24
br i1 %26, label %27, label %34
27: ; preds = %20
%28 = getelementptr inbounds i8, i8* %5, i64 %11
%29 = load i8, i8* %28
%30 = add nuw nsw i64 %11, 1
%31 = getelementptr inbounds i8, i8* %5, i64 %30
%32 = load i8, i8* %31
store i8 %32, i8* %28
store i8 %29, i8* %31
%33 = add nsw i32 %12, 1
br label %34
34: ; preds = %10, %27, %20, %17
%35 = phi i32 [ %33, %27 ], [ %12, %20 ], [ %12, %17 ], [ %12, %10 ]
%36 = add nuw nsw i64 %11, 1
%37 = tail call i32 @strlen(i8* %5)
%38 = sext i32 %37 to i64
%39 = icmp slt i64 %36, %38
br i1 %39, label %10, label %40
40: ; preds = %34, %2
%41 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %5)
ret i32 0
}