// File: /workspace/github_c_makefile_star2_O3/mohuangrui[P]ArtraCFD/cfd_commons.c
// Function: SymmetricAverage
void SymmetricAverage(const int averager, const Real gamma,
        const Real UL[restrict], const Real UR[restrict], Real Uo[restrict])
{
    const Real rhoL = UL[0];
    const Real uL = UL[1] / UL[0];
    const Real vL = UL[2] / UL[0];
    const Real wL = UL[3] / UL[0];
    const Real hTL = (UL[4] / UL[0]) * gamma - 0.5 * (uL * uL + vL * vL + wL * wL) * (gamma - 1.0);
    const Real rhoR = UR[0];
    const Real uR = UR[1] / UR[0];
    const Real vR = UR[2] / UR[0];
    const Real wR = UR[3] / UR[0];
    const Real hTR = (UR[4] / UR[0]) * gamma - 0.5 * (uR * uR + vR * vR + wR * wR) * (gamma - 1.0);
    Real D = 0.0;
    switch (averager) {
        case 0: /* arithmetic mean */
            Uo[1] = 0.5 * (uL + uR); /* u average */
            Uo[2] = 0.5 * (vL + vR); /* v average */
            Uo[3] = 0.5 * (wL + wR); /* w average */
            Uo[4] = 0.5 * (hTL + hTR); /* hT average */
            break;
        case 1: /* Roe average */
            D = sqrt(rhoR / rhoL);
            Uo[1] = (uL + D * uR) / (1.0 + D); /* u average */
            Uo[2] = (vL + D * vR) / (1.0 + D); /* v average */
            Uo[3] = (wL + D * wR) / (1.0 + D); /* w average */
            Uo[4] = (hTL + D * hTR) / (1.0 + D); /* hT average */
            break;
        default:
            break;
    }
    Uo[5] = sqrt((gamma - 1.0) * (Uo[4] - 0.5 * (Uo[1] * Uo[1] + Uo[2] * Uo[2] + Uo[3] * Uo[3]))); /* the speed of sound */
    return;
}

// Assembly:
pushq %rbx
subq $0x70, %rsp
movq %rcx, %rbx
movsd (%rsi), %xmm2
movupd 0x8(%rsi), %xmm7
movapd %xmm2, %xmm1
unpcklpd %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0]
divpd %xmm1, %xmm7
movsd 0x18(%rsi), %xmm9
divsd %xmm2, %xmm9
movsd 0x20(%rsi), %xmm10
divsd %xmm2, %xmm10
movapd %xmm7, %xmm1
mulpd %xmm7, %xmm1
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
movapd %xmm7, %xmm3
mulsd %xmm7, %xmm3
addsd %xmm1, %xmm3
movapd %xmm9, %xmm1
mulsd %xmm9, %xmm1
addsd %xmm3, %xmm1
movsd 0x14da7(%rip), %xmm6    # 0x1c5b0
addsd %xmm0, %xmm6
movsd 0x14da3(%rip), %xmm3    # 0x1c5b8
mulsd %xmm3, %xmm1
mulsd %xmm6, %xmm1
mulsd %xmm0, %xmm10
addsd %xmm1, %xmm10
movsd (%rdx), %xmm1
movupd 0x8(%rdx), %xmm11
movapd %xmm1, %xmm4
unpcklpd %xmm1, %xmm4            # xmm4 = xmm4[0],xmm1[0]
divpd %xmm4, %xmm11
movsd 0x18(%rdx), %xmm8
divsd %xmm1, %xmm8
movsd 0x20(%rdx), %xmm12
divsd %xmm1, %xmm12
movapd %xmm11, %xmm4
mulpd %xmm11, %xmm4
unpckhpd %xmm4, %xmm4            # xmm4 = xmm4[1,1]
movapd %xmm11, %xmm5
mulsd %xmm11, %xmm5
addsd %xmm4, %xmm5
movapd %xmm8, %xmm4
mulsd %xmm8, %xmm4
addsd %xmm5, %xmm4
mulsd %xmm3, %xmm4
mulsd %xmm6, %xmm4
mulsd %xmm0, %xmm12
addsd %xmm4, %xmm12
testl %edi, %edi
je 0x78b3
cmpl $0x1, %edi
jne 0x78ec
divsd %xmm2, %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jb 0x78fc
xorps %xmm0, %xmm0
sqrtsd %xmm1, %xmm0
jmp 0x7963
unpcklpd %xmm10, %xmm9           # xmm9 = xmm9[0],xmm10[0]
unpcklpd %xmm12, %xmm8           # xmm8 = xmm8[0],xmm12[0]
addpd %xmm9, %xmm8
addpd %xmm11, %xmm7
movapd 0x14d41(%rip), %xmm0    # 0x1c610
mulpd %xmm0, %xmm8
mulpd %xmm0, %xmm7
movupd %xmm7, 0x8(%rbx)
movupd %xmm8, 0x18(%rbx)
movapd %xmm7, %xmm0
jmp 0x79a8
movupd 0x8(%rbx), %xmm0
movupd 0x18(%rbx), %xmm8
jmp 0x79a8
movapd %xmm1, %xmm0
movsd %xmm6, 0x8(%rsp)
movapd %xmm7, 0x60(%rsp)
movapd %xmm8, 0x50(%rsp)
movapd %xmm9, 0x40(%rsp)
movapd %xmm10, 0x30(%rsp)
movapd %xmm11, 0x20(%rsp)
movapd %xmm12, 0x10(%rsp)
callq 0x2210
movapd 0x10(%rsp), %xmm12
movapd 0x20(%rsp), %xmm11
movapd 0x30(%rsp), %xmm10
movapd 0x40(%rsp), %xmm9
movapd 0x50(%rsp), %xmm8
movapd 0x60(%rsp), %xmm7
movsd 0x8(%rsp), %xmm6
movsd 0x1169d(%rip), %xmm1    # 0x19008
addsd %xmm0, %xmm1
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
unpcklpd %xmm12, %xmm8           # xmm8 = xmm8[0],xmm12[0]
unpcklpd %xmm10, %xmm9           # xmm9 = xmm9[0],xmm10[0]
mulpd %xmm0, %xmm8
addpd %xmm9, %xmm8
mulpd %xmm11, %xmm0
addpd %xmm7, %xmm0
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
divpd %xmm1, %xmm8
divpd %xmm1, %xmm0
movupd %xmm0, 0x8(%rbx)
movupd %xmm8, 0x18(%rbx)
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movapd %xmm8, %xmm1
mulsd %xmm8, %xmm1
addsd %xmm0, %xmm1
unpckhpd %xmm8, %xmm8            # xmm8 = xmm8[1,1]
mulsd 0x14be1(%rip), %xmm1    # 0x1c5b8
addsd %xmm8, %xmm1
mulsd %xmm1, %xmm6
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm6
jb 0x79f3
xorps %xmm0, %xmm0
sqrtsd %xmm6, %xmm0
jmp 0x79fc
movapd %xmm6, %xmm0
callq 0x2210
movsd %xmm0, 0x28(%rbx)
addq $0x70, %rsp
popq %rbx
retq