#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 */
double abs(double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(double *);
double *malloc(int);
int /*<<< orphan*/ multiply_matrix_vector(double **, double *, int, double *);
int /*<<< orphan*/ multiply_symm_matrix_vector(double **, double *, int,
                                               double *);
int /*<<< orphan*/ stderr;
bool _positive_solver_check(double **A, double *x, double *b, int n, double eps,
                            bool is_symm) {
  int status = 0;
  bool result = false;
  double *b_prime = NULL;
  b_prime = malloc(n * sizeof(double));
  {
    if (b_prime == NULL) {
      fprintf(stderr, "Unable to allocate memory\n");
      {
        {
          fprintf(stderr, "Line %3d of File %s \n", 91,
                  "/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/positive_solver.c");
        };
        status = -1;
        goto BYE;
      };
    }
  };
  if (is_symm) {
    multiply_symm_matrix_vector(A, x, n, b_prime);
  } else {
    multiply_matrix_vector(A, x, n, b_prime);
  }
  result = true;
  for (int i = 0; i < n; i++) {
    if (abs(b_prime[i] - b[i]) > eps) {
      result = false;
      break;
    }
  }
BYE : {
  if ((b_prime) != NULL) {
    free((b_prime));
    (b_prime) = NULL;
  }
};
  if (status != 0)
    result = false;
  return result;
}


x86 assembly (clang, -O0):
<_positive_solver_check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movsd  %xmm0,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movq   $0x0,-0x40(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    11fa <_positive_solver_check+0x9a>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
lea    0xe3c(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
lea    0xe40(%rip),%rsi
mov    $0x5b,%edx
lea    0xe4a(%rip),%rcx
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x30(%rbp)
jmp    1299 <_positive_solver_check+0x139>
cmpl   $0x0,-0x2c(%rbp)
je     121d <_positive_solver_check+0xbd>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x40(%rbp),%rcx
call   1060 <multiply_symm_matrix_vector@plt>
jmp    1231 <_positive_solver_check+0xd1>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x40(%rbp),%rcx
call   1040 <multiply_matrix_vector@plt>
movl   $0x1,-0x34(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1294 <_positive_solver_check+0x134>
mov    -0x40(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x44(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
call   1050 <abs@plt>
ucomisd -0x28(%rbp),%xmm0
jbe    1281 <_positive_solver_check+0x121>
movl   $0x0,-0x34(%rbp)
jmp    1294 <_positive_solver_check+0x134>
jmp    1286 <_positive_solver_check+0x126>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    123f <_positive_solver_check+0xdf>
jmp    1299 <_positive_solver_check+0x139>
cmpq   $0x0,-0x40(%rbp)
je     12b5 <_positive_solver_check+0x155>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x40(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     12c6 <_positive_solver_check+0x166>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_positive_solver_check>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r13d
movsd  %xmm0,(%rsp)
mov    %ecx,%r15d
mov    %rdx,%r14
mov    %rsi,%rbp
mov    %rdi,%rbx
lea    0x0(,%r15,8),%edi
call   1080 <malloc@plt>
test   %rax,%rax
je     11ac <_positive_solver_check+0x4c>
mov    %rax,%r12
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r15d,%edx
mov    %rax,%rcx
test   %r13d,%r13d
je     11e4 <_positive_solver_check+0x84>
call   1060 <multiply_symm_matrix_vector@plt>
jmp    11e9 <_positive_solver_check+0x89>
mov    0x2e2d(%rip),%rbx
mov    (%rbx),%edi
lea    0xe44(%rip),%rsi
xor    %r13d,%r13d
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe4c(%rip),%rsi
lea    0xe5b(%rip),%rcx
mov    $0x5b,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    122e <_positive_solver_check+0xce>
call   1040 <multiply_matrix_vector@plt>
mov    $0x1,%r13d
test   %r15d,%r15d
jle    1226 <_positive_solver_check+0xc6>
mov    %r15d,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax)
movsd  (%r12,%rbx,8),%xmm0
subsd  (%r14,%rbx,8),%xmm0
call   1050 <abs@plt>
ucomisd (%rsp),%xmm0
ja     1223 <_positive_solver_check+0xc3>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1200 <_positive_solver_check+0xa0>
jmp    1226 <_positive_solver_check+0xc6>
xor    %r13d,%r13d
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
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 = [168 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/positive_solver.c\00"
define i32 @_positive_solver_check(double** %0, double* %1, double* %2, i32 %3, double %4, i32 %5) {
%7 = alloca double**
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32
%11 = alloca double
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca double*
%16 = alloca i32
store double** %0, double*** %7
store double* %1, double** %8
store double* %2, double** %9
store i32 %3, i32* %10
store double %4, double* %11
store i32 %5, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
store double* null, double** %15
%17 = load i32, i32* %10
%18 = sext i32 %17 to i64
%19 = mul i64 %18, 8
%20 = trunc i64 %19 to i32
%21 = call double* @malloc(i32 %20)
store double* %21, double** %15
%22 = load double*, double** %15
%23 = icmp eq double* %22, null
br i1 %23, label %24, label %29
24: ; preds = %6
%25 = load i32, i32* @stderr
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%27 = load i32, i32* @stderr
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 91, i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %13
br label %70
29: ; preds = %6
%30 = load i32, i32* %12
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %38
32: ; preds = %29
%33 = load double**, double*** %7
%34 = load double*, double** %8
%35 = load i32, i32* %10
%36 = load double*, double** %15
%37 = call i32 @multiply_symm_matrix_vector(double** %33, double* %34, i32 %35, double* %36)
br label %44
38: ; preds = %29
%39 = load double**, double*** %7
%40 = load double*, double** %8
%41 = load i32, i32* %10
%42 = load double*, double** %15
%43 = call i32 @multiply_matrix_vector(double** %39, double* %40, i32 %41, double* %42)
br label %44
44: ; preds = %38, %32
store i32 1, i32* %14
store i32 0, i32* %16
br label %45
45: ; preds = %66, %44
%46 = load i32, i32* %16
%47 = load i32, i32* %10
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %69
49: ; preds = %45
%50 = load double*, double** %15
%51 = load i32, i32* %16
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds double, double* %50, i64 %52
%54 = load double, double* %53
%55 = load double*, double** %9
%56 = load i32, i32* %16
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds double, double* %55, i64 %57
%59 = load double, double* %58
%60 = fsub double %54, %59
%61 = call double @abs(double %60)
%62 = load double, double* %11
%63 = fcmp ogt double %61, %62
br i1 %63, label %64, label %65
64: ; preds = %49
store i32 0, i32* %14
br label %69
65: ; preds = %49
br label %66
66: ; preds = %65
%67 = load i32, i32* %16
%68 = add nsw i32 %67, 1
store i32 %68, i32* %16
br label %45
69: ; preds = %64, %45
br label %70
70: ; preds = %69, %24
%71 = load double*, double** %15
%72 = icmp ne double* %71, null
br i1 %72, label %73, label %76
73: ; preds = %70
%74 = load double*, double** %15
%75 = call i32 @free(double* %74)
store double* null, double** %15
br label %76
76: ; preds = %73, %70
%77 = load i32, i32* %13
%78 = icmp ne i32 %77, 0
br i1 %78, label %79, label %80
79: ; preds = %76
store i32 0, i32* %14
br label %80
80: ; preds = %79, %76
%81 = load i32, i32* %14
ret i32 %81
}

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 = [168 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/positive_solver.c\00"
define i32 @_positive_solver_check(double** %0, double* %1, double* nocapture %2, i32 %3, double %4, i32 %5) {
%7 = shl i32 %3, 3
%8 = tail call double* @malloc(i32 %7)
%9 = icmp eq double* %8, null
br i1 %9, label %10, label %15
10: ; preds = %6
%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 91, i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str.2, i64 0, i64 0))
br label %40
15: ; preds = %6
%16 = icmp eq i32 %5, 0
br i1 %16, label %19, label %17
17: ; preds = %15
%18 = tail call i32 @multiply_symm_matrix_vector(double** %0, double* %1, i32 %3, double* %8)
br label %21
19: ; preds = %15
%20 = tail call i32 @multiply_matrix_vector(double** %0, double* %1, i32 %3, double* %8)
br label %21
21: ; preds = %19, %17
%22 = icmp sgt i32 %3, 0
br i1 %22, label %23, label %37
23: ; preds = %21
%24 = zext i32 %3 to i64
br label %27
25: ; preds = %27
%26 = icmp eq i64 %36, %24
br i1 %26, label %37, label %27
27: ; preds = %23, %25
%28 = phi i64 [ 0, %23 ], [ %36, %25 ]
%29 = getelementptr inbounds double, double* %8, i64 %28
%30 = load double, double* %29
%31 = getelementptr inbounds double, double* %2, i64 %28
%32 = load double, double* %31
%33 = fsub double %30, %32
%34 = tail call double @abs(double %33)
%35 = fcmp ogt double %34, %4
%36 = add nuw nsw i64 %28, 1
br i1 %35, label %37, label %25
37: ; preds = %25, %27, %21
%38 = phi i32 [ 1, %21 ], [ 0, %27 ], [ 1, %25 ]
%39 = tail call i32 @free(double* %8)
br label %40
40: ; preds = %10, %37
%41 = phi i32 [ 0, %10 ], [ %38, %37 ]
ret i32 %41
}