#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__ glb_malloc(unsigned int);
double **glb_alloc_mat(int nrl, int nrh, int ncl, int nch) {
  int i;
  double **m;
  m = (double **)glb_malloc((unsigned)(nrh + 1) * sizeof(double *));
  for (i = 0; i <= nrh; i++) {
    m[i] = (double *)glb_malloc((unsigned)(nch + 1) * sizeof(double));
  }
  return m;
}


x86 assembly (clang, -O0):
<glb_alloc_mat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <glb_malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     117e <glb_alloc_mat+0x6e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <glb_malloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1142 <glb_alloc_mat+0x32>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<glb_alloc_mat>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %esi,%r14d
lea    0x8(,%r14,8),%edi
call   1030 <glb_malloc@plt>
mov    %rax,%r15
test   %r14d,%r14d
js     1154 <glb_alloc_mat+0x44>
lea    0x8(,%rbp,8),%ebp
add    $0x1,%r14d
xor    %ebx,%ebx
xchg   %ax,%ax
mov    %ebp,%edi
call   1030 <glb_malloc@plt>
mov    %rax,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1140 <glb_alloc_mat+0x30>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define double** @glb_alloc_mat(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = shl i32 %1, 3
%6 = add i32 %5, 8
%7 = tail call i64 @glb_malloc(i32 %6)
%8 = inttoptr i64 %7 to double**
%9 = icmp slt i32 %1, 0
br i1 %9, label %22, label %10
10: ; preds = %4
%11 = shl i32 %3, 3
%12 = add i32 %11, 8
%13 = add nuw i32 %1, 1
%14 = zext i32 %13 to i64
br label %15
15: ; preds = %10, %15
%16 = phi i64 [ 0, %10 ], [ %20, %15 ]
%17 = tail call i64 @glb_malloc(i32 %12)
%18 = inttoptr i64 %17 to double*
%19 = getelementptr inbounds double*, double** %8, i64 %16
store double* %18, double** %19
%20 = add nuw nsw i64 %16, 1
%21 = icmp eq i64 %20, %14
br i1 %21, label %22, label %15
22: ; preds = %15, %4
ret double** %8
}