#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_combination(int *chars, int len, int m, int *visitedIdx,
                       int visitedLen) {
  int i = 0;
  if (m == 0) {
    for (i = 0; i < visitedLen; i++) {
      printf("%d", chars[visitedIdx[i]]);
    }
    printf("\n");
    return;
  }
  int smallest = visitedLen == 0 ? 0 : visitedIdx[visitedLen - 1] + 1;
  for (i = smallest; i < len; i++) {
    visitedIdx[visitedLen] = i;
    print_combination(chars, len, m - 1, visitedIdx, visitedLen + 1);
  }
}


x86 assembly (clang, -O0):
<print_combination>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    11a0 <print_combination+0x80>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    118d <print_combination+0x6d>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq -0x20(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1152 <print_combination+0x32>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121c <print_combination+0xfc>
cmpl   $0x0,-0x1c(%rbp)
jne    11b4 <print_combination+0x94>
xor    %eax,%eax
mov    %eax,-0x28(%rbp)
jmp    11ca <print_combination+0xaa>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    121c <print_combination+0xfc>
mov    -0x20(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
sub    $0x1,%edx
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
add    $0x1,%r8d
call   1040 <print_combination@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11d6 <print_combination+0xb6>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_combination>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %rdi,%r14
test   %edx,%edx
je     1162 <print_combination+0x32>
mov    %esi,%ebp
movslq %r8d,%r12
test   %r8d,%r8d
je     11b3 <print_combination+0x83>
mov    -0x4(%rbx,%r12,4),%r15d
add    $0x1,%r15d
cmp    %ebp,%r15d
jl     11bb <print_combination+0x8b>
jmp    11fa <print_combination+0xca>
test   %r8d,%r8d
jle    119b <print_combination+0x6b>
mov    %r8d,%r12d
lea    0xe8f(%rip),%r15
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movslq (%rbx,%rbp,4),%rax
mov    (%r14,%rax,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1180 <print_combination+0x50>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
xor    %r15d,%r15d
cmp    %ebp,%r15d
jge    11fa <print_combination+0xca>
add    $0xffffffff,%edx
add    $0x1,%r8d
mov    %r14,(%rsp)
cs nopw 0x0(%rax,%rax,1)
mov    %r15d,(%rbx,%r12,4)
mov    %r14,%rdi
mov    %ebp,%esi
mov    %edx,%r14d
mov    %rbx,%rcx
mov    %r8d,%r13d
call   1050 <print_combination@plt>
mov    %r14d,%edx
mov    (%rsp),%r14
mov    %r13d,%r8d
add    $0x1,%r15d
cmp    %r15d,%ebp
jne    11d0 <print_combination+0xa0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @print_combination(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
%12 = 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
store i32 0, i32* %11
%13 = load i32, i32* %8
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %36
15: ; preds = %5
store i32 0, i32* %11
br label %16
16: ; preds = %31, %15
%17 = load i32, i32* %11
%18 = load i32, i32* %10
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %34
20: ; preds = %16
%21 = load i32*, i32** %6
%22 = load i32*, i32** %9
%23 = load i32, i32* %11
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = load i32, i32* %25
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %21, i64 %27
%29 = load i32, i32* %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %20
%32 = load i32, i32* %11
%33 = add nsw i32 %32, 1
store i32 %33, i32* %11
br label %16
34: ; preds = %16
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %71
36: ; preds = %5
%37 = load i32, i32* %10
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %36
br label %48
40: ; preds = %36
%41 = load i32*, i32** %9
%42 = load i32, i32* %10
%43 = sub nsw i32 %42, 1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %41, i64 %44
%46 = load i32, i32* %45
%47 = add nsw i32 %46, 1
br label %48
48: ; preds = %40, %39
%49 = phi i32 [ 0, %39 ], [ %47, %40 ]
store i32 %49, i32* %12
%50 = load i32, i32* %12
store i32 %50, i32* %11
br label %51
51: ; preds = %68, %48
%52 = load i32, i32* %11
%53 = load i32, i32* %7
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %71
55: ; preds = %51
%56 = load i32, i32* %11
%57 = load i32*, i32** %9
%58 = load i32, i32* %10
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i32, i32* %57, i64 %59
store i32 %56, i32* %60
%61 = load i32*, i32** %6
%62 = load i32, i32* %7
%63 = load i32, i32* %8
%64 = sub nsw i32 %63, 1
%65 = load i32*, i32** %9
%66 = load i32, i32* %10
%67 = add nsw i32 %66, 1
br label %68
68: ; preds = %55
%69 = load i32, i32* %11
%70 = add nsw i32 %69, 1
store i32 %70, i32* %11
br label %51
71: ; preds = %34, %51
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define void @print_combination(i32* nocapture %0, i32 %1, i32 %2, i32* nocapture %3, i32 %4) {
%6 = icmp eq i32 %2, 0
br i1 %6, label %7, label %23
7: ; preds = %5
%8 = icmp sgt i32 %4, 0
br i1 %8, label %9, label %21
9: ; preds = %7
%10 = zext i32 %4 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %19, %11 ]
%13 = getelementptr inbounds i32, i32* %3, i64 %12
%14 = load i32, i32* %13
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %0, i64 %15
%17 = load i32, i32* %16
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = add nuw nsw i64 %12, 1
%20 = icmp eq i64 %19, %10
br i1 %20, label %21, label %11
21: ; preds = %11, %7
%22 = tail call i32 @putchar(i32 10)
br label %43
23: ; preds = %5
%24 = icmp eq i32 %4, 0
br i1 %24, label %31, label %25
25: ; preds = %23
%26 = add nsw i32 %4, -1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %3, i64 %27
%29 = load i32, i32* %28
%30 = add nsw i32 %29, 1
br label %31
31: ; preds = %23, %25
%32 = phi i32 [ %30, %25 ], [ 0, %23 ]
%33 = icmp slt i32 %32, %1
br i1 %33, label %34, label %43
34: ; preds = %31
%35 = sext i32 %4 to i64
%36 = getelementptr inbounds i32, i32* %3, i64 %35
%37 = add nsw i32 %2, -1
%38 = add nsw i32 %4, 1
br label %39
39: ; preds = %34, %39
%40 = phi i32 [ %32, %34 ], [ %41, %39 ]
store i32 %40, i32* %36
tail call void @print_combination(i32* %0, i32 %1, i32 %37, i32* %3, i32 %38)
%41 = add i32 %40, 1
%42 = icmp eq i32 %41, %1
br i1 %42, label %43, label %39
43: ; preds = %39, %31, %21
ret void
}