#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*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ stderr;
double **new_doub2(int ndoub2) {
  double **newdoub2 = {NULL};
  newdoub2 = (double **)malloc(sizeof(double *) * ndoub2);
  if (!newdoub2) {
    fprintf(stderr, "ERROR:  Insufficient memory for array of pointers\n");
    fprintf(stderr, "        to the spectra.");
    return NULL;
  } else
    return newdoub2;
}


x86 assembly (clang, -O0):
<new_doub2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1188 <new_doub2+0x68>
mov    0x2e88(%rip),%rax
mov    (%rax),%edi
lea    0xe9f(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
lea    0xebd(%rip),%rsi
call   1030 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1190 <new_doub2+0x70>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<new_doub2>:
push   %rbx
shl    $0x3,%edi
call   1040 <malloc@plt>
test   %rax,%rax
je     1130 <new_doub2+0x10>
pop    %rbx
ret
mov    0x2ea9(%rip),%rbx
mov    (%rbx),%edi
lea    0xec0(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xee5(%rip),%rsi
call   1030 <fprintf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [51 x i8] c"ERROR: Insufficient memory for array of pointers\0A\00"
@.str.1 = [24 x i8] c" to the spectra.\00"
define double** @new_doub2(i32 %0) {
%2 = alloca double**
%3 = alloca i32
%4 = alloca double**
store i32 %0, i32* %3
store double** null, double*** %4
%5 = load i32, i32* %3
%6 = sext i32 %5 to i64
%7 = mul i64 8, %6
%8 = trunc i64 %7 to i32
%9 = call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to double**
store double** %10, double*** %4
%11 = load double**, double*** %4
%12 = icmp ne double** %11, null
br i1 %12, label %18, label %13
13: ; preds = %1
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store double** null, double*** %2
br label %20
18: ; preds = %1
%19 = load double**, double*** %4
store double** %19, double*** %2
br label %20
20: ; preds = %18, %13
%21 = load double**, double*** %2
ret double** %21
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [51 x i8] c"ERROR: Insufficient memory for array of pointers\0A\00"
@.str.1 = [24 x i8] c" to the spectra.\00"
define double** @new_doub2(i32 %0) {
%2 = shl i32 %0, 3
%3 = tail call i64 @malloc(i32 %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %12
10: ; preds = %1
%11 = inttoptr i64 %3 to double**
br label %12
12: ; preds = %10, %5
%13 = phi double** [ %11, %10 ], [ null, %5 ]
ret double** %13
}