#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 print_permute(char str[], long long int len) {
  char temp;
  long long int i, j, k;
  if (len == 1) {
    printf("%s\n", str);
    return;
  }
  for (i = len - 1; i >= 0; i--) {
    temp = str[len - 1];
    str[len - 1] = str[i];
    str[i] = temp;
    print_permute(str, len - 1);
    temp = str[len - 1];
    str[len - 1] = str[i];
    str[i] = temp;
  }
  return;
}


x86 assembly (clang, -O0):
<print_permute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x1,-0x10(%rbp)
jne    1150 <print_permute+0x30>
mov    -0x8(%rbp),%rsi
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
jmp    1202 <print_permute+0xe2>
mov    -0x10(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jl     11fd <print_permute+0xdd>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x11(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
sub    $0x1,%rsi
call   1040 <print_permute@plt>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x11(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
jmp    115c <print_permute+0x3c>
jmp    1202 <print_permute+0xe2>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_permute>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
cmp    $0x1,%rsi
jne    114b <print_permute+0x2b>
lea    0xec8(%rip),%rdi
mov    %r12,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <printf@plt>
jl     119d <print_permute+0x7d>
mov    %rsi,%r14
lea    -0x1(%rsi),%r15
mov    %rsi,%rbx
nopw   0x0(%rax,%rax,1)
movzbl -0x1(%r12,%r14,1),%eax
movzbl -0x1(%r12,%rbx,1),%ecx
mov    %cl,-0x1(%r12,%r14,1)
mov    %al,-0x1(%r12,%rbx,1)
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <print_permute@plt>
movzbl -0x1(%r12,%r14,1),%eax
movzbl -0x1(%r12,%rbx,1),%ecx
mov    %cl,-0x1(%r12,%r14,1)
mov    %al,-0x1(%r12,%rbx,1)
add    $0xffffffffffffffff,%rbx
jne    1160 <print_permute+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define void @print_permute(i8* %0, i64 %1) {
%3 = icmp eq i64 %1, 1
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %20
6: ; preds = %2
%7 = add nsw i64 %1, -1
%8 = icmp sgt i64 %1, 0
br i1 %8, label %9, label %20
9: ; preds = %6
%10 = getelementptr inbounds i8, i8* %0, i64 %7
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ %7, %9 ], [ %18, %11 ]
%13 = load i8, i8* %10
%14 = getelementptr inbounds i8, i8* %0, i64 %12
%15 = load i8, i8* %14
store i8 %15, i8* %10
store i8 %13, i8* %14
tail call void @print_permute(i8* %0, i64 %7)
%16 = load i8, i8* %10
%17 = load i8, i8* %14
store i8 %17, i8* %10
store i8 %16, i8* %14
%18 = add nsw i64 %12, -1
%19 = icmp eq i64 %12, 0
br i1 %19, label %20, label %11
20: ; preds = %11, %6, %4
ret void
}