#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_symm_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", 62,
                  "/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 - i) * sizeof(double));
    {
      if (X[i] == NULL) {
        fprintf(stderr, "Unable to allocate memory\n");
        {
          {
            fprintf(stderr, "Line %3d of File %s \n", 66,
                    "/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_symm_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_symm_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    $0x3e,%edx
lea    0xe97(%rip),%rcx
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x10(%rbp)
jmp    128a <alloc_symm_matrix+0x16a>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11de <alloc_symm_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_symm_matrix+0x94>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    127f <alloc_symm_matrix+0x15f>
mov    -0xc(%rbp),%eax
sub    -0x20(%rbp),%eax
cltq
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    126c <alloc_symm_matrix+0x14c>
mov    0x2db3(%rip),%rax
mov    (%rax),%edi
lea    0xdca(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
lea    0xdce(%rip),%rsi
mov    $0x42,%edx
lea    0xdd8(%rip),%rcx
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x10(%rbp)
jmp    128a <alloc_symm_matrix+0x16a>
jmp    1271 <alloc_symm_matrix+0x151>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11e5 <alloc_symm_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_symm_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r15d
mov    %rdi,%r14
movq   $0x0,(%rdi)
lea    0x0(,%r15,8),%ebp
mov    %ebp,%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     11a3 <alloc_symm_matrix+0x73>
mov    %rax,%r12
test   %r15d,%r15d
jle    119c <alloc_symm_matrix+0x6c>
mov    %r15d,%r15d
lea    0x0(,%r15,8),%rdx
xor    %ebx,%ebx
mov    %r12,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1050 <malloc@plt>
mov    %rax,(%r12,%rbx,8)
test   %rax,%rax
je     11d1 <alloc_symm_matrix+0xa1>
add    $0x1,%rbx
add    $0xfffffff8,%ebp
cmp    %rbx,%r15
jne    1180 <alloc_symm_matrix+0x50>
mov    %r12,(%r14)
xor    %eax,%eax
jmp    1209 <alloc_symm_matrix+0xd9>
mov    0x2e36(%rip),%rbx
mov    (%rbx),%edi
lea    0xe4d(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe58(%rip),%rsi
lea    0xe67(%rip),%rcx
mov    $0x3e,%edx
jmp    11fd <alloc_symm_matrix+0xcd>
mov    0x2e08(%rip),%rbx
mov    (%rbx),%edi
lea    0xe1f(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe2a(%rip),%rsi
lea    0xe39(%rip),%rcx
mov    $0x42,%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_symm_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 62, i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %5
br label %72
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 = %66, %36
%38 = load i32, i32* %8
%39 = load i32, i32* %4
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %69
41: ; preds = %37
%42 = load i32, i32* %4
%43 = load i32, i32* %8
%44 = sub nsw i32 %42, %43
%45 = sext i32 %44 to i64
%46 = mul i64 %45, 8
%47 = trunc i64 %46 to i32
%48 = call i64 @malloc(i32 %47)
%49 = inttoptr i64 %48 to double*
%50 = load double**, double*** %6
%51 = load i32, i32* %8
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds double*, double** %50, i64 %52
store double* %49, double** %53
%54 = load double**, double*** %6
%55 = load i32, i32* %8
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double*, double** %54, i64 %56
%58 = load double*, double** %57
%59 = icmp eq double* %58, null
br i1 %59, label %60, label %65
60: ; preds = %41
%61 = load i32, i32* @stderr
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%63 = load i32, i32* @stderr
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 66, i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %5
br label %72
65: ; preds = %41
br label %66
66: ; preds = %65
%67 = load i32, i32* %8
%68 = add nsw i32 %67, 1
store i32 %68, i32* %8
br label %37
69: ; preds = %37
%70 = load double**, double*** %6
%71 = load double***, double**** %3
store double** %70, double*** %71
br label %72
72: ; preds = %69, %60, %18
%73 = load i32, i32* %5
ret i32 %73
}

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_symm_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 %36
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 62, i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.2, i64 0, i64 0))
br label %37
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 %30, %18
br i1 %20, label %36, label %21
21: ; preds = %15, %19
%22 = phi i64 [ 0, %15 ], [ %30, %19 ]
%23 = trunc i64 %22 to i32
%24 = sub nsw i32 %1, %23
%25 = shl i32 %24, 3
%26 = tail call i64 @malloc(i32 %25)
%27 = inttoptr i64 %26 to double*
%28 = getelementptr inbounds double*, double** %5, i64 %22
store double* %27, double** %28
%29 = icmp eq i64 %26, 0
%30 = add nuw nsw i64 %22, 1
br i1 %29, label %31, label %19
31: ; preds = %21
%32 = load i32, i32* @stderr
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%34 = load i32, i32* @stderr
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 66, i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.2, i64 0, i64 0))
br label %37
36: ; preds = %19, %8
store double** %5, double*** %0
br label %37
37: ; preds = %31, %10, %36
%38 = phi i32 [ -1, %10 ], [ -1, %31 ], [ 0, %36 ]
ret i32 %38
}