#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);
scalar_t__ malloc(unsigned int);
int /*<<< orphan*/ printf(char *);
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) {
    printf("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    1175 <alloc_2d_dbl+0x45>
lea    0xe9d(%rip),%rdi
call   1040 <printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    11b5 <alloc_2d_dbl+0x85>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ad <alloc_2d_dbl+0x7d>
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    117c <alloc_2d_dbl+0x4c>
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    1186 <alloc_2d_dbl+0x56>
mov    %r14d,%ebp
xor    %ebx,%ebx
nopl   (%rax)
mov    %r15d,%edi
call   1040 <alloc_1d_dbl@plt>
mov    %rax,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <alloc_2d_dbl+0x30>
jmp    1186 <alloc_2d_dbl+0x56>
lea    0xe82(%rip),%rdi
call   1030 <puts@plt>
xor    %r12d,%r12d
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.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 %18
16: ; preds = %2
%17 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
store float** null, float*** %3
br label %35
18: ; preds = %2
store i32 0, i32* %6
br label %19
19: ; preds = %30, %18
%20 = load i32, i32* %6
%21 = load i32, i32* %4
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %33
23: ; preds = %19
%24 = load i32, i32* %5
%25 = call float* @alloc_1d_dbl(i32 %24)
%26 = load float**, float*** %7
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds float*, float** %26, i64 %28
store float* %25, float** %29
br label %30
30: ; preds = %23
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %19
33: ; preds = %19
%34 = load float**, float*** %7
store float** %34, float*** %3
br label %35
35: ; preds = %33, %16
%36 = load float**, float*** %3
ret float** %36
}

LLVM IR (-O2):
@str = [50 x i8] c"ALLOC_2D_DBL: Couldn't allocate array of dbl ptrs\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 %19
9: ; preds = %7
%10 = zext i32 %0 to i64
br label %13
11: ; preds = %2
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str, i64 0, i64 0))
br label %19
13: ; preds = %9, %13
%14 = phi i64 [ 0, %9 ], [ %17, %13 ]
%15 = tail call float* @alloc_1d_dbl(i32 %1)
%16 = getelementptr inbounds float*, float** %5, i64 %14
store float* %15, float** %16
%17 = add nuw nsw i64 %14, 1
%18 = icmp eq i64 %17, %10
br i1 %18, label %19, label %13
19: ; preds = %13, %7, %11
%20 = phi float** [ null, %11 ], [ %5, %7 ], [ %5, %13 ]
ret float** %20
}