#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*/ dpotrf_(char *, int *, double *, int *, int *);
int /*<<< orphan*/ dpotrs_(char *, int *, int *, double *, int *, double *,
                           int *, int *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(double *, double *, int);
int /*<<< orphan*/ stderr;
int dAx_eq_b_Chol(double *A, double *B, double *x, int m) {
  static double *buf = NULL;
  static int buf_sz = 0;
  double *a;
  int a_sz, tot_sz;
  int info, nrhs = 1;
  if (!A) {
    if (buf)
      free(buf);
    buf = NULL;
    buf_sz = 0;
    return 1;
  }
  a_sz = m * m;
  tot_sz = a_sz;
  if (tot_sz > buf_sz) {
    if (buf)
      free(buf);
    buf_sz = tot_sz;
    buf = (double *)malloc(buf_sz * sizeof(double));
    if (!buf) {
      fprintf(stderr, "memory allocation in "
                      "dAx_eq_b_Chol"
                      "() failed!\n");
      exit(1);
    }
  }
  a = buf;
  memcpy(a, A, a_sz * sizeof(double));
  memcpy(x, B, m * sizeof(double));
  dpotrf_("L", (int *)&m, a, (int *)&m, (int *)&info);
  if (info != 0) {
    if (info < 0) {
      fprintf(stderr,
              "LAPACK error: illegal value for argument %d of "
              "dpotf2_"
              "/"
              "dpotrf_"
              " in "
              "dAx_eq_b_Chol"
              "()\n",
              -info);
      exit(1);
    } else {
      fprintf(stderr,
              "LAPACK error: the leading minor of order %d is not positive "
              "definite,\nthe factorization could not be completed for "
              "dpotf2_"
              "/"
              "dpotrf_"
              " in "
              "dAx_eq_b_Chol"
              "()\n",
              info);
      return 0;
    }
  }
  dpotrs_("L", (int *)&m, (int *)&nrhs, a, (int *)&m, x, (int *)&m, &info);
  if (info < 0) {
    fprintf(stderr,
            "LAPACK error: illegal value for argument %d of "
            "dpotrs_"
            " in "
            "dAx_eq_b_Chol"
            "()\n",
            -info);
    exit(1);
  }
  return 1;
}


x86 assembly (clang, -O0):
<dAx_eq_b_Chol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
movl   $0x1,-0x40(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11d4 <dAx_eq_b_Chol+0x64>
cmpq   $0x0,0x2ebf(%rip)
je     11b3 <dAx_eq_b_Chol+0x43>
mov    0x2eb2(%rip),%rdi
call   1030 <free@plt>
movq   $0x0,0x2ea2(%rip)
movl   $0x0,0x2ea0(%rip)
movl   $0x1,-0x4(%rbp)
jmp    137d <dAx_eq_b_Chol+0x20d>
mov    -0x24(%rbp),%eax
imul   -0x24(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    0x2e7b(%rip),%eax
jle    1263 <dAx_eq_b_Chol+0xf3>
cmpq   $0x0,0x2e65(%rip)
je     120d <dAx_eq_b_Chol+0x9d>
mov    0x2e58(%rip),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%eax
mov    %eax,0x2e52(%rip)
movslq 0x2e4b(%rip),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,0x2e31(%rip)
cmpq   $0x0,0x2e29(%rip)
jne    125e <dAx_eq_b_Chol+0xee>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
lea    0xdb3(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    1263 <dAx_eq_b_Chol+0xf3>
mov    0x2df6(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x34(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1070 <memcpy@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1070 <memcpy@plt>
mov    -0x30(%rbp),%rdx
lea    0xd87(%rip),%rdi
lea    -0x24(%rbp),%rcx
lea    -0x3c(%rbp),%r8
mov    %rcx,%rsi
call   1040 <dpotrf_@plt>
cmpl   $0x0,-0x3c(%rbp)
je     1317 <dAx_eq_b_Chol+0x1a7>
cmpl   $0x0,-0x3c(%rbp)
jge    12f1 <dAx_eq_b_Chol+0x181>
mov    0x2d0e(%rip),%rax
mov    (%rax),%edi
xor    %edx,%edx
sub    -0x3c(%rbp),%edx
lea    0xd50(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2ce8(%rip),%rax
mov    (%rax),%edi
mov    -0x3c(%rbp),%edx
lea    0xd7f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    137d <dAx_eq_b_Chol+0x20d>
mov    -0x30(%rbp),%rcx
mov    -0x20(%rbp),%r9
lea    0xd08(%rip),%rdi
lea    -0x24(%rbp),%r10
lea    -0x40(%rbp),%rdx
lea    -0x3c(%rbp),%rax
mov    %r10,%rsi
mov    %r10,%r8
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1060 <dpotrs_@plt>
cmpl   $0x0,-0x3c(%rbp)
jge    1376 <dAx_eq_b_Chol+0x206>
mov    0x2c89(%rip),%rax
mov    (%rax),%edi
xor    %edx,%edx
sub    -0x3c(%rbp),%edx
lea    0xdb5(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dAx_eq_b_Chol>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,0x14(%rsp)
movl   $0x1,0x10(%rsp)
test   %rdi,%rdi
je     11fb <dAx_eq_b_Chol+0x8b>
mov    %ecx,%ebx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    %ecx,%ebp
imul   %ebx,%ebp
mov    0x2eba(%rip),%r13
cmp    0x2ebc(%rip),%ebp
jle    122b <dAx_eq_b_Chol+0xbb>
test   %r13,%r13
je     11bb <dAx_eq_b_Chol+0x4b>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %ebp,0x2ea7(%rip)
shl    $0x3,%ebp
mov    %ebp,%edi
call   1080 <malloc@plt>
mov    %rax,%r13
mov    %rax,0x2e8b(%rip)
test   %rax,%rax
jne    122e <dAx_eq_b_Chol+0xbe>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
lea    0xe16(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2e5e(%rip),%rdi
test   %rdi,%rdi
je     120c <dAx_eq_b_Chol+0x9c>
call   1030 <free@plt>
movq   $0x0,0x2e49(%rip)
movl   $0x0,0x2e47(%rip)
mov    $0x1,%ebx
jmp    12c2 <dAx_eq_b_Chol+0x152>
shl    $0x3,%ebp
mov    %r13,%rdi
mov    %r12,%rsi
mov    %ebp,%edx
call   1070 <memcpy@plt>
shl    $0x3,%ebx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1070 <memcpy@plt>
lea    0xddc(%rip),%rdi
lea    0x14(%rsp),%rbx
lea    0xc(%rsp),%rbp
mov    %rbx,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
mov    %rbp,%r8
call   1040 <dpotrf_@plt>
mov    0xc(%rsp),%edx
test   %edx,%edx
je     1292 <dAx_eq_b_Chol+0x122>
mov    0x2d64(%rip),%rax
mov    (%rax),%edi
js     12d3 <dAx_eq_b_Chol+0x163>
lea    0xdfc(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    12c2 <dAx_eq_b_Chol+0x152>
lea    0xd95(%rip),%rdi
lea    0x10(%rsp),%rdx
mov    %rbx,%rsi
mov    %r13,%rcx
mov    %rbx,%r8
mov    %r14,%r9
push   %rbp
push   %rbx
call   1060 <dpotrs_@plt>
add    $0x10,%rsp
mov    0xc(%rsp),%edx
mov    $0x1,%ebx
test   %edx,%edx
js     12de <dAx_eq_b_Chol+0x16e>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
neg    %edx
lea    0xd54(%rip),%rsi
jmp    12f0 <dAx_eq_b_Chol+0x180>
mov    0x2cfb(%rip),%rax
mov    (%rax),%edi
neg    %edx
lea    0xe2a(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@dAx_eq_b_Chol.buf = internal global double* null
@dAx_eq_b_Chol.buf_sz = internal global i32 0
@stderr = global i32 0
@.str = [46 x i8] c"memory allocation in dAx_eq_b_Chol() failed!\0A\00"
@.str.1 = [2 x i8] c"L\00"
@.str.2 = [83 x i8] c"LAPACK error: illegal value for argument %d of dpotf2_/dpotrf_ in dAx_eq_b_Chol()\0A\00"
@.str.3 = [151 x i8] c"LAPACK error: the leading minor of order %d is not positive definite,\0Athe factorization could not be completed for dpotf2_/dpotrf_ in dAx_eq_b_Chol()\0A\00"
@.str.4 = [75 x i8] c"LAPACK error: illegal value for argument %d of dpotrs_ in dAx_eq_b_Chol()\0A\00"
define i32 @dAx_eq_b_Chol(double* %0, double* %1, double* %2, i32 %3) {
%5 = alloca i32
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
%10 = alloca double*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store double* %0, double** %6
store double* %1, double** %7
store double* %2, double** %8
store i32 %3, i32* %9
store i32 1, i32* %14
%15 = load double*, double** %6
%16 = icmp ne double* %15, null
br i1 %16, label %24, label %17
17: ; preds = %4
%18 = load double*, double** @dAx_eq_b_Chol.buf
%19 = icmp ne double* %18, null
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load double*, double** @dAx_eq_b_Chol.buf
%22 = call i32 @free(double* %21)
br label %23
23: ; preds = %20, %17
store double* null, double** @dAx_eq_b_Chol.buf
store i32 0, i32* @dAx_eq_b_Chol.buf_sz
store i32 1, i32* %5
br label %99
24: ; preds = %4
%25 = load i32, i32* %9
%26 = load i32, i32* %9
%27 = mul nsw i32 %25, %26
store i32 %27, i32* %11
%28 = load i32, i32* %11
store i32 %28, i32* %12
%29 = load i32, i32* %12
%30 = load i32, i32* @dAx_eq_b_Chol.buf_sz
%31 = icmp sgt i32 %29, %30
br i1 %31, label %32, label %53
32: ; preds = %24
%33 = load double*, double** @dAx_eq_b_Chol.buf
%34 = icmp ne double* %33, null
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load double*, double** @dAx_eq_b_Chol.buf
%37 = call i32 @free(double* %36)
br label %38
38: ; preds = %35, %32
%39 = load i32, i32* %12
store i32 %39, i32* @dAx_eq_b_Chol.buf_sz
%40 = load i32, i32* @dAx_eq_b_Chol.buf_sz
%41 = sext i32 %40 to i64
%42 = mul i64 %41, 8
%43 = trunc i64 %42 to i32
%44 = call i64 @malloc(i32 %43)
%45 = inttoptr i64 %44 to double*
store double* %45, double** @dAx_eq_b_Chol.buf
%46 = load double*, double** @dAx_eq_b_Chol.buf
%47 = icmp ne double* %46, null
br i1 %47, label %52, label %48
48: ; preds = %38
%49 = load i32, i32* @stderr
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %38
br label %53
53: ; preds = %52, %24
%54 = load double*, double** @dAx_eq_b_Chol.buf
store double* %54, double** %10
%55 = load double*, double** %10
%56 = load double*, double** %6
%57 = load i32, i32* %11
%58 = sext i32 %57 to i64
%59 = mul i64 %58, 8
%60 = trunc i64 %59 to i32
%61 = call i32 @memcpy(double* %55, double* %56, i32 %60)
%62 = load double*, double** %8
%63 = load double*, double** %7
%64 = load i32, i32* %9
%65 = sext i32 %64 to i64
%66 = mul i64 %65, 8
%67 = trunc i64 %66 to i32
%68 = call i32 @memcpy(double* %62, double* %63, i32 %67)
%69 = load double*, double** %10
%70 = call i32 @dpotrf_(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32* %9, double* %69, i32* %9, i32* %13)
%71 = load i32, i32* %13
%72 = icmp ne i32 %71, 0
br i1 %72, label %73, label %86
73: ; preds = %53
%74 = load i32, i32* %13
%75 = icmp slt i32 %74, 0
br i1 %75, label %76, label %82
76: ; preds = %73
%77 = load i32, i32* @stderr
%78 = load i32, i32* %13
%79 = sub nsw i32 0, %78
%80 = call i32 (i32, i8*, ...) @fprintf(i32 %77, i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.2, i64 0, i64 0), i32 %79)
%81 = call i32 @exit(i32 1)
unreachable
82: ; preds = %73
%83 = load i32, i32* @stderr
%84 = load i32, i32* %13
%85 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.3, i64 0, i64 0), i32 %84)
store i32 0, i32* %5
br label %99
86: ; preds = %53
%87 = load double*, double** %10
%88 = load double*, double** %8
%89 = call i32 @dpotrs_(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32* %9, i32* %14, double* %87, i32* %9, double* %88, i32* %9, i32* %13)
%90 = load i32, i32* %13
%91 = icmp slt i32 %90, 0
br i1 %91, label %92, label %98
92: ; preds = %86
%93 = load i32, i32* @stderr
%94 = load i32, i32* %13
%95 = sub nsw i32 0, %94
%96 = call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.4, i64 0, i64 0), i32 %95)
%97 = call i32 @exit(i32 1)
unreachable
98: ; preds = %86
store i32 1, i32* %5
br label %99
99: ; preds = %98, %82, %23
%100 = load i32, i32* %5
ret i32 %100
}

LLVM IR (-O2):
@dAx_eq_b_Chol.buf = internal unnamed_addr global double* null
@dAx_eq_b_Chol.buf_sz = internal unnamed_addr global i32 0
@stderr = global i32 0
@.str = [46 x i8] c"memory allocation in dAx_eq_b_Chol() failed!\0A\00"
@.str.1 = [2 x i8] c"L\00"
@.str.2 = [83 x i8] c"LAPACK error: illegal value for argument %d of dpotf2_/dpotrf_ in dAx_eq_b_Chol()\0A\00"
@.str.3 = [151 x i8] c"LAPACK error: the leading minor of order %d is not positive definite,\0Athe factorization could not be completed for dpotf2_/dpotrf_ in dAx_eq_b_Chol()\0A\00"
@.str.4 = [75 x i8] c"LAPACK error: illegal value for argument %d of dpotrs_ in dAx_eq_b_Chol()\0A\00"
define i32 @dAx_eq_b_Chol(double* %0, double* %1, double* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %3, i32* %5
%8 = bitcast i32* %6 to i8*
%9 = bitcast i32* %7 to i8*
store i32 1, i32* %7
%10 = icmp eq double* %0, null
br i1 %10, label %11, label %17
11: ; preds = %4
%12 = load double*, double** @dAx_eq_b_Chol.buf
%13 = icmp eq double* %12, null
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = tail call i32 @free(double* %12)
br label %16
16: ; preds = %14, %11
store double* null, double** @dAx_eq_b_Chol.buf
store i32 0, i32* @dAx_eq_b_Chol.buf_sz
br label %64
17: ; preds = %4
%18 = mul nsw i32 %3, %3
%19 = load i32, i32* @dAx_eq_b_Chol.buf_sz
%20 = icmp sgt i32 %18, %19
%21 = load double*, double** @dAx_eq_b_Chol.buf
br i1 %20, label %24, label %22
22: ; preds = %17
%23 = shl i32 %18, 3
br label %37
24: ; preds = %17
%25 = icmp eq double* %21, null
br i1 %25, label %28, label %26
26: ; preds = %24
%27 = tail call i32 @free(double* %21)
br label %28
28: ; preds = %26, %24
store i32 %18, i32* @dAx_eq_b_Chol.buf_sz
%29 = shl i32 %18, 3
%30 = tail call i64 @malloc(i32 %29)
%31 = inttoptr i64 %30 to double*
store double* %31, double** @dAx_eq_b_Chol.buf
%32 = icmp eq i64 %30, 0
br i1 %32, label %33, label %37
33: ; preds = %28
%34 = load i32, i32* @stderr
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%36 = tail call i32 @exit(i32 1)
unreachable
37: ; preds = %22, %28
%38 = phi i32 [ %23, %22 ], [ %29, %28 ]
%39 = phi double* [ %21, %22 ], [ %31, %28 ]
%40 = tail call i32 @memcpy(double* %39, double* %0, i32 %38)
%41 = shl i32 %3, 3
%42 = tail call i32 @memcpy(double* %2, double* %1, i32 %41)
%43 = call i32 @dpotrf_(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32* %5, double* %39, i32* %5, i32* %6)
%44 = load i32, i32* %6
%45 = icmp eq i32 %44, 0
br i1 %45, label %55, label %46
46: ; preds = %37
%47 = icmp slt i32 %44, 0
%48 = load i32, i32* @stderr
br i1 %47, label %49, label %53
49: ; preds = %46
%50 = sub nsw i32 0, %44
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.2, i64 0, i64 0), i32 %50)
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %46
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.3, i64 0, i64 0), i32 %44)
br label %64
55: ; preds = %37
%56 = call i32 @dpotrs_(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32* %5, i32* %7, double* %39, i32* %5, double* %2, i32* %5, i32* %6)
%57 = load i32, i32* %6
%58 = icmp slt i32 %57, 0
br i1 %58, label %59, label %64
59: ; preds = %55
%60 = load i32, i32* @stderr
%61 = sub nsw i32 0, %57
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.4, i64 0, i64 0), i32 %61)
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %55, %53, %16
%65 = phi i32 [ 0, %53 ], [ 1, %16 ], [ 1, %55 ]
ret i32 %65
}