#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 log(int);
int pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int printPowerSet(int *set, int len) {
  int psize, i, j, pos = 0;
  if (len <= 0)
    return -1;
  psize = pow(2, len);
  pos = log(psize);
  printf("\nPowerset of A ::\n");
  printf("1.  { }");
  for (i = 1; i < psize; i++) {
    printf("\n%d . {", i + 1);
    for (j = 0; j <= pos; j++)
      if (i & (1 << j))
        printf(" %d ", set[j]);
    printf("}");
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<printPowerSet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     115c <printPowerSet+0x2c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1244 <printPowerSet+0x114>
mov    -0x14(%rbp),%esi
mov    $0x2,%edi
call   1050 <pow@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1040 <log@plt>
mov    %eax,-0x24(%rbp)
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    122f <printPowerSet+0xff>
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     1213 <printPowerSet+0xe3>
mov    -0x1c(%rbp),%eax
mov    -0x20(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1200 <printPowerSet+0xd0>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1205 <printPowerSet+0xd5>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c1 <printPowerSet+0x91>
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    119a <printPowerSet+0x6a>
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printPowerSet>:
test   %esi,%esi
jle    123a <printPowerSet+0xea>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
mov    $0x2,%edi
call   1070 <pow@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1060 <log@plt>
mov    %rax,0x10(%rsp)
lea    0xe8d(%rip),%rdi
call   1040 <puts@plt>
lea    0xe6c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,0xc(%rsp)
cmp    $0x2,%ebp
jl     121f <printPowerSet+0xcf>
mov    0x10(%rsp),%rax
lea    0x1(%rax),%r12d
mov    $0x1,%r15d
lea    0xe56(%rip),%rbp
jmp    11d4 <printPowerSet+0x84>
nopl   0x0(%rax)
mov    $0x7d,%edi
call   1030 <putchar@plt>
mov    %r14d,%r15d
cmp    0xc(%rsp),%r14d
je     121f <printPowerSet+0xcf>
lea    0x1(%r15),%r14d
lea    0xe29(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0x10(%rsp)
js     11c0 <printPowerSet+0x70>
xor    %r13d,%r13d
jmp    1209 <printPowerSet+0xb9>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r13
cmp    %r13,%r12
je     11c0 <printPowerSet+0x70>
bt     %r13d,%r15d
jae    1200 <printPowerSet+0xb0>
mov    (%rbx,%r13,4),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1200 <printPowerSet+0xb0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xffffffff,%eax
ret

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

LLVM IR (-O2):
@.str.1 = [8 x i8] c"1. { }\00"
@.str.2 = [8 x i8] c"\0A%d . {\00"
@.str.3 = [5 x i8] c" %d \00"
@str = [18 x i8] c"\0APowerset of A ::\00"
define i32 @printPowerSet(i32* nocapture %0, i32 %1) {
%3 = icmp slt i32 %1, 1
br i1 %3, label %36, label %4
4: ; preds = %2
%5 = tail call i32 @pow(i32 2, i32 %1)
%6 = tail call i32 @log(i32 %5)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp sgt i32 %5, 1
br i1 %9, label %10, label %34
10: ; preds = %4
%11 = icmp slt i32 %6, 0
%12 = add i32 %6, 1
%13 = zext i32 %12 to i64
br label %14
14: ; preds = %10, %31
%15 = phi i32 [ 1, %10 ], [ %16, %31 ]
%16 = add nuw nsw i32 %15, 1
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %16)
br i1 %11, label %31, label %18
18: ; preds = %14, %28
%19 = phi i64 [ %29, %28 ], [ 0, %14 ]
%20 = trunc i64 %19 to i32
%21 = shl nuw i32 1, %20
%22 = and i32 %21, %15
%23 = icmp eq i32 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %18
%25 = getelementptr inbounds i32, i32* %0, i64 %19
%26 = load i32, i32* %25
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %18, %24
%29 = add nuw nsw i64 %19, 1
%30 = icmp eq i64 %29, %13
br i1 %30, label %31, label %18
31: ; preds = %28, %14
%32 = tail call i32 @putchar(i32 125)
%33 = icmp eq i32 %16, %5
br i1 %33, label %34, label %14
34: ; preds = %31, %4
%35 = tail call i32 @putchar(i32 10)
br label %36
36: ; preds = %2, %34
%37 = phi i32 [ 0, %34 ], [ -1, %2 ]
ret i32 %37
}