#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*/ assert(int);
int /*<<< orphan*/ doubles_mat33_chol(double const *, int, int, double *, int,
                                      int);
int /*<<< orphan*/ doubles_mat33_lower_tri_inv(double *, int, int, double *,
                                               int, int);
void doubles_mat33_sym_solve(const double *A, int Arows, int Acols,
                             const double *B, int Brows, int Bcols, double *R,
                             int Rrows, int Rcols) {
  assert(Arows == Acols);
  assert(Acols == 3);
  assert(Brows == 3);
  assert(Bcols == 1);
  assert(Rrows == 3);
  assert(Rcols == 1);
  double L[9];
  doubles_mat33_chol(A, 3, 3, L, 3, 3);
  double M[9];
  doubles_mat33_lower_tri_inv(L, 3, 3, M, 3, 3);
  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] = (double)(M[0] * tmp[0] + M[3] * tmp[1] + M[6] * tmp[2]);
  R[1] = (double)(M[4] * tmp[1] + M[7] * tmp[2]);
  R[2] = (double)(M[8] * tmp[2]);
}


x86 assembly (clang, -O0):
<doubles_mat33_sym_solve>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
cmpl   $0x3,-0x10(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
cmpl   $0x3,-0x1c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
cmpl   $0x1,-0x20(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
cmpl   $0x3,0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
cmpl   $0x1,0x20(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    -0x70(%rbp),%rcx
mov    $0x3,%r9d
mov    %r9d,%esi
mov    %r9d,%edx
mov    %r9d,%r8d
call   1040 <doubles_mat33_chol@plt>
lea    -0x70(%rbp),%rdi
lea    -0xc0(%rbp),%rcx
mov    $0x3,%r9d
mov    %r9d,%esi
mov    %r9d,%edx
mov    %r9d,%r8d
call   1030 <doubles_mat33_lower_tri_inv@plt>
movsd  -0xc0(%rbp),%xmm0
ff
mov    -0x18(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0xe0(%rbp)
ff
movsd  -0xa8(%rbp),%xmm0
ff
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
movsd  -0xa0(%rbp),%xmm1
ff
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xd8(%rbp)
ff
movsd  -0x90(%rbp),%xmm1
ff
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
movsd  -0x88(%rbp),%xmm0
ff
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movsd  -0xc0(%rbp),%xmm1
ff
movsd  -0xe0(%rbp),%xmm2
ff
movsd  -0xa8(%rbp),%xmm0
ff
mulsd  -0xd8(%rbp),%xmm0
ff
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x90(%rbp),%xmm0
ff
movsd  -0xd0(%rbp),%xmm2
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0xa0(%rbp),%xmm0
ff
movsd  -0xd8(%rbp),%xmm2
ff
movsd  -0x88(%rbp),%xmm1
ff
mulsd  -0xd0(%rbp),%xmm1
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x80(%rbp),%xmm0
mulsd  -0xd0(%rbp),%xmm0
ff
mov    0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doubles_mat33_sym_solve>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %r9d,%r12d
mov    %r8d,%ebx
mov    %rcx,%r15
mov    %edx,%ebp
mov    %rdi,%r14
mov    0xd8(%rsp),%r13d
xor    %edi,%edi
cmp    %edx,%esi
sete   %dil
call   1050 <assert@plt>
xor    %edi,%edi
cmp    $0x3,%ebp
sete   %dil
call   1050 <assert@plt>
xor    %edi,%edi
cmp    $0x3,%ebx
sete   %dil
call   1050 <assert@plt>
xor    %edi,%edi
cmp    $0x1,%r12d
sete   %dil
call   1050 <assert@plt>
xor    %edi,%edi
cmp    $0x3,%r13d
sete   %dil
call   1050 <assert@plt>
xor    %edi,%edi
cmpl   $0x1,0xe0(%rsp)
01
sete   %dil
call   1050 <assert@plt>
lea    0x50(%rsp),%rbx
mov    %r14,%rdi
mov    $0x3,%esi
mov    $0x3,%edx
mov    %rbx,%rcx
mov    $0x3,%r8d
mov    $0x3,%r9d
call   1040 <doubles_mat33_chol@plt>
mov    %rsp,%rcx
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x3,%edx
mov    $0x3,%r8d
mov    $0x3,%r9d
call   1030 <doubles_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
mov    0xd0(%rsp),%rax
movupd %xmm4,(%rax)
mulsd  %xmm5,%xmm2
movsd  %xmm2,0x10(%rax)
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @doubles_mat33_sym_solve(double* %0, i32 %1, i32 %2, double* %3, i32 %4, i32 %5, double* %6, i32 %7, i32 %8) {
%10 = alloca double*
%11 = alloca i32
%12 = alloca i32
%13 = alloca double*
%14 = alloca i32
%15 = alloca i32
%16 = alloca double*
%17 = alloca i32
%18 = alloca i32
%19 = alloca [9 x double]
%20 = alloca [9 x double]
%21 = alloca [3 x double]
store double* %0, double** %10
store i32 %1, i32* %11
store i32 %2, i32* %12
store double* %3, double** %13
store i32 %4, i32* %14
store i32 %5, i32* %15
store double* %6, double** %16
store i32 %7, i32* %17
store i32 %8, i32* %18
%22 = load i32, i32* %11
%23 = load i32, i32* %12
%24 = icmp eq i32 %22, %23
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = load i32, i32* %12
%28 = icmp eq i32 %27, 3
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = load i32, i32* %14
%32 = icmp eq i32 %31, 3
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
%35 = load i32, i32* %15
%36 = icmp eq i32 %35, 1
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = load i32, i32* %17
%40 = icmp eq i32 %39, 3
%41 = zext i1 %40 to i32
%42 = call i32 @assert(i32 %41)
%43 = load i32, i32* %18
%44 = icmp eq i32 %43, 1
%45 = zext i1 %44 to i32
%46 = call i32 @assert(i32 %45)
%47 = load double*, double** %10
%48 = getelementptr inbounds [9 x double], [9 x double]* %19, i64 0, i64 0
%49 = call i32 @doubles_mat33_chol(double* %47, i32 3, i32 3, double* %48, i32 3, i32 3)
%50 = getelementptr inbounds [9 x double], [9 x double]* %19, i64 0, i64 0
%51 = getelementptr inbounds [9 x double], [9 x double]* %20, i64 0, i64 0
%52 = call i32 @doubles_mat33_lower_tri_inv(double* %50, i32 3, i32 3, double* %51, i32 3, i32 3)
%53 = getelementptr inbounds [9 x double], [9 x double]* %20, i64 0, i64 0
%54 = load double, double* %53
%55 = load double*, double** %13
%56 = getelementptr inbounds double, double* %55, i64 0
%57 = load double, double* %56
%58 = fmul double %54, %57
%59 = getelementptr inbounds [3 x double], [3 x double]* %21, i64 0, i64 0
store double %58, double* %59
%60 = getelementptr inbounds [9 x double], [9 x double]* %20, i64 0, i64 3
%61 = load double, double* %60
%62 = load double*, double** %13
%63 = getelementptr inbounds double, double* %62, i64 0
%64 = load double, double* %63
%65 = getelementptr inbounds [9 x double], [9 x double]* %20, i64 0, i64 4
%66 = load double, double* %65
%67 = load double*, double** %13
%68 = getelementptr inbounds double, double* %67, i64 1
%69 = load double, double* %68
%70 = fmul double %66, %69
%71 = call double @llvm.fmuladd.f64(double %61, double %64, double %70)
%72 = getelementptr inbounds [3 x double], [3 x double]* %21, i64 0, i64 1
store double %71, double* %72
%73 = getelementptr inbounds [9 x double], [9 x double]* %20, i64 0, i64 6
%74 = load double, double* %73
%75 = load double*, double** %13
%76 = getelementptr inbounds double, double* %75, i64 0
%77 = load double, double* %76
%78 = getelementptr inbounds [9 x double], [9 x double]* %20, i64 0, i64 7
%79 = load double, double* %78
%80 = load double*, double** %13
%81 = getelementptr inbounds double, double* %80, i64 1
%82 = load double, double* %81
%83 = fmul double %79, %82
%84 = call double @llvm.fmuladd.f64(double %74, double %77, double %83)
%85 = getelementptr inbounds [9 x double], [9 x double]* %20, i64 0, i64 8
%86 = load double, double* %85
%87 = load double*, double** %13
%88 = getelementptr inbounds double, double* %87, i64 2
%89 = load double, double* %88
%90 = call double @llvm.fmuladd.f64(double %86, double %89, double %84)
%91 = getelementptr inbounds [3 x double], [3 x double]* %21, i64 0, i64 2
store double %90, double* %91
%92 = getelementptr inbounds [9 x double], [9 x double]* %20, i64 0, i64 0
%93 = load double, double* %92
%94 = getelementptr inbounds [3 x double], [3 x double]* %21, i64 0, i64 0
%95 = load double, double* %94
%96 = getelementptr inbounds [9 x double], [9 x double]* %20, i64 0, i64 3
%97 = load double, double* %96
%98 = getelementptr inbounds [3 x double], [3 x double]* %21, i64 0, i64 1
%99 = load double, double* %98
%100 = fmul double %97, %99
%101 = call double @llvm.fmuladd.f64(double %93, double %95, double %100)
%102 = getelementptr inbounds [9 x double], [9 x double]* %20, i64 0, i64 6
%103 = load double, double* %102
%104 = getelementptr inbounds [3 x double], [3 x double]* %21, i64 0, i64 2
%105 = load double, double* %104
%106 = call double @llvm.fmuladd.f64(double %103, double %105, double %101)
%107 = load double*, double** %16
%108 = getelementptr inbounds double, double* %107, i64 0
store double %106, double* %108
%109 = getelementptr inbounds [9 x double], [9 x double]* %20, i64 0, i64 4
%110 = load double, double* %109
%111 = getelementptr inbounds [3 x double], [3 x double]* %21, i64 0, i64 1
%112 = load double, double* %111
%113 = getelementptr inbounds [9 x double], [9 x double]* %20, i64 0, i64 7
%114 = load double, double* %113
%115 = getelementptr inbounds [3 x double], [3 x double]* %21, i64 0, i64 2
%116 = load double, double* %115
%117 = fmul double %114, %116
%118 = call double @llvm.fmuladd.f64(double %110, double %112, double %117)
%119 = load double*, double** %16
%120 = getelementptr inbounds double, double* %119, i64 1
store double %118, double* %120
%121 = getelementptr inbounds [9 x double], [9 x double]* %20, i64 0, i64 8
%122 = load double, double* %121
%123 = getelementptr inbounds [3 x double], [3 x double]* %21, i64 0, i64 2
%124 = load double, double* %123
%125 = fmul double %122, %124
%126 = load double*, double** %16
%127 = getelementptr inbounds double, double* %126, i64 2
store double %125, double* %127
ret void
}

LLVM IR (-O2):
define void @doubles_mat33_sym_solve(double* %0, i32 %1, i32 %2, double* nocapture %3, i32 %4, i32 %5, double* nocapture writeonly %6, i32 %7, i32 %8) {
%10 = alloca [9 x double]
%11 = alloca [9 x double]
%12 = icmp eq i32 %1, %2
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
%15 = icmp eq i32 %2, 3
%16 = zext i1 %15 to i32
%17 = tail call i32 @assert(i32 %16)
%18 = icmp eq i32 %4, 3
%19 = zext i1 %18 to i32
%20 = tail call i32 @assert(i32 %19)
%21 = icmp eq i32 %5, 1
%22 = zext i1 %21 to i32
%23 = tail call i32 @assert(i32 %22)
%24 = icmp eq i32 %7, 3
%25 = zext i1 %24 to i32
%26 = tail call i32 @assert(i32 %25)
%27 = icmp eq i32 %8, 1
%28 = zext i1 %27 to i32
%29 = tail call i32 @assert(i32 %28)
%30 = bitcast [9 x double]* %10 to i8*
%31 = getelementptr inbounds [9 x double], [9 x double]* %10, i64 0, i64 0
%32 = call i32 @doubles_mat33_chol(double* %0, i32 3, i32 3, double* %31, i32 3, i32 3)
%33 = bitcast [9 x double]* %11 to i8*
%34 = getelementptr inbounds [9 x double], [9 x double]* %11, i64 0, i64 0
%35 = call i32 @doubles_mat33_lower_tri_inv(double* %31, i32 3, i32 3, double* %34, i32 3, i32 3)
%36 = load double, double* %34
%37 = load double, double* %3
%38 = fmul double %36, %37
%39 = getelementptr inbounds [9 x double], [9 x double]* %11, i64 0, i64 3
%40 = load double, double* %39
%41 = getelementptr inbounds [9 x double], [9 x double]* %11, i64 0, i64 4
%42 = load double, double* %41
%43 = getelementptr inbounds double, double* %3, i64 1
%44 = load double, double* %43
%45 = fmul double %42, %44
%46 = getelementptr inbounds [9 x double], [9 x double]* %11, i64 0, i64 6
%47 = load double, double* %46
%48 = getelementptr inbounds [9 x double], [9 x double]* %11, i64 0, i64 7
%49 = load double, double* %48
%50 = fmul double %44, %49
%51 = call double @llvm.fmuladd.f64(double %47, double %37, double %50)
%52 = getelementptr inbounds [9 x double], [9 x double]* %11, i64 0, i64 8
%53 = load double, double* %52
%54 = getelementptr inbounds double, double* %3, i64 2
%55 = load double, double* %54
%56 = insertelement <2 x double> poison, double %53, i64 0
%57 = insertelement <2 x double> %56, double %40, i64 1
%58 = insertelement <2 x double> poison, double %55, i64 0
%59 = insertelement <2 x double> %58, double %37, i64 1
%60 = insertelement <2 x double> poison, double %51, i64 0
%61 = insertelement <2 x double> %60, double %45, i64 1
%62 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %57, <2 x double> %59, <2 x double> %61)
%63 = extractelement <2 x double> %62, i64 1
%64 = fmul double %40, %63
%65 = call double @llvm.fmuladd.f64(double %36, double %38, double %64)
%66 = extractelement <2 x double> %62, i64 0
%67 = fmul double %49, %66
%68 = insertelement <2 x double> poison, double %47, i64 0
%69 = insertelement <2 x double> %68, double %42, i64 1
%70 = insertelement <2 x double> poison, double %65, i64 0
%71 = insertelement <2 x double> %70, double %67, i64 1
%72 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %69, <2 x double> %62, <2 x double> %71)
%73 = bitcast double* %6 to <2 x double>*
store <2 x double> %72, <2 x double>* %73
%74 = fmul double %53, %66
%75 = getelementptr inbounds double, double* %6, i64 2
store double %74, double* %75
ret void
}