#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*/ 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 *);
int partition_to_id(int ***, int, int *);
int /*<<< orphan*/ printf(char *, int);
void partition_test_id(int n) {
  int(*p)[n + 1][n + 1] = malloc(((n + 1) * (n + 1) * sizeof(int)));
  partition_dbl_restr_numbers(p, n, 1);
  int part[n], num_part;
  int i;
  for (i = 0; i < (*p)[n][n]; i++) {
    partition_restr_from_id(p, n, 1, i, part, &num_part);
    int res = partition_to_id(p, n, part);
    if (res != i) {
      printf("There was an error on id %d.\n", i);
    }
  }
  free(p);
}


x86 assembly (clang, -O0):
<partition_test_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
add    $0x1,%edi
mov    %edi,%eax
mov    %rax,-0x40(%rbp)
imul   %edi,%edi
shl    $0x2,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    $0x1,%edx
call   1070 <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,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x40(%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    1249 <partition_test_id+0xe9>
mov    -0x38(%rbp),%r8
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x28(%rbp),%ecx
mov    $0x1,%edx
lea    -0x24(%rbp),%r9
call   1050 <partition_restr_from_id@plt>
mov    -0x38(%rbp),%rdx
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1080 <partition_to_id@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x28(%rbp),%eax
je     1236 <partition_test_id+0xd6>
mov    -0x28(%rbp),%esi
lea    0xdcf(%rip),%rdi
call   1040 <printf@plt>
jmp    123b <partition_test_id+0xdb>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11c5 <partition_test_id+0x65>
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):
<partition_test_id>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edi,%r14d
lea    0x1(%r14),%ebx
mov    %ebx,%edi
imul   %ebx,%edi
shl    $0x2,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r14d,%esi
mov    $0x1,%edx
call   1070 <partition_dbl_restr_numbers@plt>
mov    %r14d,%eax
mov    %rsp,%r12
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
movslq %r14d,%rax
imul   %rax,%rbx
lea    (%r15,%rbx,4),%r13
mov    %rax,-0x30(%rbp)
cmpl   $0x0,0x0(%r13,%rax,4)
jle    1219 <partition_test_id+0xb9>
xor    %ebx,%ebx
jmp    11de <partition_test_id+0x7e>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
mov    -0x30(%rbp),%rax
cmp    0x0(%r13,%rax,4),%ebx
jge    1219 <partition_test_id+0xb9>
mov    %r15,%rdi
mov    %r14d,%esi
mov    $0x1,%edx
mov    %ebx,%ecx
mov    %r12,%r8
lea    -0x34(%rbp),%r9
call   1050 <partition_restr_from_id@plt>
mov    %r15,%rdi
mov    %r14d,%esi
mov    %r12,%rdx
call   1080 <partition_to_id@plt>
cmp    %eax,%ebx
je     11d0 <partition_test_id+0x70>
lea    0xdf0(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
jmp    11d0 <partition_test_id+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):
@.str = [30 x i8] c"There was an error on id %d.\0A\00"
define void @partition_test_id(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %2
%9 = load i32, i32* %2
%10 = add nsw i32 %9, 1
%11 = zext i32 %10 to i64
%12 = load i32, i32* %2
%13 = add nsw i32 %12, 1
%14 = zext i32 %13 to i64
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
%19 = mul nsw i32 %16, %18
%20 = sext i32 %19 to i64
%21 = mul i64 %20, 4
%22 = trunc i64 %21 to i32
%23 = call i32*** @malloc(i32 %22)
%24 = bitcast i32*** %23 to i32*
store i32* %24, i32** %3
%25 = load i32*, i32** %3
%26 = bitcast i32* %25 to i32***
%27 = load i32, i32* %2
%28 = call i32 @partition_dbl_restr_numbers(i32*** %26, i32 %27, i32 1)
%29 = load i32, i32* %2
%30 = zext i32 %29 to i64
%31 = call i8* @llvm.stacksave()
store i8* %31, i8** %4
%32 = alloca i32, i64 %30
store i64 %30, i64* %5
store i32 0, i32* %7
br label %33
33: ; preds = %62, %1
%34 = load i32, i32* %7
%35 = load i32*, i32** %3
%36 = load i32, i32* %2
%37 = sext i32 %36 to i64
%38 = mul nsw i64 %37, %14
%39 = getelementptr inbounds i32, i32* %35, i64 %38
%40 = load i32, i32* %2
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %39, i64 %41
%43 = load i32, i32* %42
%44 = icmp slt i32 %34, %43
br i1 %44, label %45, label %65
45: ; preds = %33
%46 = load i32*, i32** %3
%47 = bitcast i32* %46 to i32***
%48 = load i32, i32* %2
%49 = load i32, i32* %7
%50 = call i32 @partition_restr_from_id(i32*** %47, i32 %48, i32 1, i32 %49, i32* %32, i32* %6)
%51 = load i32*, i32** %3
%52 = bitcast i32* %51 to i32***
%53 = load i32, i32* %2
%54 = call i32 @partition_to_id(i32*** %52, i32 %53, i32* %32)
store i32 %54, i32* %8
%55 = load i32, i32* %8
%56 = load i32, i32* %7
%57 = icmp ne i32 %55, %56
br i1 %57, label %58, label %61
58: ; preds = %45
%59 = load i32, i32* %7
%60 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %59)
br label %61
61: ; preds = %58, %45
br label %62
62: ; preds = %61
%63 = load i32, i32* %7
%64 = add nsw i32 %63, 1
store i32 %64, i32* %7
br label %33
65: ; preds = %33
%66 = load i32*, i32** %3
%67 = bitcast i32* %66 to i32***
%68 = call i32 @free(i32*** %67)
%69 = load i8*, i8** %4
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c"There was an error on id %d.\0A\00"
define void @partition_test_id(i32 %0) {
%2 = alloca i32
%3 = add nsw i32 %0, 1
%4 = zext i32 %3 to i64
%5 = shl i32 %3, 2
%6 = mul i32 %5, %3
%7 = tail call i32*** @malloc(i32 %6)
%8 = bitcast i32*** %7 to i32*
%9 = tail call i32 @partition_dbl_restr_numbers(i32*** %7, i32 %0, i32 1)
%10 = zext i32 %0 to i64
%11 = alloca i32, i64 %10
%12 = bitcast i32* %2 to i8*
%13 = sext i32 %0 to i64
%14 = mul nsw i64 %4, %13
%15 = getelementptr inbounds i32, i32* %8, i64 %14
%16 = getelementptr inbounds i32, i32* %15, i64 %13
%17 = load i32, i32* %16
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %30
19: ; preds = %1, %26
%20 = phi i32 [ %27, %26 ], [ 0, %1 ]
%21 = call i32 @partition_restr_from_id(i32*** %7, i32 %0, i32 1, i32 %20, i32* %11, i32* %2)
%22 = call i32 @partition_to_id(i32*** %7, i32 %0, i32* %11)
%23 = icmp eq i32 %22, %20
br i1 %23, label %26, label %24
24: ; preds = %19
%25 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %20)
br label %26
26: ; preds = %24, %19
%27 = add nuw nsw i32 %20, 1
%28 = load i32, i32* %16
%29 = icmp slt i32 %27, %28
br i1 %29, label %19, label %30
30: ; preds = %26, %1
%31 = call i32 @free(i32*** %7)
ret void
}