#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 **combine(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 n k\n");
    exit(-1);
  }
  int n = atoi(argv[1]);
  int k = atoi(argv[2]);
  if (k > n) {
    fprintf(stderr, "n(=%d) must larger than k(=%d)\n", n, k);
    exit(-1);
  }
  int i, j, *col_sizes, count = 0;
  int **lists = combine(n, k, &count, &col_sizes);
  for (i = 0; i < count; i++) {
    for (j = 0; j < col_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     1191 <main+0x41>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    11e4 <main+0x94>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe40(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
lea    -0x2c(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1040 <combine@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    127b <main+0x12b>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x28(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    125f <main+0x10f>
mov    -0x38(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    121c <main+0xcc>
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1209 <main+0xb9>
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    1232 <main+0xd2>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   1070 <atoi@plt>
cmp    %ebp,%eax
jg     1253 <main+0xf3>
movl   $0x0,0xc(%rsp)
lea    0xc(%rsp),%rdx
lea    0x10(%rsp),%rcx
mov    %ebp,%edi
mov    %eax,%esi
call   1050 <combine@plt>
cmpl   $0x0,0xc(%rsp)
jle    1225 <main+0xc5>
mov    %rax,%r15
lea    0xe75(%rip),%r14
xor    %ebp,%ebp
jmp    11e8 <main+0x88>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
movslq 0xc(%rsp),%rax
cmp    %rax,%rbp
jge    1225 <main+0xc5>
mov    0x10(%rsp),%rax
cmpl   $0x0,(%rax,%rbp,4)
jle    11d0 <main+0x70>
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     1200 <main+0xa0>
jmp    11d0 <main+0x70>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2da7(%rip),%rax
mov    (%rax),%edi
lea    0xdbe(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    0x2d86(%rip),%rcx
mov    (%rcx),%edi
lea    0xdb0(%rip),%rsi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [19 x i8] c"Usage: ./test n k\0A\00"
@.str.1 = [32 x i8] c"n(=%d) must larger than k(=%d)\0A\00"
@.str.2 = [4 x i8] c"%d \00"
@.str.3 = [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 (i32, i8*, ...) @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* %6
%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* %7
%28 = load i32, i32* %7
%29 = load i32, i32* %6
%30 = icmp sgt i32 %28, %29
br i1 %30, label %31, label %37
31: ; preds = %19
%32 = load i32, i32* @stderr
%33 = load i32, i32* %6
%34 = load i32, i32* %7
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %33, i32 %34)
%36 = call i32 @exit(i32 -1)
unreachable
37: ; preds = %19
store i32 0, i32* %11
%38 = load i32, i32* %6
%39 = load i32, i32* %7
%40 = call i32** @combine(i32 %38, i32 %39, i32* %11, i32** %10)
store i32** %40, i32*** %12
store i32 0, i32* %8
br label %41
41: ; preds = %70, %37
%42 = load i32, i32* %8
%43 = load i32, i32* %11
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %73
45: ; preds = %41
store i32 0, i32* %9
br label %46
46: ; preds = %65, %45
%47 = load i32, i32* %9
%48 = load i32*, i32** %10
%49 = load i32, i32* %8
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32, i32* %48, i64 %50
%52 = load i32, i32* %51
%53 = icmp slt i32 %47, %52
br i1 %53, label %54, label %68
54: ; preds = %46
%55 = load i32**, i32*** %12
%56 = load i32, i32* %8
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i32*, i32** %55, i64 %57
%59 = load i32*, i32** %58
%60 = load i32, i32* %9
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i32, i32* %59, i64 %61
%63 = load i32, i32* %62
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %63)
br label %65
65: ; preds = %54
%66 = load i32, i32* %9
%67 = add nsw i32 %66, 1
store i32 %67, i32* %9
br label %46
68: ; preds = %46
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %70
70: ; preds = %68
%71 = load i32, i32* %8
%72 = add nsw i32 %71, 1
store i32 %72, i32* %8
br label %41
73: ; preds = %41
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [19 x i8] c"Usage: ./test n k\0A\00"
@.str.1 = [32 x i8] c"n(=%d) must larger than k(=%d)\0A\00"
@.str.2 = [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 (i32, i8*, ...) @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 = icmp sgt i32 %16, %13
br i1 %17, label %18, label %22
18: ; preds = %10
%19 = load i32, i32* @stderr
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 %16)
%21 = tail call i32 @exit(i32 -1)
unreachable
22: ; preds = %10
%23 = bitcast i32** %3 to i8*
%24 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%25 = call i32** @combine(i32 %13, i32 %16, i32* %4, i32** %3)
%26 = load i32, i32* %4
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %54
28: ; preds = %22, %48
%29 = phi i64 [ %50, %48 ], [ 0, %22 ]
%30 = load i32*, i32** %3
%31 = getelementptr inbounds i32, i32* %30, i64 %29
%32 = load i32, i32* %31
%33 = icmp sgt i32 %32, 0
br i1 %33, label %34, label %48
34: ; preds = %28
%35 = getelementptr inbounds i32*, i32** %25, i64 %29
br label %36
36: ; preds = %34, %36
%37 = phi i64 [ 0, %34 ], [ %42, %36 ]
%38 = load i32*, i32** %35
%39 = getelementptr inbounds i32, i32* %38, i64 %37
%40 = load i32, i32* %39
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %40)
%42 = add nuw nsw i64 %37, 1
%43 = load i32*, i32** %3
%44 = getelementptr inbounds i32, i32* %43, i64 %29
%45 = load i32, i32* %44
%46 = sext i32 %45 to i64
%47 = icmp slt i64 %42, %46
br i1 %47, label %36, label %48
48: ; preds = %36, %28
%49 = call i32 @putchar(i32 10)
%50 = add nuw nsw i64 %29, 1
%51 = load i32, i32* %4
%52 = sext i32 %51 to i64
%53 = icmp slt i64 %50, %52
br i1 %53, label %28, label %54
54: ; preds = %48, %22
ret i32 0
}