#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 */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
scalar_t__ malloc(int);
int /*<<< orphan*/ stderr;
double **dmatrix(int num_row, int num_col) {
  int i, j;
  double **m;
  m = (double **)malloc(num_row * sizeof(double *));
  if (!m) {
    fprintf(stderr, "%s\n",
            "[ERROR]: Allocation failure for points to rows in dmatrix()");
    exit(EXIT_FAILURE);
  }
  for (i = 0; i < num_row; i++) {
    m[i] = (double *)malloc(num_col * sizeof(double));
    if (!m[i]) {
      fprintf(stderr, "%s %d %s\n", "[ERROR]: Allocation failure for the row ",
              i, " in dmatrix()");
      exit(EXIT_FAILURE);
    }
    for (j = 0; j < num_col; j++) {
      m[i][j] = 0.0;
    }
  }
  return m;
}


x86 assembly (clang, -O0):
<dmatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1188 <dmatrix+0x58>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
lea    0xed6(%rip),%rsi
lea    0xe8d(%rip),%rdx
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    124e <dmatrix+0x11e>
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    1202 <dmatrix+0xd2>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%ecx
lea    0xe5d(%rip),%rsi
lea    0xe60(%rip),%rdx
lea    0xe41(%rip),%r8
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    123b <dmatrix+0x10b>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x10(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1209 <dmatrix+0xd9>
jmp    1240 <dmatrix+0x110>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118f <dmatrix+0x5f>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dmatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%ebx
lea    0x0(,%rbx,8),%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     1205 <dmatrix+0xc5>
mov    %rax,%r15
test   %ebx,%ebx
jle    11be <dmatrix+0x7e>
lea    0x0(,%r14,8),%r13d
mov    %r14d,%r12d
shl    $0x3,%r12
mov    %ebx,%ebp
xor    %ebx,%ebx
jmp    1199 <dmatrix+0x59>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%rbp
je     11be <dmatrix+0x7e>
mov    %r13d,%edi
call   1050 <malloc@plt>
mov    %rax,(%r15,%rbx,8)
test   %rax,%rax
je     11d0 <dmatrix+0x90>
test   %r14d,%r14d
jle    1190 <dmatrix+0x50>
mov    %rax,%rdi
xor    %esi,%esi
mov    %r12,%rdx
call   1030 <memset@plt>
jmp    1190 <dmatrix+0x50>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
lea    0xe5c(%rip),%rsi
lea    0xe5f(%rip),%rdx
lea    0xe40(%rip),%r8
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    0x2dd4(%rip),%rax
mov    (%rax),%edi
lea    0xe2d(%rip),%rsi
lea    0xde4(%rip),%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    11f7 <dmatrix+0xb7>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [60 x i8] c"[ERROR]: Allocation failure for points to rows in dmatrix()\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [10 x i8] c"%s %d %s\0A\00"
@.str.3 = [41 x i8] c"[ERROR]: Allocation failure for the row \00"
@.str.4 = [14 x i8] c" in dmatrix()\00"
define double** @dmatrix(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double**
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* %3
%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 double**
store double** %13, double*** %7
%14 = load double**, double*** %7
%15 = icmp ne double** %14, null
br i1 %15, label %21, label %16
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0))
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %2
store i32 0, i32* %5
br label %22
22: ; preds = %67, %21
%23 = load i32, i32* %5
%24 = load i32, i32* %3
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %70
26: ; preds = %22
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = mul i64 %28, 8
%30 = trunc i64 %29 to i32
%31 = call i64 @malloc(i32 %30)
%32 = inttoptr i64 %31 to double*
%33 = load double**, double*** %7
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double*, double** %33, i64 %35
store double* %32, double** %36
%37 = load double**, double*** %7
%38 = load i32, i32* %5
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double*, double** %37, i64 %39
%41 = load double*, double** %40
%42 = icmp ne double* %41, null
br i1 %42, label %49, label %43
43: ; preds = %26
%44 = load i32, i32* @stderr
%45 = load i32, i32* %5
%46 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i32 %45, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%47 = load i32, i32* @EXIT_FAILURE
%48 = call i32 @exit(i32 %47)
unreachable
49: ; preds = %26
store i32 0, i32* %6
br label %50
50: ; preds = %63, %49
%51 = load i32, i32* %6
%52 = load i32, i32* %4
%53 = icmp slt i32 %51, %52
br i1 %53, label %54, label %66
54: ; preds = %50
%55 = load double**, double*** %7
%56 = load i32, i32* %5
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds double*, double** %55, i64 %57
%59 = load double*, double** %58
%60 = load i32, i32* %6
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds double, double* %59, i64 %61
store double 0.000000e+00, double* %62
br label %63
63: ; preds = %54
%64 = load i32, i32* %6
%65 = add nsw i32 %64, 1
store i32 %65, i32* %6
br label %50
66: ; preds = %50
br label %67
67: ; preds = %66
%68 = load i32, i32* %5
%69 = add nsw i32 %68, 1
store i32 %69, i32* %5
br label %22
70: ; preds = %22
%71 = load double**, double*** %7
ret double** %71
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [60 x i8] c"[ERROR]: Allocation failure for points to rows in dmatrix()\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [10 x i8] c"%s %d %s\0A\00"
@.str.3 = [41 x i8] c"[ERROR]: Allocation failure for the row \00"
@.str.4 = [14 x i8] c" in dmatrix()\00"
define double** @dmatrix(i32 %0, i32 %1) {
%3 = shl i32 %0, 3
%4 = tail call i64 @malloc(i32 %3)
%5 = inttoptr i64 %4 to double**
%6 = icmp eq i64 %4, 0
br i1 %6, label %15, label %7
7: ; preds = %2
%8 = icmp sgt i32 %0, 0
br i1 %8, label %9, label %38
9: ; preds = %7
%10 = shl i32 %1, 3
%11 = icmp sgt i32 %1, 0
%12 = zext i32 %1 to i64
%13 = shl nuw nsw i64 %12, 3
%14 = zext i32 %0 to i64
br label %20
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = tail call i32 @exit(i32 %18)
unreachable
20: ; preds = %9, %35
%21 = phi i64 [ 0, %9 ], [ %36, %35 ]
%22 = tail call i64 @malloc(i32 %10)
%23 = inttoptr i64 %22 to double*
%24 = inttoptr i64 %22 to i8*
%25 = getelementptr inbounds double*, double** %5, i64 %21
store double* %23, double** %25
%26 = icmp eq i64 %22, 0
br i1 %26, label %29, label %27
27: ; preds = %20
br i1 %11, label %28, label %35
28: ; preds = %27
br label %35
29: ; preds = %20
%30 = trunc i64 %21 to i32
%31 = load i32, i32* @stderr
%32 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i32 %30, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%33 = load i32, i32* @EXIT_FAILURE
%34 = tail call i32 @exit(i32 %33)
unreachable
35: ; preds = %28, %27
%36 = add nuw nsw i64 %21, 1
%37 = icmp eq i64 %36, %14
br i1 %37, label %38, label %20
38: ; preds = %35, %7
ret double** %5
}