#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 PowerSet(int a[], int b[], int n, int index) {
  if (index == n) {
    printf("{");
    for (int i = 0; i < n; i++) {
      if (b[i] == 1) {
        printf("%d ", a[i]);
      }
    }
    printf("}\n");
    return;
  }
  PowerSet(a, b, n, index + 1);
  b[index] = 1;
  PowerSet(a, b, n, index + 1);
  b[index] = 0;
}


x86 assembly (clang, -O0):
<PowerSet>:
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    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    11b4 <PowerSet+0x94>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11a1 <PowerSet+0x81>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jne    118e <PowerSet+0x6e>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1193 <PowerSet+0x73>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1157 <PowerSet+0x37>
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11fe <PowerSet+0xde>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
call   1030 <PowerSet@plt>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
call   1030 <PowerSet@plt>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PowerSet>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %rsi,%r13
mov    %rdi,%r14
cmp    %edx,%ecx
jne    11a1 <PowerSet+0x61>
mov    $0x7b,%edi
call   1030 <putchar@plt>
test   %r15d,%r15d
jle    11e9 <PowerSet+0xa9>
mov    %r15d,%ebp
lea    0xe8b(%rip),%r15
xor    %ebx,%ebx
jmp    1189 <PowerSet+0x49>
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %rbx,%rbp
je     11e9 <PowerSet+0xa9>
cmpl   $0x1,0x0(%r13,%rbx,4)
jne    1180 <PowerSet+0x40>
mov    (%r14,%rbx,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1180 <PowerSet+0x40>
mov    %edx,%ebp
lea    0x1(%r15),%r12d
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r12d,%ecx
call   1050 <PowerSet@plt>
movslq %r15d,%rbx
movl   $0x1,0x0(%r13,%rbx,4)
mov    %r14,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
mov    %r12d,%ecx
call   1050 <PowerSet@plt>
movl   $0x0,0x0(%r13,%rbx,4)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe14(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"{\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [3 x i8] c"}\0A\00"
define void @PowerSet(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %8
%11 = load i32, i32* %7
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %39
13: ; preds = %4
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %9
br label %15
15: ; preds = %34, %13
%16 = load i32, i32* %9
%17 = load i32, i32* %7
%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* %9
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
%24 = load i32, i32* %23
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %33
26: ; preds = %19
%27 = load i32*, i32** %5
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %26, %19
br label %34
34: ; preds = %33
%35 = load i32, i32* %9
%36 = add nsw i32 %35, 1
store i32 %36, i32* %9
br label %15
37: ; preds = %15
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %58
39: ; preds = %4
%40 = load i32*, i32** %5
%41 = load i32*, i32** %6
%42 = load i32, i32* %7
%43 = load i32, i32* %8
%44 = add nsw i32 %43, 1
%45 = load i32*, i32** %6
%46 = load i32, i32* %8
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %45, i64 %47
store i32 1, i32* %48
%49 = load i32*, i32** %5
%50 = load i32*, i32** %6
%51 = load i32, i32* %7
%52 = load i32, i32* %8
%53 = add nsw i32 %52, 1
%54 = load i32*, i32** %6
%55 = load i32, i32* %8
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i32, i32* %54, i64 %56
store i32 0, i32* %57
br label %58
58: ; preds = %39, %37
ret void
}

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