#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 print_subset(int n, int s) {
  for (int i = 0; i < n; i++) {
    if (s & (1 << i))
      printf("%d ", i);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_subset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    116f <print_subset+0x5f>
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     115c <print_subset+0x4c>
mov    -0xc(%rbp),%esi
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1161 <print_subset+0x51>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1125 <print_subset+0x15>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_subset>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
jle    115b <print_subset+0x3b>
mov    %esi,%r15d
mov    %edi,%ebp
lea    0xec9(%rip),%r14
xor    %ebx,%ebx
jmp    1147 <print_subset+0x27>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    %ebx,%ebp
je     115b <print_subset+0x3b>
bt     %ebx,%r15d
jae    1140 <print_subset+0x20>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1140 <print_subset+0x20>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @print_subset(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %20, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %3
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %23
10: ; preds = %6
%11 = load i32, i32* %4
%12 = load i32, i32* %5
%13 = shl i32 1, %12
%14 = and i32 %11, %13
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %10
%17 = load i32, i32* %5
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %16, %10
br label %20
20: ; preds = %19
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %6
23: ; preds = %6
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define void @print_subset(i32 %0, i32 %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %6, label %4
4: ; preds = %13, %2
%5 = tail call i32 @putchar(i32 10)
ret void
6: ; preds = %2, %13
%7 = phi i32 [ %14, %13 ], [ 0, %2 ]
%8 = shl nuw i32 1, %7
%9 = and i32 %8, %1
%10 = icmp eq i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %6
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %13
13: ; preds = %6, %11
%14 = add nuw nsw i32 %7, 1
%15 = icmp eq i32 %14, %0
br i1 %15, label %4, label %6
}