#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 */
struct S_MATRIX {
  int dummy;
};

/* Variables and functions */
struct S_MATRIX ****calloc(size_t const, int);
struct S_MATRIX ***constructor_matrix3_pointer(size_t const, size_t const);
struct S_MATRIX ****
constructor_matrix4_pointer(size_t const N0, size_t const N1, size_t const N2) {
  struct S_MATRIX ****A = calloc(N0, sizeof *A);
  for (size_t i = 0; i < N0; i++)
    A[i] = constructor_matrix3_pointer(N1, N2);
  return A;
}


x86 assembly (clang, -O0):
<constructor_matrix4_pointer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    1189 <constructor_matrix4_pointer+0x69>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <constructor_matrix3_pointer@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    114e <constructor_matrix4_pointer+0x2e>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<constructor_matrix4_pointer>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,%r13
test   %r12,%r12
je     1169 <constructor_matrix4_pointer+0x49>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <constructor_matrix3_pointer@plt>
mov    %rax,0x0(%r13,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1150 <constructor_matrix4_pointer+0x30>
mov    %r13,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.S_MATRIX = type { i32 }
define %struct.S_MATRIX**** @constructor_matrix4_pointer(i64 %0, i64 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca %struct.S_MATRIX****
%8 = alloca i64
store i64 %0, i64* %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%9 = load i64, i64* %4
%10 = call %struct.S_MATRIX**** @calloc(i64 %9, i32 8)
store %struct.S_MATRIX**** %10, %struct.S_MATRIX***** %7
store i64 0, i64* %8
br label %11
11: ; preds = %22, %3
%12 = load i64, i64* %8
%13 = load i64, i64* %4
%14 = icmp ult i64 %12, %13
br i1 %14, label %15, label %25
15: ; preds = %11
%16 = load i64, i64* %5
%17 = load i64, i64* %6
%18 = call %struct.S_MATRIX*** @constructor_matrix3_pointer(i64 %16, i64 %17)
%19 = load %struct.S_MATRIX****, %struct.S_MATRIX***** %7
%20 = load i64, i64* %8
%21 = getelementptr inbounds %struct.S_MATRIX***, %struct.S_MATRIX**** %19, i64 %20
store %struct.S_MATRIX*** %18, %struct.S_MATRIX**** %21
br label %22
22: ; preds = %15
%23 = load i64, i64* %8
%24 = add i64 %23, 1
store i64 %24, i64* %8
br label %11
25: ; preds = %11
%26 = load %struct.S_MATRIX****, %struct.S_MATRIX***** %7
ret %struct.S_MATRIX**** %26
}

LLVM IR (-O2):
%struct.S_MATRIX = type { i32 }
define %struct.S_MATRIX**** @constructor_matrix4_pointer(i64 %0, i64 %1, i64 %2) {
%4 = tail call %struct.S_MATRIX**** @calloc(i64 %0, i32 8)
%5 = icmp eq i64 %0, 0
br i1 %5, label %6, label %7
6: ; preds = %7, %3
ret %struct.S_MATRIX**** %4
7: ; preds = %3, %7
%8 = phi i64 [ %11, %7 ], [ 0, %3 ]
%9 = tail call %struct.S_MATRIX*** @constructor_matrix3_pointer(i64 %1, i64 %2)
%10 = getelementptr inbounds %struct.S_MATRIX***, %struct.S_MATRIX**** %4, i64 %8
store %struct.S_MATRIX*** %9, %struct.S_MATRIX**** %10
%11 = add nuw i64 %8, 1
%12 = icmp eq i64 %11, %0
br i1 %12, label %6, label %7
}