#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 _get_last_index(char *, int);
int /*<<< orphan*/ print_combination(char *, int, int, int);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int main() {
  int i = 0, j = 0, ind = 0;
  char *str = "careercup";
  int str_len = strlen(str);
  printf("\n%s\n", str);
  for (i = 0; i < str_len; i++) {
    for (j = i; j < str_len; j++) {
      ind = 0;
      ind = _get_last_index(str, j);
      printf("\nind  = %d, j = %d, i = %d\n", ind, j, i);
      if (j != ind) {
        print_combination(str, i, ind, j);
      } else {
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xe95(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    122d <main+0xed>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    121a <main+0xda>
movl   $0x0,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <_get_last_index@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
je     1202 <main+0xc2>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
call   1060 <print_combination@plt>
jmp    1207 <main+0xc7>
jmp    1207 <main+0xc7>
jmp    120c <main+0xcc>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a6 <main+0x66>
jmp    121f <main+0xdf>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1194 <main+0x54>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeae(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%r12d
lea    0xea6(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r12d,%r12d
jle    11da <main+0x9a>
lea    0xe86(%rip),%r14
lea    0xe8e(%rip),%r15
xor    %r13d,%r13d
jmp    1199 <main+0x59>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r13d
cmp    %r12d,%r13d
je     11da <main+0x9a>
mov    %r13d,%ebp
jmp    11a8 <main+0x68>
xchg   %ax,%ax
add    $0x1,%ebp
cmp    %ebp,%r12d
je     1190 <main+0x50>
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <_get_last_index@plt>
mov    %eax,%ebx
mov    %r15,%rdi
mov    %eax,%esi
mov    %ebp,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
cmp    %ebx,%ebp
je     11a0 <main+0x60>
mov    %r14,%rdi
mov    %r13d,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
call   1060 <print_combination@plt>
jmp    11a0 <main+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [10 x i8] c"careercup\00"
@.str.1 = [5 x i8] c"\0A%s\0A\00"
@.str.2 = [28 x i8] c"\0Aind = %d, j = %d, i = %d\0A\00"
define i32 @main() {
%1 = tail call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %19
4: ; preds = %0, %16
%5 = phi i32 [ %17, %16 ], [ 0, %0 ]
br label %6
6: ; preds = %4, %13
%7 = phi i32 [ %14, %13 ], [ %5, %4 ]
%8 = tail call i32 @_get_last_index(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %8, i32 %7, i32 %5)
%10 = icmp eq i32 %7, %8
br i1 %10, label %13, label %11
11: ; preds = %6
%12 = tail call i32 @print_combination(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %8, i32 %7)
br label %13
13: ; preds = %11, %6
%14 = add nuw i32 %7, 1
%15 = icmp eq i32 %14, %1
br i1 %15, label %16, label %6
16: ; preds = %13
%17 = add nuw nsw i32 %5, 1
%18 = icmp eq i32 %17, %1
br i1 %18, label %19, label %4
19: ; preds = %16, %0
ret i32 0
}