#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*/ assert(int);
int /*<<< orphan*/ pool_create_maxalloc();
int /*<<< orphan*/ pool_destroy();
unsigned int powerset(char ***, char **, unsigned int, unsigned int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ read_args(unsigned int *, unsigned int *, char ***);
int /*<<< orphan*/ set_print(char **, unsigned int);
int /*<<< orphan*/ system(char *);
int main(void) {
  unsigned k, n, pcard;
  char **set = NULL, **pset = NULL;
  printf("[MemPool -> ALLOC]\n");
  pool_create_maxalloc();
  printf("[MemPool -> OK]\n\n");
  read_args(&k, &n, &set);
  assert(k >= 1 && n >= 0);
  pcard = powerset(&pset, set, n, k);
  printf("\nP(A) = ");
  set_print(pset, pcard);
  printf("\n\n");
  system("PAUSE");
  pool_destroy();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
lea    0xe5a(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <pool_create_maxalloc@plt>
lea    0xe5b(%rip),%rdi
call   1040 <printf@plt>
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1080 <read_args@plt>
xor    %eax,%eax
cmpl   $0x1,-0x8(%rbp)
mov    %al,-0x21(%rbp)
jb     11e8 <main+0x68>
cmpl   $0x0,-0xc(%rbp)
setae  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    -0x20(%rbp),%rdi
call   1050 <powerset@plt>
mov    %eax,-0x10(%rbp)
lea    0xe14(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1090 <set_print@plt>
lea    0xdf9(%rip),%rdi
call   1040 <printf@plt>
lea    0xdf9(%rip),%rdi
call   1030 <system@plt>
mov    $0x0,%al
call   10a0 <pool_destroy@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movq   $0x0,0x18(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xe61(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1070 <pool_create_maxalloc@plt>
lea    0xe61(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rdi
lea    0xc(%rsp),%rsi
lea    0x18(%rsp),%rdx
call   1090 <read_args@plt>
xor    %edi,%edi
cmpl   $0x0,0x8(%rsp)
setne  %dil
call   1080 <assert@plt>
mov    0x18(%rsp),%rsi
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    0x10(%rsp),%rdi
call   1060 <powerset@plt>
mov    %eax,%ebx
lea    0xdf6(%rip),%rdi
call   1050 <printf@plt>
mov    0x10(%rsp),%rdi
mov    %ebx,%esi
call   10a0 <set_print@plt>
lea    0xe0f(%rip),%rdi
call   1030 <puts@plt>
lea    0xddb(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
call   10b0 <pool_destroy@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"[MemPool -> ALLOC]\0A\00"
@.str.1 = [18 x i8] c"[MemPool -> OK]\0A\0A\00"
@.str.2 = [9 x i8] c"\0AP(A) = \00"
@.str.3 = [3 x i8] c"\0A\0A\00"
@.str.4 = [6 x i8] c"PAUSE\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8**
store i32 0, i32* %1
store i8** null, i8*** %5
store i8** null, i8*** %6
%7 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (...) @pool_create_maxalloc()
%9 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @read_args(i32* %2, i32* %3, i8*** %5)
%11 = load i32, i32* %2
%12 = icmp uge i32 %11, 1
br i1 %12, label %13, label %16
13: ; preds = %0
%14 = load i32, i32* %3
%15 = icmp uge i32 %14, 0
br label %16
16: ; preds = %13, %0
%17 = phi i1 [ false, %0 ], [ %15, %13 ]
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = load i8**, i8*** %5
%21 = load i32, i32* %3
%22 = load i32, i32* %2
%23 = call i32 @powerset(i8*** %6, i8** %20, i32 %21, i32 %22)
store i32 %23, i32* %4
%24 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%25 = load i8**, i8*** %6
%26 = load i32, i32* %4
%27 = call i32 @set_print(i8** %25, i32 %26)
%28 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%29 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%30 = call i32 (...) @pool_destroy()
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [9 x i8] c"\0AP(A) = \00"
@.str.4 = [6 x i8] c"PAUSE\00"
@str = [19 x i8] c"[MemPool -> ALLOC]\00"
@str.5 = [17 x i8] c"[MemPool -> OK]\0A\00"
@str.6 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8**
%4 = alloca i8**
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i8*** %3 to i8*
store i8** null, i8*** %3
%8 = bitcast i8*** %4 to i8*
store i8** null, i8*** %4
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 (...) @pool_create_maxalloc()
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.5, i64 0, i64 0))
%12 = call i32 @read_args(i32* %1, i32* %2, i8*** %3)
%13 = load i32, i32* %1
%14 = icmp ne i32 %13, 0
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = load i8**, i8*** %3
%18 = load i32, i32* %2
%19 = load i32, i32* %1
%20 = call i32 @powerset(i8*** %4, i8** %17, i32 %18, i32 %19)
%21 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%22 = load i8**, i8*** %4
%23 = call i32 @set_print(i8** %22, i32 %20)
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.6, i64 0, i64 0))
%25 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%26 = call i32 (...) @pool_destroy()
ret i32 0
}