#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 *, ...);
int **subsets(int *, int, int **, int *);
int main(void) {
  int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 10, 0};
  int **res = NULL;
  int size = 0;
  int *columnSizes = NULL;
  res = subsets(arr, 10, &columnSizes, &size);
  printf("size = %d\n", size);
  for (int i = 0; i < size; i++) {
    printf("[");
    for (int j = 0; j < columnSizes[i]; j++) {
      printf("%d ", res[i][j]);
    }
    printf("]\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
movq   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movq   $0x0,-0x48(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0xa,%esi
lea    -0x48(%rbp),%rdx
lea    -0x3c(%rbp),%rcx
call   1050 <subsets@plt>
mov    %rax,-0x38(%rbp)
mov    -0x3c(%rbp),%esi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    121d <main+0xed>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
mov    -0x48(%rbp),%rcx
movslq -0x4c(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    1201 <main+0xd1>
mov    -0x38(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x50(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    11be <main+0x8e>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    119d <main+0x6d>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    0xecc(%rip),%rax
mov    %rax,0x30(%rsp)
movaps 0xeb0(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe94(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x4(%rsp)
movq   $0x0,0x8(%rsp)
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
mov    $0xa,%esi
call   1060 <subsets@plt>
mov    %rax,%r12
mov    0x4(%rsp),%esi
lea    0xe7f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0x4(%rsp)
jle    1225 <main+0xe5>
lea    0xe75(%rip),%r14
lea    0xe72(%rip),%r15
xor    %r13d,%r13d
jmp    11e6 <main+0xa6>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1040 <puts@plt>
add    $0x1,%r13
movslq 0x4(%rsp),%rax
cmp    %rax,%r13
jge    1225 <main+0xe5>
mov    $0x5b,%edi
call   1030 <putchar@plt>
mov    0x8(%rsp),%rax
cmpl   $0x0,(%rax,%r13,4)
jle    11d0 <main+0x90>
xor    %ebx,%ebx
xchg   %ax,%ax
mov    (%r12,%r13,8),%rax
mov    (%rax,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
mov    0x8(%rsp),%rax
movslq (%rax,%r13,4),%rax
cmp    %rax,%rbx
jl     1200 <main+0xc0>
jmp    11d0 <main+0x90>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@__const.main.arr = [10 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 10, i32 0]
@.str = [11 x i8] c"size = %d\0A\00"
@.str.2 = [4 x i8] c"%d \00"
@str = [2 x i8] c"]\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = alloca i32
%3 = alloca i32*
%4 = bitcast [10 x i32]* %1 to i8*
%5 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%6 = bitcast i32** %3 to i8*
store i32* null, i32** %3
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%8 = call i32** @subsets(i32* %7, i32 10, i32** %3, i32* %2)
%9 = load i32, i32* %2
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %2
%12 = icmp sgt i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %23, %0
ret i32 0
14: ; preds = %0, %23
%15 = phi i64 [ %25, %23 ], [ 0, %0 ]
%16 = call i32 @putchar(i32 91)
%17 = load i32*, i32** %3
%18 = getelementptr inbounds i32, i32* %17, i64 %15
%19 = load i32, i32* %18
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %14
%22 = getelementptr inbounds i32*, i32** %8, i64 %15
br label %29
23: ; preds = %29, %14
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%25 = add nuw nsw i64 %15, 1
%26 = load i32, i32* %2
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %25, %27
br i1 %28, label %14, label %13
29: ; preds = %21, %29
%30 = phi i64 [ 0, %21 ], [ %35, %29 ]
%31 = load i32*, i32** %22
%32 = getelementptr inbounds i32, i32* %31, i64 %30
%33 = load i32, i32* %32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = add nuw nsw i64 %30, 1
%36 = load i32*, i32** %3
%37 = getelementptr inbounds i32, i32* %36, i64 %15
%38 = load i32, i32* %37
%39 = sext i32 %38 to i64
%40 = icmp slt i64 %35, %39
br i1 %40, label %29, label %23
}