#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 atoi(char *);
int **combinationSum3(int, int, int *, int **);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (argc != 3) {
    fprintf(stderr, "Usage: ./test k n\n");
    exit(-1);
  }
  int i, j;
  int k = atoi(argv[1]);
  int n = atoi(argv[2]);
  int *sizes, count = 0;
  int **lists = combinationSum3(k, n, &count, &sizes);
  for (i = 0; i < count; i++) {
    for (j = 0; j < sizes[i]; j++) {
      printf("%d ", lists[i][j]);
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     118f <main+0x3f>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
lea    -0x2c(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1050 <combinationSum3@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1246 <main+0xf6>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x28(%rbp),%rcx
movslq -0x14(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    122a <main+0xda>
mov    -0x38(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e7 <main+0x97>
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d4 <main+0x84>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
cmp    $0x3,%edi
jne    1222 <main+0xc2>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   1070 <atoi@plt>
movl   $0x0,0xc(%rsp)
lea    0xc(%rsp),%rdx
lea    0x10(%rsp),%rcx
mov    %ebp,%edi
mov    %eax,%esi
call   1060 <combinationSum3@plt>
cmpl   $0x0,0xc(%rsp)
jle    1215 <main+0xb5>
mov    %rax,%r15
lea    0xe5d(%rip),%r14
xor    %ebp,%ebp
jmp    11d8 <main+0x78>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
movslq 0xc(%rsp),%rax
cmp    %rax,%rbp
jge    1215 <main+0xb5>
mov    0x10(%rsp),%rax
cmpl   $0x0,(%rax,%rbp,4)
jle    11c0 <main+0x60>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r15,%rbp,8),%rax
mov    (%rax,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
mov    0x10(%rsp),%rax
movslq (%rax,%rbp,4),%rax
cmp    %rax,%rbx
jl     11f0 <main+0x90>
jmp    11c0 <main+0x60>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2db7(%rip),%rax
mov    (%rax),%edi
lea    0xdce(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [19 x i8] c"Usage: ./test k n\0A\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%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* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @exit(i32 -1)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %8
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @atoi(i8* %26)
store i32 %27, i32* %9
store i32 0, i32* %11
%28 = load i32, i32* %8
%29 = load i32, i32* %9
%30 = call i32** @combinationSum3(i32 %28, i32 %29, i32* %11, i32** %10)
store i32** %30, i32*** %12
store i32 0, i32* %6
br label %31
31: ; preds = %60, %19
%32 = load i32, i32* %6
%33 = load i32, i32* %11
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %63
35: ; preds = %31
store i32 0, i32* %7
br label %36
36: ; preds = %55, %35
%37 = load i32, i32* %7
%38 = load i32*, i32** %10
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %38, i64 %40
%42 = load i32, i32* %41
%43 = icmp slt i32 %37, %42
br i1 %43, label %44, label %58
44: ; preds = %36
%45 = load i32**, i32*** %12
%46 = load i32, i32* %6
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32*, i32** %45, i64 %47
%49 = load i32*, i32** %48
%50 = load i32, i32* %7
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i32, i32* %49, i64 %51
%53 = load i32, i32* %52
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %53)
br label %55
55: ; preds = %44
%56 = load i32, i32* %7
%57 = add nsw i32 %56, 1
store i32 %57, i32* %7
br label %36
58: ; preds = %36
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %60
60: ; preds = %58
%61 = load i32, i32* %6
%62 = add nsw i32 %61, 1
store i32 %62, i32* %6
br label %31
63: ; preds = %31
ret i32 0
}

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