#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*/ getchar();
int /*<<< orphan*/ permuteWithRepitition(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int main() {
  printf("Print all permutations of ABC (with repetition):\n");
  char str1[] = "ABC";
  permuteWithRepitition(str1, 0, 3);
  printf("\nPrint all permutations of ABB (with repetition):\n");
  char str2[] = "ABB";
  permuteWithRepitition(str2, 0, 3);
  getchar();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
mov    0xee8(%rip),%eax
mov    %eax,-0x4(%rbp)
lea    -0x4(%rbp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1050 <permuteWithRepitition@plt>
lea    0xed2(%rip),%rdi
call   1030 <printf@plt>
mov    0xefa(%rip),%eax
mov    %eax,-0x8(%rbp)
lea    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1050 <permuteWithRepitition@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
call   1030 <puts@plt>
movl   $0x434241,0x4(%rsp)
lea    0x4(%rsp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1050 <permuteWithRepitition@plt>
lea    0xed4(%rip),%rdi
call   1030 <puts@plt>
movl   $0x424241,(%rsp)
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1050 <permuteWithRepitition@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [50 x i8] c"Print all permutations of ABC (with repetition):\0A\00"
@__const.main.str1 = [4 x i8] c"ABC\00"
@.str.1 = [51 x i8] c"\0APrint all permutations of ABB (with repetition):\0A\00"
@__const.main.str2 = [4 x i8] c"ABB\00"
define i32 @main() {
%1 = alloca [4 x i8]
%2 = alloca [4 x i8]
%3 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%4 = bitcast [4 x i8]* %1 to i8*
%5 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%6 = call i32 @permuteWithRepitition(i8* %5, i32 0, i32 3)
%7 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%8 = bitcast [4 x i8]* %2 to i8*
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%10 = call i32 @permuteWithRepitition(i8* %9, i32 0, i32 3)
%11 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@str = [49 x i8] c"Print all permutations of ABC (with repetition):\00"
@str.2 = [50 x i8] c"\0APrint all permutations of ABB (with repetition):\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str, i64 0, i64 0))
%4 = bitcast i32* %1 to i8*
store i32 4407873, i32* %1
%5 = call i32 @permuteWithRepitition(i8* %4, i32 0, i32 3)
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.2, i64 0, i64 0))
%7 = bitcast i32* %2 to i8*
store i32 4342337, i32* %2
%8 = call i32 @permuteWithRepitition(i8* %7, i32 0, i32 3)
%9 = call i32 (...) @getchar()
ret i32 0
}