#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*/ free(char *);
int /*<<< orphan*/ printf(char *, char *);
char *remove_at(char *, int /*<<< orphan*/);
scalar_t__ strlen(char *);
void subsets(char *cs, char *buf, int last) {
  if (strlen(cs) == 0) {
    buf[last] = '\0';
    printf("%s\n", buf);
  } else {
    char c = cs[0];
    char *rest = remove_at(cs, 0);
    subsets(rest, buf, last);
    buf[last] = c;
    subsets(rest, buf, last + 1);
    free(rest);
  }
}


x86 assembly (clang, -O0):
<subsets>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
jne    1197 <subsets+0x47>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rsi
lea    0xe73(%rip),%rdi
call   1050 <printf@plt>
jmp    11e9 <subsets+0x99>
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x15(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1070 <remove_at@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <subsets@plt>
mov    -0x15(%rbp),%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
add    $0x1,%edx
call   1060 <subsets@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<subsets>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%rbx
mov    (%rdi),%r15b
test   %r15b,%r15b
je     1194 <subsets+0x54>
xor    %esi,%esi
call   1060 <remove_at@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1050 <subsets@plt>
movslq %r14d,%rdx
mov    %r15b,(%rbx,%rdx,1)
add    $0x1,%edx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <subsets@plt>
mov    %rbp,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
movslq %r14d,%rax
movb   $0x0,(%rbx,%rax,1)
lea    0xe5e(%rip),%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

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

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