#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*/ print_powerset(int *, int);
void powerset(int a[], int len, int pos, int p[], int p_len) {
  if (len == pos) {
    print_powerset(p, p_len);
    return;
  }
  powerset(a, len, pos + 1, p, p_len);
  p[p_len] = a[pos];
  powerset(a, len, pos + 1, p, p_len + 1);
  return;
}


x86 assembly (clang, -O0):
<powerset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    1157 <powerset+0x37>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <print_powerset@plt>
jmp    11a5 <powerset+0x85>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
add    $0x1,%edx
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
call   1040 <powerset@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
add    $0x1,%edx
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
add    $0x1,%r8d
call   1040 <powerset@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<powerset>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,%r14
mov    %rdi,0x10(%rsp)
mov    %esi,%ebx
sub    %edx,%ebx
je     11bd <powerset+0x9d>
mov    %rdx,%rdi
mov    %r8d,0xc(%rsp)
movslq %r8d,%rax
movslq %edi,%rdx
mov    0x10(%rsp),%rbp
lea    0x0(,%rdx,4),%rdx
add    %rbp,%rdx
mov    %rdx,0x18(%rsp)
add    $0x1,%edi
mov    %rdi,0x20(%rsp)
mov    %eax,%r12d
lea    (%r14,%rax,4),%r13
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
lea    (%r12,%r15,1),%r8d
mov    0x20(%rsp),%rax
lea    (%rax,%r15,1),%edx
mov    0x10(%rsp),%rdi
mov    %esi,%ebp
mov    %r14,%rcx
call   1040 <powerset@plt>
mov    %ebp,%esi
mov    0x18(%rsp),%rax
mov    (%rax,%r15,4),%eax
mov    %eax,0x0(%r13,%r15,4)
add    $0x1,%r15
cmp    %r15d,%ebx
jne    1180 <powerset+0x60>
mov    0xc(%rsp),%r8d
add    %r15d,%r8d
mov    %r14,%rdi
mov    %r8d,%esi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <print_powerset@plt>

LLVM IR (-O0):
define void @powerset(i32* %0, i32 %1, i32 %2, i32* %3, i32 %4) {
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32* %3, i32** %9
store i32 %4, i32* %10
%11 = load i32, i32* %7
%12 = load i32, i32* %8
%13 = icmp eq i32 %11, %12
br i1 %13, label %14, label %18
14: ; preds = %5
%15 = load i32*, i32** %9
%16 = load i32, i32* %10
%17 = call i32 @print_powerset(i32* %15, i32 %16)
br label %41
18: ; preds = %5
%19 = load i32*, i32** %6
%20 = load i32, i32* %7
%21 = load i32, i32* %8
%22 = add nsw i32 %21, 1
%23 = load i32*, i32** %9
%24 = load i32, i32* %10
%25 = load i32*, i32** %6
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = load i32, i32* %28
%30 = load i32*, i32** %9
%31 = load i32, i32* %10
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
store i32 %29, i32* %33
%34 = load i32*, i32** %6
%35 = load i32, i32* %7
%36 = load i32, i32* %8
%37 = add nsw i32 %36, 1
%38 = load i32*, i32** %9
%39 = load i32, i32* %10
%40 = add nsw i32 %39, 1
br label %41
41: ; preds = %18, %14
ret void
}

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