#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 partition_number(int n) {
  int(*p)[n + 1][n + 1] = malloc(((n + 1) * (n + 1) * sizeof(int)));
  partition_dbl_restr_numbers(p, n, 1);
  int res = (*p)[n][n];
  free(p);
  return res;
}


x86 assembly (clang, -O0):
<partition_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,%eax
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    $0x1,%edx
call   1050 <partition_dbl_restr_numbers@plt>
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
imul   %rdx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<partition_number>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
lea    0x1(%r14),%ebp
mov    %ebp,%edi
imul   %ebp,%edi
shl    $0x2,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14d,%esi
mov    $0x1,%edx
call   1050 <partition_dbl_restr_numbers@plt>
movslq %r14d,%rax
imul   %rax,%rbp
lea    (%rbx,%rbp,4),%rcx
mov    (%rcx,%rax,4),%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @partition_number(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = add nsw i32 %5, 1
%7 = zext i32 %6 to i64
%8 = load i32, i32* %2
%9 = add nsw i32 %8, 1
%10 = zext i32 %9 to i64
%11 = load i32, i32* %2
%12 = add nsw i32 %11, 1
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
%15 = mul nsw i32 %12, %14
%16 = sext i32 %15 to i64
%17 = mul i64 %16, 4
%18 = trunc i64 %17 to i32
%19 = call i32*** @malloc(i32 %18)
%20 = bitcast i32*** %19 to i32*
store i32* %20, i32** %3
%21 = load i32*, i32** %3
%22 = bitcast i32* %21 to i32***
%23 = load i32, i32* %2
%24 = call i32 @partition_dbl_restr_numbers(i32*** %22, i32 %23, i32 1)
%25 = load i32*, i32** %3
%26 = load i32, i32* %2
%27 = sext i32 %26 to i64
%28 = mul nsw i64 %27, %10
%29 = getelementptr inbounds i32, i32* %25, i64 %28
%30 = load i32, i32* %2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
%33 = load i32, i32* %32
store i32 %33, i32* %4
%34 = load i32*, i32** %3
%35 = bitcast i32* %34 to i32***
%36 = call i32 @free(i32*** %35)
%37 = load i32, i32* %4
ret i32 %37
}

LLVM IR (-O2):
define i32 @partition_number(i32 %0) {
%2 = add nsw i32 %0, 1
%3 = zext i32 %2 to i64
%4 = shl i32 %2, 2
%5 = mul i32 %4, %2
%6 = tail call i32*** @malloc(i32 %5)
%7 = bitcast i32*** %6 to i32*
%8 = tail call i32 @partition_dbl_restr_numbers(i32*** %6, i32 %0, i32 1)
%9 = sext i32 %0 to i64
%10 = mul nsw i64 %3, %9
%11 = getelementptr inbounds i32, i32* %7, i64 %10
%12 = getelementptr inbounds i32, i32* %11, i64 %9
%13 = load i32, i32* %12
%14 = tail call i32 @free(i32*** %6)
ret i32 %13
}