#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__ HTS_calloc(size_t, int);
double **HTS_alloc_matrix(size_t x, size_t y) {
  size_t i;
  double **p;
  if (x == 0 || y == 0)
    return NULL;
  p = (double **)HTS_calloc(x, sizeof(double *));
  for (i = 0; i < x; i++)
    p[i] = (double *)HTS_calloc(y, sizeof(double));
  return p;
}


x86 assembly (clang, -O0):
<HTS_alloc_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1136 <HTS_alloc_matrix+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    1143 <HTS_alloc_matrix+0x33>
movq   $0x0,-0x8(%rbp)
jmp    11a1 <HTS_alloc_matrix+0x91>
mov    -0x10(%rbp),%rdi
mov    $0x8,%esi
call   1030 <HTS_calloc@plt>
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1199 <HTS_alloc_matrix+0x89>
mov    -0x18(%rbp),%rdi
mov    $0x8,%esi
call   1030 <HTS_calloc@plt>
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    115d <HTS_alloc_matrix+0x4d>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HTS_alloc_matrix>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %r15d,%r15d
test   %rdi,%rdi
je     115a <HTS_alloc_matrix+0x4a>
mov    %rsi,%r14
test   %rsi,%rsi
je     115a <HTS_alloc_matrix+0x4a>
mov    %rdi,%r12
mov    $0x8,%esi
call   1030 <HTS_calloc@plt>
mov    %rax,%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x8,%esi
call   1030 <HTS_calloc@plt>
mov    %rax,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1140 <HTS_alloc_matrix+0x30>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double** @HTS_alloc_matrix(i64 %0, i64 %1) {
%3 = alloca double**
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca double**
store i64 %0, i64* %4
store i64 %1, i64* %5
%8 = load i64, i64* %4
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = load i64, i64* %5
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %10, %2
store double** null, double*** %3
br label %34
14: ; preds = %10
%15 = load i64, i64* %4
%16 = call i64 @HTS_calloc(i64 %15, i32 8)
%17 = inttoptr i64 %16 to double**
store double** %17, double*** %7
store i64 0, i64* %6
br label %18
18: ; preds = %29, %14
%19 = load i64, i64* %6
%20 = load i64, i64* %4
%21 = icmp ult i64 %19, %20
br i1 %21, label %22, label %32
22: ; preds = %18
%23 = load i64, i64* %5
%24 = call i64 @HTS_calloc(i64 %23, i32 8)
%25 = inttoptr i64 %24 to double*
%26 = load double**, double*** %7
%27 = load i64, i64* %6
%28 = getelementptr inbounds double*, double** %26, i64 %27
store double* %25, double** %28
br label %29
29: ; preds = %22
%30 = load i64, i64* %6
%31 = add i64 %30, 1
store i64 %31, i64* %6
br label %18
32: ; preds = %18
%33 = load double**, double*** %7
store double** %33, double*** %3
br label %34
34: ; preds = %32, %13
%35 = load double**, double*** %3
ret double** %35
}

LLVM IR (-O2):
define double** @HTS_alloc_matrix(i64 %0, i64 %1) {
%3 = icmp eq i64 %0, 0
%4 = icmp eq i64 %1, 0
%5 = or i1 %3, %4
br i1 %5, label %16, label %6
6: ; preds = %2
%7 = tail call i64 @HTS_calloc(i64 %0, i32 8)
%8 = inttoptr i64 %7 to double**
br label %9
9: ; preds = %6, %9
%10 = phi i64 [ %14, %9 ], [ 0, %6 ]
%11 = tail call i64 @HTS_calloc(i64 %1, i32 8)
%12 = inttoptr i64 %11 to double*
%13 = getelementptr inbounds double*, double** %8, i64 %10
store double* %12, double** %13
%14 = add nuw i64 %10, 1
%15 = icmp eq i64 %14, %0
br i1 %15, label %16, label %9
16: ; preds = %9, %2
%17 = phi double** [ null, %2 ], [ %8, %9 ]
ret double** %17
}