#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__ calloc(int, int);
int pow(int, int);
double **constructNodeArray(int size) {
  double **return_array = (double **)calloc(size, sizeof(double *));
  int i;
  for (i = size; i > 0; i--) {
    return_array[size - i] = (double *)calloc(pow(4, i - 1), sizeof(double));
  }
  return return_array;
}


x86 assembly (clang, -O0):
<constructNodeArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    118a <constructNodeArray+0x6a>
mov    -0x14(%rbp),%esi
sub    $0x1,%esi
mov    $0x4,%edi
call   1040 <pow@plt>
mov    %eax,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    -0x14(%rbp),%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1142 <constructNodeArray+0x22>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<constructNodeArray>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%r14
test   %ebp,%ebp
jle    116d <constructNodeArray+0x4d>
mov    %ebp,%ebp
mov    %r14,%rbx
nop
lea    -0x1(%rbp),%r15
mov    $0x4,%edi
mov    %r15d,%esi
call   1040 <pow@plt>
mov    %eax,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,(%rbx)
add    $0x8,%rbx
cmp    $0x1,%rbp
mov    %r15,%rbp
ja     1140 <constructNodeArray+0x20>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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