#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 */
float *alloc_1d_dbl(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ malloc(unsigned int);
int /*<<< orphan*/ stderr;
float **alloc_2d_dbl(int m, int n) {
  int i;
  float **new_t;
  new_t = (float **)malloc((unsigned)(m * sizeof(float *)));
  if (new_t == NULL) {
    fprintf(stderr, "ALLOC_2D_DBL: Couldn't allocate array of dbl ptrs\n");
    return (NULL);
  }
  for (i = 0; i < m; i++) {
    new_t[i] = alloc_1d_dbl(n);
  }
  return (new_t);
}


x86 assembly (clang, -O0):
<alloc_2d_dbl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    117e <alloc_2d_dbl+0x4e>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
lea    0xe94(%rip),%rsi
call   1040 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    11be <alloc_2d_dbl+0x8e>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b6 <alloc_2d_dbl+0x86>
mov    -0x10(%rbp),%edi
call   1030 <alloc_1d_dbl@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    1185 <alloc_2d_dbl+0x55>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alloc_2d_dbl>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r15d
mov    %edi,%r14d
lea    0x0(,%r14,8),%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     1177 <alloc_2d_dbl+0x47>
mov    %rax,%r12
test   %r14d,%r14d
jle    118f <alloc_2d_dbl+0x5f>
mov    %r14d,%ebp
xor    %ebx,%ebx
nopl   (%rax)
mov    %r15d,%edi
call   1030 <alloc_1d_dbl@plt>
mov    %rax,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <alloc_2d_dbl+0x30>
jmp    118f <alloc_2d_dbl+0x5f>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
lea    0xe79(%rip),%rsi
call   1040 <fprintf@plt>
xor    %r12d,%r12d
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [51 x i8] c"ALLOC_2D_DBL: Couldn't allocate array of dbl ptrs\0A\00"
define float** @alloc_2d_dbl(i32 %0, i32 %1) {
%3 = alloca float**
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca float**
store i32 %0, i32* %4
store i32 %1, i32* %5
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = mul i64 %9, 8
%11 = trunc i64 %10 to i32
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to float**
store float** %13, float*** %7
%14 = load float**, float*** %7
%15 = icmp eq float** %14, null
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
store float** null, float*** %3
br label %36
19: ; preds = %2
store i32 0, i32* %6
br label %20
20: ; preds = %31, %19
%21 = load i32, i32* %6
%22 = load i32, i32* %4
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %34
24: ; preds = %20
%25 = load i32, i32* %5
%26 = call float* @alloc_1d_dbl(i32 %25)
%27 = load float**, float*** %7
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds float*, float** %27, i64 %29
store float* %26, float** %30
br label %31
31: ; preds = %24
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %20
34: ; preds = %20
%35 = load float**, float*** %7
store float** %35, float*** %3
br label %36
36: ; preds = %34, %16
%37 = load float**, float*** %3
ret float** %37
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [51 x i8] c"ALLOC_2D_DBL: Couldn't allocate array of dbl ptrs\0A\00"
define float** @alloc_2d_dbl(i32 %0, i32 %1) {
%3 = shl i32 %0, 3
%4 = tail call i64 @malloc(i32 %3)
%5 = inttoptr i64 %4 to float**
%6 = icmp eq i64 %4, 0
br i1 %6, label %11, label %7
7: ; preds = %2
%8 = icmp sgt i32 %0, 0
br i1 %8, label %9, label %20
9: ; preds = %7
%10 = zext i32 %0 to i64
br label %14
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
br label %20
14: ; preds = %9, %14
%15 = phi i64 [ 0, %9 ], [ %18, %14 ]
%16 = tail call float* @alloc_1d_dbl(i32 %1)
%17 = getelementptr inbounds float*, float** %5, i64 %15
store float* %16, float** %17
%18 = add nuw nsw i64 %15, 1
%19 = icmp eq i64 %18, %10
br i1 %19, label %20, label %14
20: ; preds = %14, %7, %11
%21 = phi float** [ null, %11 ], [ %5, %7 ], [ %5, %14 ]
ret float** %21
}