#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 */
scalar_t__ malloc(int const);
double ***dblarr3alloc(const int n1, const int n2, const int n3) {
  int i, j;
  double ***aa;
  aa = (double ***)malloc(n1 * sizeof(double **));
  for (i = 0; i < n1; i++) {
    aa[i] = (double **)malloc(n2 * sizeof(double *));
    for (j = 0; j < n2; j++)
      aa[i][j] = (double *)malloc(n3 * sizeof(double));
  }
  return aa;
}


x86 assembly (clang, -O0):
<dblarr3alloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11bf <dblarr3alloc+0xaf>
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ac <dblarr3alloc+0x9c>
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116c <dblarr3alloc+0x5c>
jmp    11b1 <dblarr3alloc+0xa1>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113b <dblarr3alloc+0x2b>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dblarr3alloc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%r13d
mov    %rsi,0x10(%rsp)
mov    %edi,%r12d
lea    0x0(,%r12,8),%edi
call   1030 <malloc@plt>
mov    %rax,%rbx
test   %r12d,%r12d
jle    119b <dblarr3alloc+0x8b>
mov    0x10(%rsp),%rax
lea    0x0(,%rax,8),%ecx
mov    %ecx,0xc(%rsp)
shl    $0x3,%r13d
mov    %r12d,%r12d
mov    %eax,%ebp
xor    %r14d,%r14d
jmp    1169 <dblarr3alloc+0x59>
nopl   0x0(%rax)
add    $0x1,%r14
cmp    %r12,%r14
je     119b <dblarr3alloc+0x8b>
mov    0xc(%rsp),%edi
call   1030 <malloc@plt>
mov    %rax,(%rbx,%r14,8)
cmpl   $0x0,0x10(%rsp)
jle    1160 <dblarr3alloc+0x50>
xor    %r15d,%r15d
mov    %r13d,%edi
call   1030 <malloc@plt>
mov    (%rbx,%r14,8),%rcx
mov    %rax,(%rcx,%r15,8)
add    $0x1,%r15
cmp    %r15,%rbp
jne    1180 <dblarr3alloc+0x70>
jmp    1160 <dblarr3alloc+0x50>
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define double*** @dblarr3alloc(i32 %0, i32 %1, i32 %2) {
%4 = shl i32 %0, 3
%5 = tail call i64 @malloc(i32 %4)
%6 = inttoptr i64 %5 to double***
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %30
8: ; preds = %3
%9 = shl i32 %1, 3
%10 = icmp sgt i32 %1, 0
%11 = shl i32 %2, 3
%12 = zext i32 %0 to i64
%13 = zext i32 %1 to i64
br label %14
14: ; preds = %8, %27
%15 = phi i64 [ 0, %8 ], [ %28, %27 ]
%16 = tail call i64 @malloc(i32 %9)
%17 = inttoptr i64 %16 to double**
%18 = getelementptr inbounds double**, double*** %6, i64 %15
store double** %17, double*** %18
br i1 %10, label %19, label %27
19: ; preds = %14, %19
%20 = phi i64 [ %25, %19 ], [ 0, %14 ]
%21 = tail call i64 @malloc(i32 %11)
%22 = inttoptr i64 %21 to double*
%23 = load double**, double*** %18
%24 = getelementptr inbounds double*, double** %23, i64 %20
store double* %22, double** %24
%25 = add nuw nsw i64 %20, 1
%26 = icmp eq i64 %25, %13
br i1 %26, label %27, label %19
27: ; preds = %19, %14
%28 = add nuw nsw i64 %15, 1
%29 = icmp eq i64 %28, %12
br i1 %29, label %30, label %14
30: ; preds = %27, %3
ret double*** %6
}