#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*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ malloc(int);
int /*<<< orphan*/ stderr;
extern int alloc_matrix(double ***ptr_X, int n) {
  int status = 0;
  double **X = NULL;
  *ptr_X = NULL;
  X = (double **)malloc(n * sizeof(double *));
  {
    if (X == NULL) {
      fprintf(stderr, "Unable to allocate memory\n");
      {
        {
          fprintf(stderr, "Line %3d of File %s \n", 136,
                  "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/NerdWalletOSS/Q/refs/"
                  "heads/master/OPERATORS/AX_EQUALS_B/src/matrix_helpers.c");
        };
        status = -1;
        goto BYE;
      };
    }
  };
  for (int i = 0; i < n; i++) {
    X[i] = NULL;
  }
  for (int i = 0; i < n; i++) {
    X[i] = (double *)malloc(n * sizeof(double));
    {
      if (X[i] == NULL) {
        fprintf(stderr, "Unable to allocate memory\n");
        {
          {
            fprintf(stderr, "Line %3d of File %s \n", 140,
                    "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                    "outputs/2022-01-22/02-19-57/repos/NerdWalletOSS/Q/refs/"
                    "heads/master/OPERATORS/AX_EQUALS_B/src/matrix_helpers.c");
          };
          status = -1;
          goto BYE;
        };
      }
    };
  }
  *ptr_X = X;
BYE:
  return status;
}


x86 assembly (clang, -O0):
<alloc_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ad <alloc_matrix+0x8d>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
lea    0xe89(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
lea    0xe8d(%rip),%rsi
mov    $0x88,%edx
lea    0xe97(%rip),%rcx
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x10(%rbp)
jmp    1286 <alloc_matrix+0x166>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11de <alloc_matrix+0xbe>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b4 <alloc_matrix+0x94>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    127b <alloc_matrix+0x15b>
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    1268 <alloc_matrix+0x148>
mov    0x2db7(%rip),%rax
mov    (%rax),%edi
lea    0xdce(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
lea    0xdd2(%rip),%rsi
mov    $0x8c,%edx
lea    0xddc(%rip),%rcx
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x10(%rbp)
jmp    1286 <alloc_matrix+0x166>
jmp    126d <alloc_matrix+0x14d>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11e5 <alloc_matrix+0xc5>
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alloc_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r15d
mov    %rdi,%r14
movq   $0x0,(%rdi)
lea    0x0(,%r15,8),%r12d
mov    %r12d,%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     11a1 <alloc_matrix+0x71>
mov    %rax,%rbx
test   %r15d,%r15d
jle    119a <alloc_matrix+0x6a>
mov    %r15d,%r15d
lea    0x0(,%r15,8),%rdx
xor    %ebp,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
nopl   0x0(%rax)
mov    %r12d,%edi
call   1050 <malloc@plt>
mov    %rax,(%rbx,%rbp,8)
test   %rax,%rax
je     11cf <alloc_matrix+0x9f>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1180 <alloc_matrix+0x50>
mov    %rbx,(%r14)
xor    %eax,%eax
jmp    1207 <alloc_matrix+0xd7>
mov    0x2e38(%rip),%rbx
mov    (%rbx),%edi
lea    0xe4f(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe5a(%rip),%rsi
lea    0xe69(%rip),%rcx
mov    $0x88,%edx
jmp    11fb <alloc_matrix+0xcb>
mov    0x2e0a(%rip),%rbx
mov    (%rbx),%edi
lea    0xe21(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe2c(%rip),%rsi
lea    0xe3b(%rip),%rcx
mov    $0x8c,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [27 x i8] c"Unable to allocate memory\0A\00"
@.str.1 = [22 x i8] c"Line %3d of File %s \0A\00"
@.str.2 = [167 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/NerdWalletOSS/Q/refs/heads/master/OPERATORS/AX_EQUALS_B/src/matrix_helpers.c\00"
define i32 @alloc_matrix(double*** %0, i32 %1) {
%3 = alloca double***
%4 = alloca i32
%5 = alloca i32
%6 = alloca double**
%7 = alloca i32
%8 = alloca i32
store double*** %0, double**** %3
store i32 %1, i32* %4
store i32 0, i32* %5
store double** null, double*** %6
%9 = load double***, double**** %3
store double** null, double*** %9
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = mul i64 %11, 8
%13 = trunc i64 %12 to i32
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to double**
store double** %15, double*** %6
%16 = load double**, double*** %6
%17 = icmp eq double** %16, null
br i1 %17, label %18, label %23
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%21 = load i32, i32* @stderr
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 136, i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %5
br label %70
23: ; preds = %2
store i32 0, i32* %7
br label %24
24: ; preds = %33, %23
%25 = load i32, i32* %7
%26 = load i32, i32* %4
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %36
28: ; preds = %24
%29 = load double**, double*** %6
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double*, double** %29, i64 %31
store double* null, double** %32
br label %33
33: ; preds = %28
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %24
36: ; preds = %24
store i32 0, i32* %8
br label %37
37: ; preds = %64, %36
%38 = load i32, i32* %8
%39 = load i32, i32* %4
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %67
41: ; preds = %37
%42 = load i32, i32* %4
%43 = sext i32 %42 to i64
%44 = mul i64 %43, 8
%45 = trunc i64 %44 to i32
%46 = call i64 @malloc(i32 %45)
%47 = inttoptr i64 %46 to double*
%48 = load double**, double*** %6
%49 = load i32, i32* %8
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double*, double** %48, i64 %50
store double* %47, double** %51
%52 = load double**, double*** %6
%53 = load i32, i32* %8
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double*, double** %52, i64 %54
%56 = load double*, double** %55
%57 = icmp eq double* %56, null
br i1 %57, label %58, label %63
58: ; preds = %41
%59 = load i32, i32* @stderr
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%61 = load i32, i32* @stderr
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 140, i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %5
br label %70
63: ; preds = %41
br label %64
64: ; preds = %63
%65 = load i32, i32* %8
%66 = add nsw i32 %65, 1
store i32 %66, i32* %8
br label %37
67: ; preds = %37
%68 = load double**, double*** %6
%69 = load double***, double**** %3
store double** %68, double*** %69
br label %70
70: ; preds = %67, %58, %18
%71 = load i32, i32* %5
ret i32 %71
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"Unable to allocate memory\0A\00"
@.str.1 = [22 x i8] c"Line %3d of File %s \0A\00"
@.str.2 = [167 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/NerdWalletOSS/Q/refs/heads/master/OPERATORS/AX_EQUALS_B/src/matrix_helpers.c\00"
define i32 @alloc_matrix(double*** nocapture writeonly %0, i32 %1) {
store double** null, double*** %0
%3 = shl i32 %1, 3
%4 = tail call i64 @malloc(i32 %3)
%5 = inttoptr i64 %4 to double**
%6 = inttoptr i64 %4 to i8*
%7 = icmp eq i64 %4, 0
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = icmp sgt i32 %1, 0
br i1 %9, label %15, label %33
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 136, i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.2, i64 0, i64 0))
br label %34
15: ; preds = %8
%16 = zext i32 %1 to i64
%17 = shl nuw nsw i64 %16, 3
%18 = zext i32 %1 to i64
br label %21
19: ; preds = %21
%20 = icmp eq i64 %27, %18
br i1 %20, label %33, label %21
21: ; preds = %15, %19
%22 = phi i64 [ 0, %15 ], [ %27, %19 ]
%23 = tail call i64 @malloc(i32 %3)
%24 = inttoptr i64 %23 to double*
%25 = getelementptr inbounds double*, double** %5, i64 %22
store double* %24, double** %25
%26 = icmp eq i64 %23, 0
%27 = add nuw nsw i64 %22, 1
br i1 %26, label %28, label %19
28: ; preds = %21
%29 = load i32, i32* @stderr
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%31 = load i32, i32* @stderr
%32 = tail call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 140, i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.2, i64 0, i64 0))
br label %34
33: ; preds = %19, %8
store double** %5, double*** %0
br label %34
34: ; preds = %28, %10, %33
%35 = phi i32 [ -1, %10 ], [ -1, %28 ], [ 0, %33 ]
ret i32 %35
}