#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 *, ...);
void find_power_set(char *set, int set_size) {
  unsigned int power_set_size = 1 << set_size;
  int counter, j;
  for (counter = 0; counter < power_set_size; counter++) {
    for (j = 0; j < set_size; j++) {
      if (counter & (1 << j))
        printf("%c", set[j]);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<find_power_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jae    11b5 <find_power_set+0xa5>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1199 <find_power_set+0x89>
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1186 <find_power_set+0x76>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118b <find_power_set+0x7b>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1146 <find_power_set+0x36>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1133 <find_power_set+0x23>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_power_set>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r14d
mov    %rdi,%r15
mov    %esi,%r12d
xor    %ebx,%ebx
jmp    1148 <find_power_set+0x38>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
mov    %ebx,%eax
mov    %r14d,%ecx
shr    %cl,%eax
test   %eax,%eax
jne    117a <find_power_set+0x6a>
test   %r14d,%r14d
jle    1130 <find_power_set+0x20>
xor    %ebp,%ebp
jmp    1169 <find_power_set+0x59>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%r12
je     1130 <find_power_set+0x20>
bt     %ebp,%ebx
jae    1160 <find_power_set+0x50>
movsbl (%r15,%rbp,1),%edi
call   1030 <putchar@plt>
jmp    1160 <find_power_set+0x50>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @find_power_set(i8* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
%4 = zext i32 %1 to i64
br label %5
5: ; preds = %2, %21
%6 = phi i32 [ 0, %2 ], [ %23, %21 ]
br i1 %3, label %7, label %21
7: ; preds = %5, %18
%8 = phi i64 [ %19, %18 ], [ 0, %5 ]
%9 = trunc i64 %8 to i32
%10 = shl nuw i32 1, %9
%11 = and i32 %10, %6
%12 = icmp eq i32 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %7
%14 = getelementptr inbounds i8, i8* %0, i64 %8
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = tail call i32 @putchar(i32 %16)
br label %18
18: ; preds = %7, %13
%19 = add nuw nsw i64 %8, 1
%20 = icmp eq i64 %19, %4
br i1 %20, label %21, label %7
21: ; preds = %18, %5
%22 = tail call i32 @putchar(i32 10)
%23 = add nuw nsw i32 %6, 1
%24 = lshr i32 %23, %1
%25 = icmp eq i32 %24, 0
br i1 %25, label %5, label %26
26: ; preds = %21
ret void
}