#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*/ puts(char *);
void permutationR(char *string, char *first) {
  if (*first == '\0') {
    puts(string);
  } else {
    for (char *ch = first; *ch != '\0'; ++ch) {
      char tmpChar = *ch;
      *ch = *first;
      *first = tmpChar;
      permutationR(string, first + 1);
      tmpChar = *ch;
      *ch = *first;
      *first = tmpChar;
    }
  }
}


x86 assembly (clang, -O0):
<permutationR>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    114e <permutationR+0x2e>
mov    -0x8(%rbp),%rdi
call   1030 <puts@plt>
jmp    11c9 <permutationR+0xa9>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11c4 <permutationR+0xa4>
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x19(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x19(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
call   1040 <permutationR@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x19(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x19(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1156 <permutationR+0x36>
jmp    11c9 <permutationR+0xa9>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<permutationR>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rsi),%al
test   %al,%al
je     1177 <permutationR+0x57>
mov    %rsi,%r12
lea    0x1(%rsi),%r15
mov    %rsi,%rbx
mov    %eax,%ecx
nopl   (%rax)
mov    %al,(%rbx)
mov    %cl,(%r12)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <permutationR@plt>
movzbl (%rbx),%eax
movzbl (%r12),%ecx
mov    %cl,(%rbx)
mov    %al,(%r12)
movzbl 0x1(%rbx),%ecx
add    $0x1,%rbx
test   %cl,%cl
jne    1140 <permutationR+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <puts@plt>

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

LLVM IR (-O2):
define void @permutationR(i8* nocapture %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %1, i64 1
br label %9
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) %0)
br label %18
9: ; preds = %5, %9
%10 = phi i8 [ %3, %5 ], [ %13, %9 ]
%11 = phi i8* [ %1, %5 ], [ %15, %9 ]
%12 = phi i8 [ %3, %5 ], [ %16, %9 ]
store i8 %10, i8* %11
store i8 %12, i8* %1
tail call void @permutationR(i8* %0, i8* %6)
%13 = load i8, i8* %11
%14 = load i8, i8* %1
store i8 %14, i8* %11
store i8 %13, i8* %1
%15 = getelementptr inbounds i8, i8* %11, i64 1
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %9
18: ; preds = %9, %7
ret void
}