#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*/ mat33_chol(double const *, double *);
int /*<<< orphan*/ mat33_lower_tri_inv(double *, double *);
void mat33_sym_solve(const double *A, const double *B, double *R) {
  double L[9];
  mat33_chol(A, L);
  double M[9];
  mat33_lower_tri_inv(L, M);
  double tmp[3];
  tmp[0] = M[0] * B[0];
  tmp[1] = M[3] * B[0] + M[4] * B[1];
  tmp[2] = M[6] * B[0] + M[7] * B[1] + M[8] * B[2];
  R[0] = M[0] * tmp[0] + M[3] * tmp[1] + M[6] * tmp[2];
  R[1] = M[4] * tmp[1] + M[7] * tmp[2];
  R[2] = M[8] * tmp[2];
}


x86 assembly (clang, -O0):
<mat33_sym_solve>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1030 <mat33_chol@plt>
lea    -0x60(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
call   1040 <mat33_lower_tri_inv@plt>
movsd  -0xb0(%rbp),%xmm0
ff
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
movsd  -0x90(%rbp),%xmm1
ff
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0x80(%rbp),%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
movsd  -0x78(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0xb0(%rbp),%xmm1
ff
movsd  -0xd0(%rbp),%xmm2
ff
movsd  -0x98(%rbp),%xmm0
ff
mulsd  -0xc8(%rbp),%xmm0
ff
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
movsd  -0xc0(%rbp),%xmm2
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x90(%rbp),%xmm0
ff
movsd  -0xc8(%rbp),%xmm2
ff
movsd  -0x78(%rbp),%xmm1
mulsd  -0xc0(%rbp),%xmm1
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x70(%rbp),%xmm0
mulsd  -0xc0(%rbp),%xmm0
ff
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mat33_sym_solve>:
push   %r15
push   %r14
push   %rbx
sub    $0xa0,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
lea    0x50(%rsp),%rbx
mov    %rbx,%rsi
call   1030 <mat33_chol@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <mat33_lower_tri_inv@plt>
movsd  (%rsp),%xmm8
movsd  0x18(%rsp),%xmm9
movsd  (%r15),%xmm3
movsd  0x8(%r15),%xmm5
movapd %xmm8,%xmm1
mulsd  %xmm3,%xmm1
movsd  0x20(%rsp),%xmm6
movsd  0x30(%rsp),%xmm4
movapd %xmm4,%xmm7
unpcklpd %xmm6,%xmm4
mulsd  %xmm5,%xmm6
movsd  0x38(%rsp),%xmm0
mulsd  %xmm0,%xmm5
mulsd  %xmm3,%xmm7
addsd  %xmm5,%xmm7
unpcklpd %xmm6,%xmm7
movsd  0x40(%rsp),%xmm5
movapd %xmm5,%xmm6
unpcklpd %xmm9,%xmm6
movsd  0x10(%r15),%xmm2
unpcklpd %xmm3,%xmm2
mulpd  %xmm6,%xmm2
addpd  %xmm7,%xmm2
movapd %xmm2,%xmm3
unpckhpd %xmm2,%xmm3
mulsd  %xmm9,%xmm3
mulsd  %xmm8,%xmm1
addsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
unpcklpd %xmm0,%xmm1
mulpd  %xmm2,%xmm4
addpd  %xmm1,%xmm4
movupd %xmm4,(%r14)
mulsd  %xmm5,%xmm2
movsd  %xmm2,0x10(%r14)
add    $0xa0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @mat33_sym_solve(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca [9 x double]
%8 = alloca [9 x double]
%9 = alloca [3 x double]
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%10 = load double*, double** %4
%11 = getelementptr inbounds [9 x double], [9 x double]* %7, i64 0, i64 0
%12 = call i32 @mat33_chol(double* %10, double* %11)
%13 = getelementptr inbounds [9 x double], [9 x double]* %7, i64 0, i64 0
%14 = getelementptr inbounds [9 x double], [9 x double]* %8, i64 0, i64 0
%15 = call i32 @mat33_lower_tri_inv(double* %13, double* %14)
%16 = getelementptr inbounds [9 x double], [9 x double]* %8, i64 0, i64 0
%17 = load double, double* %16
%18 = load double*, double** %5
%19 = getelementptr inbounds double, double* %18, i64 0
%20 = load double, double* %19
%21 = fmul double %17, %20
%22 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
store double %21, double* %22
%23 = getelementptr inbounds [9 x double], [9 x double]* %8, i64 0, i64 3
%24 = load double, double* %23
%25 = load double*, double** %5
%26 = getelementptr inbounds double, double* %25, i64 0
%27 = load double, double* %26
%28 = getelementptr inbounds [9 x double], [9 x double]* %8, i64 0, i64 4
%29 = load double, double* %28
%30 = load double*, double** %5
%31 = getelementptr inbounds double, double* %30, i64 1
%32 = load double, double* %31
%33 = fmul double %29, %32
%34 = call double @llvm.fmuladd.f64(double %24, double %27, double %33)
%35 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 1
store double %34, double* %35
%36 = getelementptr inbounds [9 x double], [9 x double]* %8, i64 0, i64 6
%37 = load double, double* %36
%38 = load double*, double** %5
%39 = getelementptr inbounds double, double* %38, i64 0
%40 = load double, double* %39
%41 = getelementptr inbounds [9 x double], [9 x double]* %8, i64 0, i64 7
%42 = load double, double* %41
%43 = load double*, double** %5
%44 = getelementptr inbounds double, double* %43, i64 1
%45 = load double, double* %44
%46 = fmul double %42, %45
%47 = call double @llvm.fmuladd.f64(double %37, double %40, double %46)
%48 = getelementptr inbounds [9 x double], [9 x double]* %8, i64 0, i64 8
%49 = load double, double* %48
%50 = load double*, double** %5
%51 = getelementptr inbounds double, double* %50, i64 2
%52 = load double, double* %51
%53 = call double @llvm.fmuladd.f64(double %49, double %52, double %47)
%54 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 2
store double %53, double* %54
%55 = getelementptr inbounds [9 x double], [9 x double]* %8, i64 0, i64 0
%56 = load double, double* %55
%57 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%58 = load double, double* %57
%59 = getelementptr inbounds [9 x double], [9 x double]* %8, i64 0, i64 3
%60 = load double, double* %59
%61 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 1
%62 = load double, double* %61
%63 = fmul double %60, %62
%64 = call double @llvm.fmuladd.f64(double %56, double %58, double %63)
%65 = getelementptr inbounds [9 x double], [9 x double]* %8, i64 0, i64 6
%66 = load double, double* %65
%67 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 2
%68 = load double, double* %67
%69 = call double @llvm.fmuladd.f64(double %66, double %68, double %64)
%70 = load double*, double** %6
%71 = getelementptr inbounds double, double* %70, i64 0
store double %69, double* %71
%72 = getelementptr inbounds [9 x double], [9 x double]* %8, i64 0, i64 4
%73 = load double, double* %72
%74 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 1
%75 = load double, double* %74
%76 = getelementptr inbounds [9 x double], [9 x double]* %8, i64 0, i64 7
%77 = load double, double* %76
%78 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 2
%79 = load double, double* %78
%80 = fmul double %77, %79
%81 = call double @llvm.fmuladd.f64(double %73, double %75, double %80)
%82 = load double*, double** %6
%83 = getelementptr inbounds double, double* %82, i64 1
store double %81, double* %83
%84 = getelementptr inbounds [9 x double], [9 x double]* %8, i64 0, i64 8
%85 = load double, double* %84
%86 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 2
%87 = load double, double* %86
%88 = fmul double %85, %87
%89 = load double*, double** %6
%90 = getelementptr inbounds double, double* %89, i64 2
store double %88, double* %90
ret void
}

LLVM IR (-O2):
define void @mat33_sym_solve(double* %0, double* nocapture %1, double* nocapture writeonly %2) {
%4 = alloca [9 x double]
%5 = alloca [9 x double]
%6 = bitcast [9 x double]* %4 to i8*
%7 = getelementptr inbounds [9 x double], [9 x double]* %4, i64 0, i64 0
%8 = call i32 @mat33_chol(double* %0, double* %7)
%9 = bitcast [9 x double]* %5 to i8*
%10 = getelementptr inbounds [9 x double], [9 x double]* %5, i64 0, i64 0
%11 = call i32 @mat33_lower_tri_inv(double* %7, double* %10)
%12 = load double, double* %10
%13 = load double, double* %1
%14 = fmul double %12, %13
%15 = getelementptr inbounds [9 x double], [9 x double]* %5, i64 0, i64 3
%16 = load double, double* %15
%17 = getelementptr inbounds [9 x double], [9 x double]* %5, i64 0, i64 4
%18 = load double, double* %17
%19 = getelementptr inbounds double, double* %1, i64 1
%20 = load double, double* %19
%21 = fmul double %18, %20
%22 = getelementptr inbounds [9 x double], [9 x double]* %5, i64 0, i64 6
%23 = load double, double* %22
%24 = getelementptr inbounds [9 x double], [9 x double]* %5, i64 0, i64 7
%25 = load double, double* %24
%26 = fmul double %20, %25
%27 = call double @llvm.fmuladd.f64(double %23, double %13, double %26)
%28 = getelementptr inbounds [9 x double], [9 x double]* %5, i64 0, i64 8
%29 = load double, double* %28
%30 = getelementptr inbounds double, double* %1, i64 2
%31 = load double, double* %30
%32 = insertelement <2 x double> poison, double %29, i64 0
%33 = insertelement <2 x double> %32, double %16, i64 1
%34 = insertelement <2 x double> poison, double %31, i64 0
%35 = insertelement <2 x double> %34, double %13, i64 1
%36 = insertelement <2 x double> poison, double %27, i64 0
%37 = insertelement <2 x double> %36, double %21, i64 1
%38 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %33, <2 x double> %35, <2 x double> %37)
%39 = extractelement <2 x double> %38, i64 1
%40 = fmul double %16, %39
%41 = call double @llvm.fmuladd.f64(double %12, double %14, double %40)
%42 = extractelement <2 x double> %38, i64 0
%43 = fmul double %25, %42
%44 = insertelement <2 x double> poison, double %23, i64 0
%45 = insertelement <2 x double> %44, double %18, i64 1
%46 = insertelement <2 x double> poison, double %41, i64 0
%47 = insertelement <2 x double> %46, double %43, i64 1
%48 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %45, <2 x double> %38, <2 x double> %47)
%49 = bitcast double* %2 to <2 x double>*
store <2 x double> %48, <2 x double>* %49
%50 = fmul double %29, %42
%51 = getelementptr inbounds double, double* %2, i64 2
store double %50, double* %51
ret void
}