#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 */
double **dmatrix(int, int, int, int);
scalar_t__ malloc(int);
double ***AllocXi(int T, int N) {
  int t;
  double ***xi;
  xi = (double ***)malloc(T * sizeof(double **));
  xi--;
  for (t = 1; t <= T; t++)
    xi[t] = dmatrix(1, N, 1, N);
  return xi;
}


x86 assembly (clang, -O0):
<AllocXi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x18(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     118f <AllocXi+0x6f>
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%ecx
mov    $0x1,%edx
mov    %edx,%edi
call   1030 <dmatrix@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1154 <AllocXi+0x34>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AllocXi>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebp
mov    %edi,%r12d
lea    0x0(,%r12,8),%edi
call   1040 <malloc@plt>
lea    -0x8(%rax),%r14
test   %r12d,%r12d
jle    1170 <AllocXi+0x50>
mov    %rax,%r15
mov    %r12d,%r12d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edi
mov    %ebp,%esi
mov    $0x1,%edx
mov    %ebp,%ecx
call   1030 <dmatrix@plt>
mov    %rax,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1150 <AllocXi+0x30>
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double*** @AllocXi(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca double***
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = mul i64 %8, 8
%10 = trunc i64 %9 to i32
%11 = call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to double***
store double*** %12, double**** %6
%13 = load double***, double**** %6
%14 = getelementptr inbounds double**, double*** %13, i32 -1
store double*** %14, double**** %6
store i32 1, i32* %5
br label %15
15: ; preds = %27, %2
%16 = load i32, i32* %5
%17 = load i32, i32* %3
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %30
19: ; preds = %15
%20 = load i32, i32* %4
%21 = load i32, i32* %4
%22 = call double** @dmatrix(i32 1, i32 %20, i32 1, i32 %21)
%23 = load double***, double**** %6
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double**, double*** %23, i64 %25
store double** %22, double*** %26
br label %27
27: ; preds = %19
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %15
30: ; preds = %15
%31 = load double***, double**** %6
ret double*** %31
}

LLVM IR (-O2):
define double*** @AllocXi(i32 %0, i32 %1) {
%3 = shl i32 %0, 3
%4 = tail call i64 @malloc(i32 %3)
%5 = inttoptr i64 %4 to double***
%6 = getelementptr inbounds double**, double*** %5, i64 -1
%7 = icmp slt i32 %0, 1
br i1 %7, label %17, label %8
8: ; preds = %2
%9 = add nuw i32 %0, 1
%10 = zext i32 %9 to i64
br label %11
11: ; preds = %8, %11
%12 = phi i64 [ 1, %8 ], [ %15, %11 ]
%13 = tail call double** @dmatrix(i32 1, i32 %1, i32 1, i32 %1)
%14 = getelementptr inbounds double**, double*** %6, i64 %12
store double** %13, double*** %14
%15 = add nuw nsw i64 %12, 1
%16 = icmp eq i64 %15, %10
br i1 %16, label %17, label %11
17: ; preds = %11, %2
ret double*** %6
}