#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*/ printArr(int *, int);
void combine(int *arr, int len, int pos) {
  if (pos >= len) {
    printArr(arr, len);
    return;
  }
  arr[pos] = 0;
  combine(arr, len, pos + 1);
  arr[pos] = 1;
  combine(arr, len, pos + 1);
}


x86 assembly (clang, -O0):
<combine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     114f <combine+0x2f>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <printArr@plt>
jmp    1191 <combine+0x71>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
add    $0x1,%edx
call   1030 <combine@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
add    $0x1,%edx
call   1030 <combine@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<combine>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%r12
cmp    %esi,%edx
jge    116c <combine+0x4c>
mov    %edx,%ebp
movslq %edx,%rbx
movslq %r14d,%r15
add    $0x1,%ebp
movl   $0x0,(%r12,%rbx,4)
lea    0x1(%rbx),%r13
mov    %r12,%rdi
mov    %r14d,%esi
mov    %ebp,%edx
call   1030 <combine@plt>
movl   $0x1,(%r12,%rbx,4)
add    $0x1,%ebp
mov    %r13,%rbx
cmp    %r13,%r15
jne    1140 <combine+0x20>
mov    %r12,%rdi
mov    %r14d,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printArr@plt>

LLVM IR (-O0):
define void @combine(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %6
%8 = load i32, i32* %5
%9 = icmp sge i32 %7, %8
br i1 %9, label %10, label %14
10: ; preds = %3
%11 = load i32*, i32** %4
%12 = load i32, i32* %5
%13 = call i32 @printArr(i32* %11, i32 %12)
br label %31
14: ; preds = %3
%15 = load i32*, i32** %4
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
store i32 0, i32* %18
%19 = load i32*, i32** %4
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
%23 = load i32*, i32** %4
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %23, i64 %25
store i32 1, i32* %26
%27 = load i32*, i32** %4
%28 = load i32, i32* %5
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
br label %31
31: ; preds = %14, %10
ret void
}

LLVM IR (-O2):
define void @combine(i32* %0, i32 %1, i32 %2) {
%4 = icmp slt i32 %2, %1
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = sext i32 %2 to i64
%7 = sext i32 %1 to i64
br label %10
8: ; preds = %10, %3
%9 = tail call i32 @printArr(i32* %0, i32 %1)
ret void
10: ; preds = %5, %10
%11 = phi i64 [ %6, %5 ], [ %13, %10 ]
%12 = getelementptr inbounds i32, i32* %0, i64 %11
store i32 0, i32* %12
%13 = add nsw i64 %11, 1
%14 = trunc i64 %13 to i32
tail call void @combine(i32* %0, i32 %1, i32 %14)
store i32 1, i32* %12
%15 = icmp eq i64 %13, %7
br i1 %15, label %8, label %10
}