#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*/ islast(int, int *);
int /*<<< orphan*/ printf(char *, ...);
void ft_comb(int n, int nb[], int index) {
  int count;
  count = 0;
  if (index == n) {
    for (int i = 0; i < n; i++)
      printf("%d", nb[i]);
    if (!islast(n, nb))
      printf(", ");
    return;
  }
  while (count < 10) {
    if (index > 0 && nb[index - 1] >= count) {
      count++;
      continue;
    } else {
      nb[index] = count;
      ft_comb(n, nb, index + 1);
    }
    count++;
  }
}


x86 assembly (clang, -O0):
<ft_comb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jne    11b7 <ft_comb+0x87>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    118f <ft_comb+0x5f>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115c <ft_comb+0x2c>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <islast@plt>
cmp    $0x0,%eax
jne    11b2 <ft_comb+0x82>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1225 <ft_comb+0xf5>
jmp    11bc <ft_comb+0x8c>
cmpl   $0xa,-0x18(%rbp)
jge    1225 <ft_comb+0xf5>
cmpl   $0x0,-0x14(%rbp)
jle    11f7 <ft_comb+0xc7>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x18(%rbp),%eax
jl     11f7 <ft_comb+0xc7>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11bc <ft_comb+0x8c>
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
add    $0x1,%edx
call   1030 <ft_comb@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11bc <ft_comb+0x8c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_comb>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r12d
mov    %rsi,%r13
cmp    %edi,%edx
jne    11a7 <ft_comb+0x77>
test   %r12d,%r12d
jle    1178 <ft_comb+0x48>
mov    %r12d,%ebx
lea    0xeac(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    0x0(%r13,%rbp,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1160 <ft_comb+0x30>
mov    %r12d,%edi
mov    %r13,%rsi
call   1050 <islast@plt>
test   %eax,%eax
jne    12c9 <ft_comb+0x199>
lea    0xe71(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>
mov    %edi,%r15d
lea    0x1(%r12),%r14d
movslq %r12d,%rbp
test   %r12d,%r12d
jle    12d8 <ft_comb+0x1a8>
add    $0xffffffff,%r12d
mov    0x0(%r13,%r12,4),%eax
test   %eax,%eax
js     13cc <ft_comb+0x29c>
test   %eax,%eax
jle    13f0 <ft_comb+0x2c0>
mov    0x0(%r13,%r12,4),%eax
cmp    $0x1,%eax
jg     11fa <ft_comb+0xca>
movl   $0x2,0x0(%r13,%rbp,4)
mov    %r15d,%edi
mov    %r13,%rsi
mov    %r14d,%edx
call   1030 <ft_comb@plt>
mov    0x0(%r13,%r12,4),%eax
cmp    $0x2,%eax
jg     1216 <ft_comb+0xe6>
movl   $0x3,0x0(%r13,%rbp,4)
mov    %r15d,%edi
mov    %r13,%rsi
mov    %r14d,%edx
call   1030 <ft_comb@plt>
mov    0x0(%r13,%r12,4),%eax
cmp    $0x3,%eax
jg     123c <ft_comb+0x10c>
movl   $0x4,0x0(%r13,%rbp,4)
mov    %r15d,%edi
mov    %r13,%rsi
mov    %r14d,%edx
call   1030 <ft_comb@plt>
mov    0x0(%r13,%r12,4),%eax
cmp    $0x4,%eax
jg     1258 <ft_comb+0x128>
movl   $0x5,0x0(%r13,%rbp,4)
mov    %r15d,%edi
mov    %r13,%rsi
mov    %r14d,%edx
call   1030 <ft_comb@plt>
mov    0x0(%r13,%r12,4),%eax
cmp    $0x5,%eax
jg     127e <ft_comb+0x14e>
movl   $0x6,0x0(%r13,%rbp,4)
mov    %r15d,%edi
mov    %r13,%rsi
mov    %r14d,%edx
call   1030 <ft_comb@plt>
mov    0x0(%r13,%r12,4),%eax
cmp    $0x6,%eax
jg     129a <ft_comb+0x16a>
movl   $0x7,0x0(%r13,%rbp,4)
mov    %r15d,%edi
mov    %r13,%rsi
mov    %r14d,%edx
call   1030 <ft_comb@plt>
mov    0x0(%r13,%r12,4),%eax
cmp    $0x7,%eax
jg     12c0 <ft_comb+0x190>
movl   $0x8,0x0(%r13,%rbp,4)
mov    %r15d,%edi
mov    %r13,%rsi
mov    %r14d,%edx
call   1030 <ft_comb@plt>
mov    0x0(%r13,%r12,4),%eax
cmp    $0x8,%eax
jle    13a7 <ft_comb+0x277>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movl   $0x0,0x0(%r13,%rbp,4)
mov    %r15d,%edi
mov    %r13,%rsi
mov    %r14d,%edx
call   1030 <ft_comb@plt>
movl   $0x1,0x0(%r13,%rbp,4)
mov    %r15d,%edi
mov    %r13,%rsi
mov    %r14d,%edx
call   1030 <ft_comb@plt>
movl   $0x2,0x0(%r13,%rbp,4)
mov    %r15d,%edi
mov    %r13,%rsi
mov    %r14d,%edx
call   1030 <ft_comb@plt>
movl   $0x3,0x0(%r13,%rbp,4)
mov    %r15d,%edi
mov    %r13,%rsi
mov    %r14d,%edx
call   1030 <ft_comb@plt>
movl   $0x4,0x0(%r13,%rbp,4)
mov    %r15d,%edi
mov    %r13,%rsi
mov    %r14d,%edx
call   1030 <ft_comb@plt>
movl   $0x5,0x0(%r13,%rbp,4)
mov    %r15d,%edi
mov    %r13,%rsi
mov    %r14d,%edx
call   1030 <ft_comb@plt>
movl   $0x6,0x0(%r13,%rbp,4)
mov    %r15d,%edi
mov    %r13,%rsi
mov    %r14d,%edx
call   1030 <ft_comb@plt>
movl   $0x7,0x0(%r13,%rbp,4)
mov    %r15d,%edi
mov    %r13,%rsi
mov    %r14d,%edx
call   1030 <ft_comb@plt>
movl   $0x8,0x0(%r13,%rbp,4)
mov    %r15d,%edi
mov    %r13,%rsi
mov    %r14d,%edx
call   1030 <ft_comb@plt>
movl   $0x9,0x0(%r13,%rbp,4)
mov    %r15d,%edi
mov    %r13,%rsi
mov    %r14d,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <ft_comb@plt>
movl   $0x0,0x0(%r13,%rbp,4)
mov    %r15d,%edi
mov    %r13,%rsi
mov    %r14d,%edx
call   1030 <ft_comb@plt>
mov    0x0(%r13,%r12,4),%eax
test   %eax,%eax
jg     11d4 <ft_comb+0xa4>
movl   $0x1,0x0(%r13,%rbp,4)
mov    %r15d,%edi
mov    %r13,%rsi
mov    %r14d,%edx
call   1030 <ft_comb@plt>
jmp    11d4 <ft_comb+0xa4>

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

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