#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*/ printString(char *, int);
int /*<<< orphan*/ swap(char *, int, int);
void permuteWithRepitition(char str[], int k, int n) {
  if (k == n) {
    printString(str, n);
  } else {
    int i;
    for (i = k; i < n; i++) {
      swap(str, k, i);
      permuteWithRepitition(str, k + 1, n);
      swap(str, k, i);
    }
  }
}


x86 assembly (clang, -O0):
<permuteWithRepitition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    115f <permuteWithRepitition+0x2f>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1030 <printString@plt>
jmp    11b4 <permuteWithRepitition+0x84>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11af <permuteWithRepitition+0x7f>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1050 <swap@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
call   1040 <permuteWithRepitition@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1050 <swap@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1165 <permuteWithRepitition+0x35>
jmp    11b4 <permuteWithRepitition+0x84>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<permuteWithRepitition>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r12d
mov    %rdi,%rbp
cmp    %edx,%esi
jne    1155 <permuteWithRepitition+0x25>
mov    %rbp,%rdi
mov    %r12d,%esi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printString@plt>
jge    11a0 <permuteWithRepitition+0x70>
mov    %edx,%r14d
lea    0x1(%r12),%r15d
mov    %r12d,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    %r12d,%esi
mov    %ebx,%edx
call   1050 <swap@plt>
mov    %rbp,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
call   1040 <permuteWithRepitition@plt>
mov    %rbp,%rdi
mov    %r12d,%esi
mov    %ebx,%edx
call   1050 <swap@plt>
add    $0x1,%ebx
cmp    %ebx,%r14d
jne    1170 <permuteWithRepitition+0x40>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @permuteWithRepitition(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %5
%9 = load i32, i32* %6
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %15
11: ; preds = %3
%12 = load i8*, i8** %4
%13 = load i32, i32* %6
%14 = call i32 @printString(i8* %12, i32 %13)
br label %38
15: ; preds = %3
%16 = load i32, i32* %5
store i32 %16, i32* %7
br label %17
17: ; preds = %34, %15
%18 = load i32, i32* %7
%19 = load i32, i32* %6
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %37
21: ; preds = %17
%22 = load i8*, i8** %4
%23 = load i32, i32* %5
%24 = load i32, i32* %7
%25 = call i32 @swap(i8* %22, i32 %23, i32 %24)
%26 = load i8*, i8** %4
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
%29 = load i32, i32* %6
%30 = load i8*, i8** %4
%31 = load i32, i32* %5
%32 = load i32, i32* %7
%33 = call i32 @swap(i8* %30, i32 %31, i32 %32)
br label %34
34: ; preds = %21
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %17
37: ; preds = %17
br label %38
38: ; preds = %37, %11
ret void
}

LLVM IR (-O2):
define void @permuteWithRepitition(i8* %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %1, %2
br i1 %4, label %9, label %5
5: ; preds = %3
%6 = icmp slt i32 %1, %2
br i1 %6, label %7, label %17
7: ; preds = %5
%8 = add nsw i32 %1, 1
br label %11
9: ; preds = %3
%10 = tail call i32 @printString(i8* %0, i32 %1)
br label %17
11: ; preds = %7, %11
%12 = phi i32 [ %1, %7 ], [ %15, %11 ]
%13 = tail call i32 @swap(i8* %0, i32 %1, i32 %12)
tail call void @permuteWithRepitition(i8* %0, i32 %8, i32 %2)
%14 = tail call i32 @swap(i8* %0, i32 %1, i32 %12)
%15 = add i32 %12, 1
%16 = icmp eq i32 %15, %2
br i1 %16, label %17, label %11
17: ; preds = %11, %5, %9
ret void
}