#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 list_combination(int a[], size_t n) {
  for (int i = 0; i < (1 << n); i++) {
    int printed = 0;
    char *sep = "";
    for (int j = 0; j < n; j++) {
      if ((i >> j) & 0x01) {
        printed = 1;
        printf("%s%d", sep, a[j]);
        sep = ", ";
      }
    }
    if (printed) {
      printf("\n");
    }
  }
}


x86 assembly (clang, -O0):
<list_combination>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
cmp    %ecx,%eax
jge    11e7 <list_combination+0xd7>
movl   $0x0,-0x18(%rbp)
lea    0xebc(%rip),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11bc <list_combination+0xac>
mov    -0x14(%rbp),%eax
mov    -0x24(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11a9 <list_combination+0x99>
movl   $0x1,-0x18(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe60(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11ae <list_combination+0x9e>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1158 <list_combination+0x48>
cmpl   $0x0,-0x18(%rbp)
je     11d4 <list_combination+0xc4>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d9 <list_combination+0xc9>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <list_combination+0x17>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<list_combination>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x1f,%ebx
jne    1142 <list_combination+0x22>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rdi,%r14
mov    $0x1,%edx
mov    %ebx,%ecx
shl    %cl,%edx
mov    $0x1,%eax
cmp    $0x2,%edx
cmovl  %eax,%edx
mov    %edx,0x4(%rsp)
lea    0xe9c(%rip),%r15
lea    0xe9a(%rip),%rbp
xor    %r12d,%r12d
jmp    117b <list_combination+0x5b>
add    $0x1,%r12d
cmp    0x4(%rsp),%r12d
je     1133 <list_combination+0x13>
test   %rbx,%rbx
je     1170 <list_combination+0x50>
xor    %r13d,%r13d
lea    0xe7d(%rip),%rsi
xor    %eax,%eax
jmp    1199 <list_combination+0x79>
xchg   %ax,%ax
add    $0x1,%r13
cmp    %r13,%rbx
je     11c0 <list_combination+0xa0>
bt     %r13d,%r12d
jae    1190 <list_combination+0x70>
mov    (%r14,%r13,4),%edx
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
mov    %rbp,%rsi
jmp    1190 <list_combination+0x70>
nopw   0x0(%rax,%rax,1)
test   %eax,%eax
je     1170 <list_combination+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1170 <list_combination+0x50>

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

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