#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*/ print_combo(int, int *);
void generate_recurse(int positions, int combo[positions], int set_size,
                      int set[set_size], int level) {
  int i;
  if (level == positions) {
    print_combo(positions, combo);
    return;
  }
  for (i = 0; i < set_size; i++) {
    combo[level] = set[i];
    generate_recurse(positions, combo, set_size, set, level + 1);
  }
}


x86 assembly (clang, -O0):
<generate_recurse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jne    1157 <generate_recurse+0x37>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <print_combo@plt>
jmp    11a9 <generate_recurse+0x89>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11a9 <generate_recurse+0x89>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
add    $0x1,%r8d
call   1030 <generate_recurse@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    115e <generate_recurse+0x3e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_recurse>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,%r14d
mov    %edx,0xc(%rsp)
mov    %rsi,%rbx
cmp    %edi,%r8d
jne    1156 <generate_recurse+0x36>
mov    %r14d,%edi
mov    %rbx,%rsi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <print_combo@plt>
cmpl   $0x0,0xc(%rsp)
jle    11ab <generate_recurse+0x8b>
mov    %rcx,%rbp
mov    %edi,%r13d
movslq %r14d,%rax
mov    %rax,0x10(%rsp)
add    $0x1,%r14d
mov    0xc(%rsp),%r15d
xor    %r12d,%r12d
nopw   0x0(%rax,%rax,1)
mov    0x0(%rbp,%r12,4),%eax
mov    0x10(%rsp),%rcx
mov    %eax,(%rbx,%rcx,4)
mov    %r13d,%edi
mov    %rbx,%rsi
mov    0xc(%rsp),%edx
mov    %rbp,%rcx
mov    %r14d,%r8d
call   1030 <generate_recurse@plt>
add    $0x1,%r12
cmp    %r12,%r15
jne    1180 <generate_recurse+0x60>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @generate_recurse(i32 %0, i32* %1, i32 %2, i32* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %6
store i32* %1, i32** %7
store i32 %2, i32* %8
store i32* %3, i32** %9
store i32 %4, i32* %10
%12 = load i32, i32* %6
%13 = zext i32 %12 to i64
%14 = load i32, i32* %8
%15 = zext i32 %14 to i64
%16 = load i32, i32* %10
%17 = load i32, i32* %6
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %23
19: ; preds = %5
%20 = load i32, i32* %6
%21 = load i32*, i32** %7
%22 = call i32 @print_combo(i32 %20, i32* %21)
br label %47
23: ; preds = %5
store i32 0, i32* %11
br label %24
24: ; preds = %44, %23
%25 = load i32, i32* %11
%26 = load i32, i32* %8
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %47
28: ; preds = %24
%29 = load i32*, i32** %9
%30 = load i32, i32* %11
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
%33 = load i32, i32* %32
%34 = load i32*, i32** %7
%35 = load i32, i32* %10
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
store i32 %33, i32* %37
%38 = load i32, i32* %6
%39 = load i32*, i32** %7
%40 = load i32, i32* %8
%41 = load i32*, i32** %9
%42 = load i32, i32* %10
%43 = add nsw i32 %42, 1
br label %44
44: ; preds = %28
%45 = load i32, i32* %11
%46 = add nsw i32 %45, 1
store i32 %46, i32* %11
br label %24
47: ; preds = %19, %24
ret void
}

LLVM IR (-O2):
define void @generate_recurse(i32 %0, i32* %1, i32 %2, i32* nocapture %3, i32 %4) {
%6 = icmp eq i32 %4, %0
br i1 %6, label %14, label %7
7: ; preds = %5
%8 = icmp sgt i32 %2, 0
br i1 %8, label %9, label %22
9: ; preds = %7
%10 = sext i32 %4 to i64
%11 = getelementptr inbounds i32, i32* %1, i64 %10
%12 = add nsw i32 %4, 1
%13 = zext i32 %2 to i64
br label %16
14: ; preds = %5
%15 = tail call i32 @print_combo(i32 %4, i32* %1)
br label %22
16: ; preds = %9, %16
%17 = phi i64 [ 0, %9 ], [ %20, %16 ]
%18 = getelementptr inbounds i32, i32* %3, i64 %17
%19 = load i32, i32* %18
store i32 %19, i32* %11
tail call void @generate_recurse(i32 %0, i32* %1, i32 %2, i32* %3, i32 %12)
%20 = add nuw nsw i64 %17, 1
%21 = icmp eq i64 %20, %13
br i1 %21, label %22, label %16
22: ; preds = %16, %7, %14
ret void
}