#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*/ comb(int *, int **, int *, int /*<<< orphan*/, int,
                        int /*<<< orphan*/, int, int /*<<< orphan*/);
scalar_t__ malloc(int);
int num_combs(int, int);
int **get_combs(int *items, int k, int len) {
  int i;
  int **shit = (int **)malloc(num_combs(len, k) * sizeof(int *));
  for (i = 0; i < num_combs(len, k); i++) {
    shit[i] = (int *)malloc(k * sizeof(int));
  }
  int *row = (int *)malloc(k * sizeof(int));
  comb(items, shit, row, 0, len, 0, k, 0);
  return shit;
}


x86 assembly (clang, -O0):
<get_combs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <num_combs@plt>
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <num_combs@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jge    11af <get_combs+0x7f>
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1165 <get_combs+0x35>
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x10(%rbp),%r8d
mov    -0xc(%rbp),%eax
xor    %r9d,%r9d
mov    %r9d,%ecx
mov    %eax,(%rsp)
movl   $0x0,0x8(%rsp)
call   1030 <comb@plt>
mov    -0x20(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_combs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r12d
mov    %esi,%r14d
mov    %rdi,%r15
mov    %edx,%edi
call   1040 <num_combs@plt>
lea    0x0(,%rax,8),%edi
call   1050 <malloc@plt>
mov    %rax,%r13
mov    %r12d,%edi
mov    %r14d,%esi
call   1040 <num_combs@plt>
lea    0x0(,%r14,4),%ebp
test   %eax,%eax
jle    11a2 <get_combs+0x72>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebp,%edi
call   1050 <malloc@plt>
mov    %rax,0x0(%r13,%rbx,8)
add    $0x1,%rbx
mov    %r12d,%edi
mov    %r14d,%esi
call   1040 <num_combs@plt>
cltq
cmp    %rax,%rbx
jl     1180 <get_combs+0x50>
mov    %ebp,%edi
call   1050 <malloc@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %rax,%rdx
xor    %ecx,%ecx
mov    %r12d,%r8d
xor    %r9d,%r9d
push   $0x0
push   %r14
call   1030 <comb@plt>
add    $0x10,%rsp
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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