#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 *);
int strlen(char *);
void allLexicographicRecur(char *str, char *data, int last, int index) {
  int i, len = strlen(str);
  for (i = 0; i < len; i++) {
    data[index] = str[i];
    if (index == last)
      printf("%s\n", data);
    else
      allLexicographicRecur(str, data, last, index + 1);
  }
}


x86 assembly (clang, -O0):
<allLexicographicRecur>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11c5 <allLexicographicRecur+0x95>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    119c <allLexicographicRecur+0x6c>
mov    -0x10(%rbp),%rsi
lea    0xe6e(%rip),%rdi
call   1040 <printf@plt>
jmp    11b2 <allLexicographicRecur+0x82>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
call   1050 <allLexicographicRecur@plt>
jmp    11b7 <allLexicographicRecur+0x87>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1159 <allLexicographicRecur+0x29>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<allLexicographicRecur>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%r13
call   1030 <strlen@plt>
test   %eax,%eax
jle    11aa <allLexicographicRecur+0x7a>
movslq %r15d,%rbp
lea    0x1(%rbp),%ecx
mov    %ecx,0x4(%rsp)
mov    %eax,%r12d
xor    %r15d,%r15d
jmp    118b <allLexicographicRecur+0x5b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
mov    0x4(%rsp),%ecx
call   1050 <allLexicographicRecur@plt>
add    $0x1,%r15
cmp    %r15,%r12
je     11aa <allLexicographicRecur+0x7a>
movzbl 0x0(%r13,%r15,1),%eax
mov    %al,(%rbx,%rbp,1)
cmp    %r14d,%ebp
jne    1170 <allLexicographicRecur+0x40>
lea    0xe60(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
jmp    1182 <allLexicographicRecur+0x52>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define void @allLexicographicRecur(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load i8*, i8** %5
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %10
store i32 0, i32* %9
br label %13
13: ; preds = %40, %4
%14 = load i32, i32* %9
%15 = load i32, i32* %10
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %43
17: ; preds = %13
%18 = load i8*, i8** %5
%19 = load i32, i32* %9
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = load i8*, i8** %6
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
store i8 %22, i8* %26
%27 = load i32, i32* %8
%28 = load i32, i32* %7
%29 = icmp eq i32 %27, %28
br i1 %29, label %30, label %33
30: ; preds = %17
%31 = load i8*, i8** %6
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %31)
br label %39
33: ; preds = %17
%34 = load i8*, i8** %5
%35 = load i8*, i8** %6
%36 = load i32, i32* %7
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 1
br label %39
39: ; preds = %33, %30
br label %40
40: ; preds = %39
%41 = load i32, i32* %9
%42 = add nsw i32 %41, 1
store i32 %42, i32* %9
br label %13
43: ; preds = %13
ret void
}

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