#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 *);
void permute_iterative_size_3(char *str) {
  int size = 3;
  char tmp[3];
  int m, n, o;
  for (m = 0; m < size; m++)
    for (n = 0; n < size; n++)
      if (n != m)
        for (o = 0; o < size; o++)
          if (o != n && o != m) {
            tmp[0] = str[m];
            tmp[1] = str[n];
            tmp[2] = str[o];
            printf("%s\n", tmp);
          }
}


x86 assembly (clang, -O0):
<permute_iterative_size_3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x3,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f8 <permute_iterative_size_3+0xe8>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11e5 <permute_iterative_size_3+0xd5>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     11d2 <permute_iterative_size_3+0xc2>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11cd <permute_iterative_size_3+0xbd>
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     11ba <permute_iterative_size_3+0xaa>
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     11ba <permute_iterative_size_3+0xaa>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0xf(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0xe(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0xd(%rbp)
lea    -0xf(%rbp),%rsi
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
jmp    11bf <permute_iterative_size_3+0xaf>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115c <permute_iterative_size_3+0x4c>
jmp    11d2 <permute_iterative_size_3+0xc2>
jmp    11d7 <permute_iterative_size_3+0xc7>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113d <permute_iterative_size_3+0x2d>
jmp    11ea <permute_iterative_size_3+0xda>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112a <permute_iterative_size_3+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<permute_iterative_size_3>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
xor    %r12d,%r12d
lea    0xed7(%rip),%r14
lea    0xd(%rsp),%r15
jmp    117c <permute_iterative_size_3+0x6c>
movzbl (%rbx,%r12,1),%eax
mov    %al,0xd(%rsp)
movzbl 0x1(%rbx),%eax
mov    %al,0xe(%rsp)
movzbl 0x2(%rbx),%eax
mov    %al,0xf(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
movzbl (%rbx,%r12,1),%eax
mov    %al,0xd(%rsp)
movzbl 0x2(%rbx),%eax
mov    %al,0xe(%rsp)
movzbl 0x1(%rbx),%eax
mov    %al,0xf(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
add    $0x1,%r12
test   %r12,%r12
je     1130 <permute_iterative_size_3+0x20>
cmp    $0x1,%r12
je     11b0 <permute_iterative_size_3+0xa0>
movzbl (%rbx,%r12,1),%eax
mov    %al,0xd(%rsp)
movzbl (%rbx),%eax
mov    %al,0xe(%rsp)
movzbl 0x1(%rbx),%eax
mov    %al,0xf(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
cmp    $0x2,%r12
je     11dc <permute_iterative_size_3+0xcc>
movzbl (%rbx,%r12,1),%eax
mov    %al,0xd(%rsp)
movzbl (%rbx),%eax
mov    %al,0xe(%rsp)
movzbl 0x2(%rbx),%eax
mov    %al,0xf(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
mov    $0x1,%bpl
cmp    $0x1,%r12
je     1234 <permute_iterative_size_3+0x124>
movzbl (%rbx,%r12,1),%eax
mov    %al,0xd(%rsp)
movzbl 0x1(%rbx),%eax
mov    %al,0xe(%rsp)
movzbl (%rbx),%eax
mov    %al,0xf(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
cmp    $0x2,%r12
je     1265 <permute_iterative_size_3+0x155>
movzbl (%rbx,%r12,1),%eax
mov    %al,0xd(%rsp)
movzbl 0x1(%rbx),%eax
mov    %al,0xe(%rsp)
movzbl 0x2(%rbx),%eax
mov    %al,0xf(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
test   %r12,%r12
je     1154 <permute_iterative_size_3+0x44>
xor    %ebp,%ebp
movzbl (%rbx,%r12,1),%eax
mov    %al,0xd(%rsp)
movzbl 0x2(%rbx),%eax
mov    %al,0xe(%rsp)
movzbl (%rbx),%eax
mov    %al,0xf(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
test   %bpl,%bpl
je     1154 <permute_iterative_size_3+0x44>
jmp    1178 <permute_iterative_size_3+0x68>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define void @permute_iterative_size_3(i8* nocapture %0) {
%2 = alloca [3 x i8]
%3 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 1
%5 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 2
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = getelementptr inbounds i8, i8* %0, i64 2
%8 = getelementptr inbounds i8, i8* %0, i64 2
%9 = getelementptr inbounds i8, i8* %0, i64 1
%10 = getelementptr inbounds i8, i8* %0, i64 2
%11 = getelementptr inbounds i8, i8* %0, i64 2
%12 = getelementptr inbounds i8, i8* %0, i64 1
%13 = getelementptr inbounds i8, i8* %0, i64 1
br label %14
14: ; preds = %61, %1
%15 = phi i64 [ 0, %1 ], [ %62, %61 ]
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = icmp eq i64 %15, 0
br i1 %17, label %50, label %18
18: ; preds = %14
%19 = icmp eq i64 %15, 1
br i1 %19, label %26, label %20
20: ; preds = %18
%21 = load i8, i8* %16
store i8 %21, i8* %3
%22 = load i8, i8* %0
store i8 %22, i8* %4
%23 = load i8, i8* %6
store i8 %23, i8* %5
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %3)
%25 = icmp eq i64 %15, 2
br i1 %25, label %32, label %26
26: ; preds = %18, %20
%27 = load i8, i8* %16
store i8 %27, i8* %3
%28 = load i8, i8* %0
store i8 %28, i8* %4
%29 = load i8, i8* %7
store i8 %29, i8* %5
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %3)
%31 = icmp eq i64 %15, 1
br i1 %31, label %43, label %32
32: ; preds = %20, %26
%33 = load i8, i8* %16
store i8 %33, i8* %3
%34 = load i8, i8* %13
store i8 %34, i8* %4
%35 = load i8, i8* %0
store i8 %35, i8* %5
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %3)
%37 = icmp eq i64 %15, 2
br i1 %37, label %63, label %38
38: ; preds = %32
%39 = load i8, i8* %16
store i8 %39, i8* %3
%40 = load i8, i8* %13
store i8 %40, i8* %4
%41 = load i8, i8* %10
store i8 %41, i8* %5
%42 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %3)
br i1 %17, label %55, label %43
43: ; preds = %26, %38
%44 = phi i8* [ %11, %38 ], [ %8, %26 ]
%45 = phi i1 [ false, %38 ], [ true, %26 ]
%46 = load i8, i8* %16
store i8 %46, i8* %3
%47 = load i8, i8* %44
store i8 %47, i8* %4
%48 = load i8, i8* %0
store i8 %48, i8* %5
%49 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %3)
br i1 %45, label %61, label %55
50: ; preds = %14
%51 = load i8, i8* %16
store i8 %51, i8* %3
%52 = load i8, i8* %9
store i8 %52, i8* %4
%53 = load i8, i8* %10
store i8 %53, i8* %5
%54 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %3)
br label %55
55: ; preds = %38, %50, %43
%56 = phi i8* [ %44, %43 ], [ %11, %50 ], [ %11, %38 ]
%57 = load i8, i8* %16
store i8 %57, i8* %3
%58 = load i8, i8* %56
store i8 %58, i8* %4
%59 = load i8, i8* %12
store i8 %59, i8* %5
%60 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %3)
br label %61
61: ; preds = %43, %55
%62 = add nuw nsw i64 %15, 1
br label %14
63: ; preds = %32
ret void
}