#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 subsets(int ls[], int size) {
  int bit, element;
  for (bit = 0; bit < (1 << (size)); bit++) {
    for (element = 0; element < size; element++) {
      if (bit & (1 << element))
        printf("%d, ", ls[element]);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<subsets>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
cmp    %ecx,%eax
jge    11b2 <subsets+0xa2>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1196 <subsets+0x86>
mov    -0x10(%rbp),%eax
mov    -0x14(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1183 <subsets+0x73>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1188 <subsets+0x78>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1144 <subsets+0x34>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <subsets+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<subsets>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,0x4(%rsp)
cmp    $0x1f,%esi
jne    1143 <subsets+0x23>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rdi,%r13
mov    $0x1,%r15d
mov    0x4(%rsp),%ecx
shl    %cl,%r15d
mov    $0x1,%eax
cmp    $0x2,%r15d
cmovl  %eax,%r15d
mov    %ecx,%ebp
lea    0xe97(%rip),%r12
xor    %ebx,%ebx
jmp    1182 <subsets+0x62>
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
cmp    %r15d,%ebx
je     1134 <subsets+0x14>
cmpl   $0x0,0x4(%rsp)
jle    1170 <subsets+0x50>
xor    %r14d,%r14d
jmp    1199 <subsets+0x79>
xchg   %ax,%ax
add    $0x1,%r14
cmp    %r14,%rbp
je     1170 <subsets+0x50>
bt     %r14d,%ebx
jae    1190 <subsets+0x70>
mov    0x0(%r13,%r14,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1190 <subsets+0x70>

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

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