#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*/ array_print(int *, int);
int /*<<< orphan*/ free(int ***);
int ***malloc(int);
int /*<<< orphan*/ partition_dbl_restr_numbers(int ***, int, int);
int /*<<< orphan*/ partition_restr_from_id(int ***, int, int, int, int *,
                                           int *);
void print_restricted_partitions(int n, int k) {
  int(*p)[n + 1][n + 1] = malloc(((n + 1) * (n + 1) * sizeof(int)));
  partition_dbl_restr_numbers(p, n, k);
  int part[n], num_part;
  int i;
  for (i = 0; i < (*p)[n][n]; i++) {
    partition_restr_from_id(p, n, k, i, part, &num_part);
    array_print(part, num_part);
  }
  free(p);
}


x86 assembly (clang, -O0):
<print_restricted_partitions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
add    $0x1,%edi
mov    %edi,%eax
mov    %rax,-0x38(%rbp)
imul   %edi,%edi
shl    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1060 <partition_dbl_restr_numbers@plt>
mov    -0x4(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x38(%rbp),%rsi
mov    -0x28(%rbp),%eax
mov    -0x10(%rbp),%rcx
movslq -0x4(%rbp),%rdx
imul   %rsi,%rdx
shl    $0x2,%rdx
add    %rdx,%rcx
movslq -0x4(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    1211 <print_restricted_partitions+0xc1>
mov    -0x30(%rbp),%r8
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x28(%rbp),%ecx
lea    -0x24(%rbp),%r9
call   1040 <partition_restr_from_id@plt>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1070 <array_print@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11b6 <print_restricted_partitions+0x66>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_restricted_partitions>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r14d
mov    %edi,%ebx
lea    0x1(%rbx),%eax
mov    %rax,-0x38(%rbp)
mov    %eax,%edi
imul   %eax,%edi
shl    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %ebx,%esi
mov    %r14d,-0x2c(%rbp)
mov    %r14d,%edx
call   1060 <partition_dbl_restr_numbers@plt>
mov    %ebx,%eax
mov    %rsp,%r12
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
movslq %ebx,%r13
mov    -0x38(%rbp),%rax
imul   %r13,%rax
lea    (%r15,%rax,4),%r14
cmpl   $0x0,(%r14,%r13,4)
jle    11eb <print_restricted_partitions+0x9b>
xor    %ebx,%ebx
nopl   (%rax)
mov    %r15,%rdi
mov    %r13d,%esi
mov    -0x2c(%rbp),%edx
mov    %ebx,%ecx
mov    %r12,%r8
lea    -0x30(%rbp),%r9
call   1040 <partition_restr_from_id@plt>
mov    -0x30(%rbp),%esi
mov    %r12,%rdi
call   1070 <array_print@plt>
add    $0x1,%ebx
cmp    (%r14,%r13,4),%ebx
jl     11c0 <print_restricted_partitions+0x70>
mov    %r15,%rdi
call   1030 <free@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @print_restricted_partitions(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%10 = load i32, i32* %3
%11 = add nsw i32 %10, 1
%12 = zext i32 %11 to i64
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
%15 = zext i32 %14 to i64
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
%20 = mul nsw i32 %17, %19
%21 = sext i32 %20 to i64
%22 = mul i64 %21, 4
%23 = trunc i64 %22 to i32
%24 = call i32*** @malloc(i32 %23)
%25 = bitcast i32*** %24 to i32*
store i32* %25, i32** %5
%26 = load i32*, i32** %5
%27 = bitcast i32* %26 to i32***
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = call i32 @partition_dbl_restr_numbers(i32*** %27, i32 %28, i32 %29)
%31 = load i32, i32* %3
%32 = zext i32 %31 to i64
%33 = call i8* @llvm.stacksave()
store i8* %33, i8** %6
%34 = alloca i32, i64 %32
store i64 %32, i64* %7
store i32 0, i32* %9
br label %35
35: ; preds = %56, %2
%36 = load i32, i32* %9
%37 = load i32*, i32** %5
%38 = load i32, i32* %3
%39 = sext i32 %38 to i64
%40 = mul nsw i64 %39, %15
%41 = getelementptr inbounds i32, i32* %37, i64 %40
%42 = load i32, i32* %3
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
%45 = load i32, i32* %44
%46 = icmp slt i32 %36, %45
br i1 %46, label %47, label %59
47: ; preds = %35
%48 = load i32*, i32** %5
%49 = bitcast i32* %48 to i32***
%50 = load i32, i32* %3
%51 = load i32, i32* %4
%52 = load i32, i32* %9
%53 = call i32 @partition_restr_from_id(i32*** %49, i32 %50, i32 %51, i32 %52, i32* %34, i32* %8)
%54 = load i32, i32* %8
%55 = call i32 @array_print(i32* %34, i32 %54)
br label %56
56: ; preds = %47
%57 = load i32, i32* %9
%58 = add nsw i32 %57, 1
store i32 %58, i32* %9
br label %35
59: ; preds = %35
%60 = load i32*, i32** %5
%61 = bitcast i32* %60 to i32***
%62 = call i32 @free(i32*** %61)
%63 = load i8*, i8** %6
ret void
}

LLVM IR (-O2):
define void @print_restricted_partitions(i32 %0, i32 %1) {
%3 = alloca i32
%4 = add nsw i32 %0, 1
%5 = zext i32 %4 to i64
%6 = shl i32 %4, 2
%7 = mul i32 %6, %4
%8 = tail call i32*** @malloc(i32 %7)
%9 = bitcast i32*** %8 to i32*
%10 = tail call i32 @partition_dbl_restr_numbers(i32*** %8, i32 %0, i32 %1)
%11 = zext i32 %0 to i64
%12 = alloca i32, i64 %11
%13 = bitcast i32* %3 to i8*
%14 = sext i32 %0 to i64
%15 = mul nsw i64 %5, %14
%16 = getelementptr inbounds i32, i32* %9, i64 %15
%17 = getelementptr inbounds i32, i32* %16, i64 %14
%18 = load i32, i32* %17
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %28
20: ; preds = %2, %20
%21 = phi i32 [ %25, %20 ], [ 0, %2 ]
%22 = call i32 @partition_restr_from_id(i32*** %8, i32 %0, i32 %1, i32 %21, i32* %12, i32* %3)
%23 = load i32, i32* %3
%24 = call i32 @array_print(i32* %12, i32 %23)
%25 = add nuw nsw i32 %21, 1
%26 = load i32, i32* %17
%27 = icmp slt i32 %25, %26
br i1 %27, label %20, label %28
28: ; preds = %20, %2
%29 = call i32 @free(i32*** %8)
ret void
}