#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 */
typedef int /*<<< orphan*/ letters;

/* Variables and functions */
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ print_combinations_aux(unsigned char *, int /*<<< orphan*/,
                                          char *, int /*<<< orphan*/);
void print_combinations(const char *str) {
  static unsigned char letters[26];
  memset(letters, 0, sizeof(letters));
  size_t i;
  for (i = 0; str[i] != '\0'; i++) {
    letters[(unsigned char)(str[i] - 'a')] = 1;
  }
  char buff[i + 1];
  print_combinations_aux(letters, 0, buff, 0);
}


x86 assembly (clang, -O0):
<print_combinations>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0x2f0d(%rip),%rdi
xor    %esi,%esi
mov    $0x1a,%edx
call   1030 <memset@plt>
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     118c <print_combinations+0x6c>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x61,%eax
movzbl %al,%eax
mov    %eax,%ecx
lea    0x2ec9(%rip),%rax
movb   $0x1,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1147 <print_combinations+0x27>
mov    -0x10(%rbp),%rcx
mov    %rcx,%rax
add    $0x1,%rax
mov    %rsp,%rdx
mov    %rdx,-0x18(%rbp)
add    $0x10,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,%rsp
mov    %rax,-0x20(%rbp)
lea    0x2e86(%rip),%rdi
xor    %ecx,%ecx
mov    %ecx,%esi
call   1040 <print_combinations_aux@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_combinations>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0x2f0f(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x1a,%edx
call   1030 <memset@plt>
mov    (%rbx),%cl
mov    $0x1,%eax
test   %cl,%cl
je     1167 <print_combinations+0x47>
nopl   0x0(%rax,%rax,1)
add    $0x9f,%cl
movzbl %cl,%ecx
movb   $0x1,(%rcx,%r14,1)
movzbl (%rbx,%rax,1),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    1150 <print_combinations+0x30>
mov    %rsp,%rdx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rdx
mov    %rdx,%rsp
lea    0x2ec1(%rip),%rdi
xor    %esi,%esi
xor    %ecx,%ecx
call   1040 <print_combinations_aux@plt>
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@print_combinations.letters = internal global [26 x i8] zeroinitializer
define void @print_combinations(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i64
store i8* %0, i8** %2
%6 = call i32 @memset(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @print_combinations.letters, i64 0, i64 0), i32 0, i32 26)
store i64 0, i64* %3
br label %7
7: ; preds = %24, %1
%8 = load i8*, i8** %2
%9 = load i64, i64* %3
%10 = getelementptr inbounds i8, i8* %8, i64 %9
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %27
14: ; preds = %7
%15 = load i8*, i8** %2
%16 = load i64, i64* %3
%17 = getelementptr inbounds i8, i8* %15, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = sub nsw i32 %19, 97
%21 = trunc i32 %20 to i8
%22 = zext i8 %21 to i64
%23 = getelementptr inbounds [26 x i8], [26 x i8]* @print_combinations.letters, i64 0, i64 %22
store i8 1, i8* %23
br label %24
24: ; preds = %14
%25 = load i64, i64* %3
%26 = add i64 %25, 1
store i64 %26, i64* %3
br label %7
27: ; preds = %7
%28 = load i64, i64* %3
%29 = add i64 %28, 1
%30 = call i8* @llvm.stacksave()
store i8* %30, i8** %4
%31 = alloca i8, i64 %29
store i64 %29, i64* %5
%32 = call i32 @print_combinations_aux(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @print_combinations.letters, i64 0, i64 0), i32 0, i8* %31, i32 0)
%33 = load i8*, i8** %4
ret void
}

LLVM IR (-O2):
@print_combinations.letters = internal global [26 x i8] zeroinitializer
define void @print_combinations(i8* nocapture %0) {
%2 = tail call i32 @memset(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @print_combinations.letters, i64 0, i64 0), i32 0, i32 26)
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %17, label %5
5: ; preds = %1, %5
%6 = phi i8 [ %13, %5 ], [ %3, %1 ]
%7 = phi i64 [ %11, %5 ], [ 0, %1 ]
%8 = add i8 %6, -97
%9 = zext i8 %8 to i64
%10 = getelementptr inbounds [26 x i8], [26 x i8]* @print_combinations.letters, i64 0, i64 %9
store i8 1, i8* %10
%11 = add i64 %7, 1
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %5
15: ; preds = %5
%16 = add i64 %7, 2
br label %17
17: ; preds = %15, %1
%18 = phi i64 [ 1, %1 ], [ %16, %15 ]
%19 = alloca i8, i64 %18
%20 = call i32 @print_combinations_aux(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @print_combinations.letters, i64 0, i64 0), i32 0, i8* %19, i32 0)
ret void
}