#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__ safe_malloc(int);
float **alloc_float_matrix(float **matrix, int nRow, int nCol) {
  unsigned int i;
  matrix = (float **)safe_malloc(nRow * sizeof(float *));
  for (i = 0; i < nRow; ++i)
    matrix[i] = (float *)safe_malloc(nCol * sizeof(float));
  return matrix;
}


x86 assembly (clang, -O0):
<alloc_float_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <safe_malloc@plt>
mov    %rax,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1173 <alloc_float_matrix+0x63>
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <safe_malloc@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113c <alloc_float_matrix+0x2c>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alloc_float_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r15d
mov    %esi,%r14d
lea    0x0(,%r14,8),%edi
call   1030 <safe_malloc@plt>
mov    %rax,%r12
test   %r14d,%r14d
je     1155 <alloc_float_matrix+0x45>
shl    $0x2,%r15d
mov    %r14d,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r15d,%edi
call   1030 <safe_malloc@plt>
mov    %rax,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1140 <alloc_float_matrix+0x30>
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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