#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(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(float *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(float *, float *, int);
int /*<<< orphan*/ spotrf_(char *, int *, float *, int *, int *);
int /*<<< orphan*/ spotrs_(char *, int *, int *, float *, int *, float *, int *,
                           int *);
int /*<<< orphan*/ stderr;
int sAx_eq_b_Chol(float *A, float *B, float *x, int m) {
  static float *buf = NULL;
  static int buf_sz = 0;
  float *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 = (float *)malloc(buf_sz * sizeof(float));
    if (!buf) {
      fprintf(stderr, "memory allocation in "
                      "sAx_eq_b_Chol"
                      "() failed!\n");
      exit(1);
    }
  }
  a = buf;
  memcpy(a, A, a_sz * sizeof(float));
  memcpy(x, B, m * sizeof(float));
  spotrf_("L", (int *)&m, a, (int *)&m, (int *)&info);
  if (info != 0) {
    if (info < 0) {
      fprintf(stderr,
              "LAPACK error: illegal value for argument %d of "
              "spotf2_"
              "/"
              "spotrf_"
              " in "
              "sAx_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 "
              "spotf2_"
              "/"
              "spotrf_"
              " in "
              "sAx_eq_b_Chol"
              "()\n",
              info);
      return 0;
    }
  }
  spotrs_("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 "
            "spotrs_"
            " in "
            "sAx_eq_b_Chol"
            "()\n",
            -info);
    exit(1);
  }
  return 1;
}


x86 assembly (clang, -O0):
<sAx_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 <sAx_eq_b_Chol+0x64>
cmpq   $0x0,0x2ebf(%rip)
je     11b3 <sAx_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 <sAx_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 <sAx_eq_b_Chol+0xf3>
cmpq   $0x0,0x2e65(%rip)
je     120d <sAx_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    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,0x2e31(%rip)
cmpq   $0x0,0x2e29(%rip)
jne    125e <sAx_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 <sAx_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    $0x2,%rax
mov    %eax,%edx
call   1060 <memcpy@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
call   1060 <memcpy@plt>
mov    -0x30(%rbp),%rdx
lea    0xd87(%rip),%rdi
lea    -0x24(%rbp),%rcx
lea    -0x3c(%rbp),%r8
mov    %rcx,%rsi
call   1070 <spotrf_@plt>
cmpl   $0x0,-0x3c(%rbp)
je     1317 <sAx_eq_b_Chol+0x1a7>
cmpl   $0x0,-0x3c(%rbp)
jge    12f1 <sAx_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 <sAx_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   1040 <spotrs_@plt>
cmpl   $0x0,-0x3c(%rbp)
jge    1376 <sAx_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):
<sAx_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 <sAx_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 <sAx_eq_b_Chol+0xbb>
test   %r13,%r13
je     11bb <sAx_eq_b_Chol+0x4b>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %ebp,0x2ea7(%rip)
shl    $0x2,%ebp
mov    %ebp,%edi
call   1080 <malloc@plt>
mov    %rax,%r13
mov    %rax,0x2e8b(%rip)
test   %rax,%rax
jne    122e <sAx_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 <sAx_eq_b_Chol+0x9c>
call   1030 <free@plt>
movq   $0x0,0x2e49(%rip)
movl   $0x0,0x2e47(%rip)
mov    $0x1,%ebx
jmp    12c2 <sAx_eq_b_Chol+0x152>
shl    $0x2,%ebp
mov    %r13,%rdi
mov    %r12,%rsi
mov    %ebp,%edx
call   1060 <memcpy@plt>
shl    $0x2,%ebx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1060 <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   1070 <spotrf_@plt>
mov    0xc(%rsp),%edx
test   %edx,%edx
je     1292 <sAx_eq_b_Chol+0x122>
mov    0x2d64(%rip),%rax
mov    (%rax),%edi
js     12d3 <sAx_eq_b_Chol+0x163>
lea    0xdfc(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    12c2 <sAx_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   1040 <spotrs_@plt>
add    $0x10,%rsp
mov    0xc(%rsp),%edx
mov    $0x1,%ebx
test   %edx,%edx
js     12de <sAx_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 <sAx_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):
@sAx_eq_b_Chol.buf = internal global float* null
@sAx_eq_b_Chol.buf_sz = internal global i32 0
@stderr = global i32 0
@.str = [46 x i8] c"memory allocation in sAx_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 spotf2_/spotrf_ in sAx_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 spotf2_/spotrf_ in sAx_eq_b_Chol()\0A\00"
@.str.4 = [75 x i8] c"LAPACK error: illegal value for argument %d of spotrs_ in sAx_eq_b_Chol()\0A\00"
define i32 @sAx_eq_b_Chol(float* %0, float* %1, float* %2, i32 %3) {
%5 = alloca i32
%6 = alloca float*
%7 = alloca float*
%8 = alloca float*
%9 = alloca i32
%10 = alloca float*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store float* %0, float** %6
store float* %1, float** %7
store float* %2, float** %8
store i32 %3, i32* %9
store i32 1, i32* %14
%15 = load float*, float** %6
%16 = icmp ne float* %15, null
br i1 %16, label %24, label %17
17: ; preds = %4
%18 = load float*, float** @sAx_eq_b_Chol.buf
%19 = icmp ne float* %18, null
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load float*, float** @sAx_eq_b_Chol.buf
%22 = call i32 @free(float* %21)
br label %23
23: ; preds = %20, %17
store float* null, float** @sAx_eq_b_Chol.buf
store i32 0, i32* @sAx_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* @sAx_eq_b_Chol.buf_sz
%31 = icmp sgt i32 %29, %30
br i1 %31, label %32, label %53
32: ; preds = %24
%33 = load float*, float** @sAx_eq_b_Chol.buf
%34 = icmp ne float* %33, null
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load float*, float** @sAx_eq_b_Chol.buf
%37 = call i32 @free(float* %36)
br label %38
38: ; preds = %35, %32
%39 = load i32, i32* %12
store i32 %39, i32* @sAx_eq_b_Chol.buf_sz
%40 = load i32, i32* @sAx_eq_b_Chol.buf_sz
%41 = sext i32 %40 to i64
%42 = mul i64 %41, 4
%43 = trunc i64 %42 to i32
%44 = call i64 @malloc(i32 %43)
%45 = inttoptr i64 %44 to float*
store float* %45, float** @sAx_eq_b_Chol.buf
%46 = load float*, float** @sAx_eq_b_Chol.buf
%47 = icmp ne float* %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 float*, float** @sAx_eq_b_Chol.buf
store float* %54, float** %10
%55 = load float*, float** %10
%56 = load float*, float** %6
%57 = load i32, i32* %11
%58 = sext i32 %57 to i64
%59 = mul i64 %58, 4
%60 = trunc i64 %59 to i32
%61 = call i32 @memcpy(float* %55, float* %56, i32 %60)
%62 = load float*, float** %8
%63 = load float*, float** %7
%64 = load i32, i32* %9
%65 = sext i32 %64 to i64
%66 = mul i64 %65, 4
%67 = trunc i64 %66 to i32
%68 = call i32 @memcpy(float* %62, float* %63, i32 %67)
%69 = load float*, float** %10
%70 = call i32 @spotrf_(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32* %9, float* %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 float*, float** %10
%88 = load float*, float** %8
%89 = call i32 @spotrs_(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32* %9, i32* %14, float* %87, i32* %9, float* %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):
@sAx_eq_b_Chol.buf = internal unnamed_addr global float* null
@sAx_eq_b_Chol.buf_sz = internal unnamed_addr global i32 0
@stderr = global i32 0
@.str = [46 x i8] c"memory allocation in sAx_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 spotf2_/spotrf_ in sAx_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 spotf2_/spotrf_ in sAx_eq_b_Chol()\0A\00"
@.str.4 = [75 x i8] c"LAPACK error: illegal value for argument %d of spotrs_ in sAx_eq_b_Chol()\0A\00"
define i32 @sAx_eq_b_Chol(float* %0, float* %1, float* %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 float* %0, null
br i1 %10, label %11, label %17
11: ; preds = %4
%12 = load float*, float** @sAx_eq_b_Chol.buf
%13 = icmp eq float* %12, null
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = tail call i32 @free(float* %12)
br label %16
16: ; preds = %14, %11
store float* null, float** @sAx_eq_b_Chol.buf
store i32 0, i32* @sAx_eq_b_Chol.buf_sz
br label %64
17: ; preds = %4
%18 = mul nsw i32 %3, %3
%19 = load i32, i32* @sAx_eq_b_Chol.buf_sz
%20 = icmp sgt i32 %18, %19
%21 = load float*, float** @sAx_eq_b_Chol.buf
br i1 %20, label %24, label %22
22: ; preds = %17
%23 = shl i32 %18, 2
br label %37
24: ; preds = %17
%25 = icmp eq float* %21, null
br i1 %25, label %28, label %26
26: ; preds = %24
%27 = tail call i32 @free(float* %21)
br label %28
28: ; preds = %26, %24
store i32 %18, i32* @sAx_eq_b_Chol.buf_sz
%29 = shl i32 %18, 2
%30 = tail call i64 @malloc(i32 %29)
%31 = inttoptr i64 %30 to float*
store float* %31, float** @sAx_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 float* [ %21, %22 ], [ %31, %28 ]
%40 = tail call i32 @memcpy(float* %39, float* %0, i32 %38)
%41 = shl i32 %3, 2
%42 = tail call i32 @memcpy(float* %2, float* %1, i32 %41)
%43 = call i32 @spotrf_(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32* %5, float* %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 @spotrs_(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32* %5, i32* %7, float* %39, i32* %5, float* %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
}