#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*/ EXIT_FAILURE;
scalar_t__ calloc(size_t, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
double *new_vector_double(size_t);
int /*<<< orphan*/ perror(char *);
double **new_matrix_double(size_t size_y, size_t size_x) {
  size_t i;
  double **retP;
  retP = (double **)calloc(size_y, sizeof(double *));
  if (!retP) {
    perror("Out of memory when initializing double matrix.\n");
    exit(EXIT_FAILURE);
  } else {
    for (i = 0; i < size_y; i++) {
      retP[i] = new_vector_double(size_x);
    }
  }
  return retP;
}


x86 assembly (clang, -O0):
<new_matrix_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1187 <new_matrix_double+0x47>
lea    0xe8c(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    11c6 <new_matrix_double+0x86>
mov    -0x10(%rbp),%rdi
call   1030 <new_vector_double@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    118f <new_matrix_double+0x4f>
jmp    11cb <new_matrix_double+0x8b>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<new_matrix_double>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x8,%esi
call   1040 <calloc@plt>
test   %rax,%rax
je     1194 <new_matrix_double+0x54>
mov    %rax,%r12
test   %r15,%r15
je     1185 <new_matrix_double+0x45>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <new_vector_double@plt>
mov    %rax,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1170 <new_matrix_double+0x30>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe65(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [48 x i8] c"Out of memory when initializing double matrix.\0A\00"
@EXIT_FAILURE = global i32 0
define double** @new_matrix_double(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca double**
store i64 %0, i64* %3
store i64 %1, i64* %4
%7 = load i64, i64* %3
%8 = call i64 @calloc(i64 %7, i32 8)
%9 = inttoptr i64 %8 to double**
store double** %9, double*** %6
%10 = load double**, double*** %6
%11 = icmp ne double** %10, null
br i1 %11, label %16, label %12
12: ; preds = %2
%13 = call i32 @perror(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %2
store i64 0, i64* %5
br label %17
17: ; preds = %27, %16
%18 = load i64, i64* %5
%19 = load i64, i64* %3
%20 = icmp ult i64 %18, %19
br i1 %20, label %21, label %30
21: ; preds = %17
%22 = load i64, i64* %4
%23 = call double* @new_vector_double(i64 %22)
%24 = load double**, double*** %6
%25 = load i64, i64* %5
%26 = getelementptr inbounds double*, double** %24, i64 %25
store double* %23, double** %26
br label %27
27: ; preds = %21
%28 = load i64, i64* %5
%29 = add i64 %28, 1
store i64 %29, i64* %5
br label %17
30: ; preds = %17
br label %31
31: ; preds = %30
%32 = load double**, double*** %6
ret double** %32
}

LLVM IR (-O2):
@.str = [48 x i8] c"Out of memory when initializing double matrix.\0A\00"
@EXIT_FAILURE = global i32 0
define double** @new_matrix_double(i64 %0, i64 %1) {
%3 = tail call i64 @calloc(i64 %0, i32 8)
%4 = inttoptr i64 %3 to double**
%5 = icmp eq i64 %3, 0
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = icmp eq i64 %0, 0
br i1 %7, label %18, label %12
8: ; preds = %2
%9 = tail call i32 @perror(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %6, %12
%13 = phi i64 [ %16, %12 ], [ 0, %6 ]
%14 = tail call double* @new_vector_double(i64 %1)
%15 = getelementptr inbounds double*, double** %4, i64 %13
store double* %14, double** %15
%16 = add nuw i64 %13, 1
%17 = icmp eq i64 %16, %0
br i1 %17, label %18, label %12
18: ; preds = %12, %6
ret double** %4
}