// File: /workspace/github_c_makefile_star2_O0/mohuangrui[P]ArtraCFD/immersed_boundary.c
// Function: ReconstructFlow
static void ReconstructFlow(const int tn, const int n[restrict], const Real p[restrict],
        const int h, const int type, const int did, const Polyhedron *poly, const Partition *const part,
        const Node *const node, const Model *model, const Real pO[restrict], const Real N[restrict],
        Real UoO[restrict], Real Uo[restrict])
{
    const Real zero = 0.0;
    const Real one = 1.0;
    /* pre-estimate step */
    Real weightSum = InverseDistanceWeighting(tn, n, p, h, type, did, part, node, model, Uo);
    const Real weight = one / weightSum;
    /* physical boundary condition enforcement step */
    RealVec Vs = {zero}; /* general motion of boundary point */
    /* Vs = Vcentroid + W x r */
    const RealVec r = {pO[X] - poly->O[X], pO[Y] - poly->O[Y], pO[Z] - poly->O[Z]};
    Cross(poly->W[TO], r, Vs); /* relative motion in translating coordinate system */
    Vs[X] = poly->V[TO][X] + Vs[X];
    Vs[Y] = poly->V[TO][Y] + Vs[Y];
    Vs[Z] = poly->V[TO][Z] + Vs[Z];
    if (zero < poly->cf) { /* noslip wall */
        UoO[1] = Vs[X];
        UoO[2] = Vs[Y];
        UoO[3] = Vs[Z];
    } else { /* slip wall */
        const RealVec V = {Uo[1] * weight, Uo[2] * weight, Uo[3] * weight};
        RealVec Ta = {zero}; /* tangential vector */
        RealVec Tb = {zero}; /* tangential vector */
        Real RHS[DIMS] = {zero}; /* right hand side vector */
        OrthogonalSpace(N, Ta, Tb);
        RHS[X] = Dot(Vs, N);
        RHS[Y] = Dot(V, Ta);
        RHS[Z] = Dot(V, Tb);
        UoO[1] = N[X] * RHS[X] + Ta[X] * RHS[Y] + Tb[X] * RHS[Z];
        UoO[2] = N[Y] * RHS[X] + Ta[Y] * RHS[Y] + Tb[Y] * RHS[Z];
        UoO[3] = N[Z] * RHS[X] + Ta[Z] * RHS[Y] + Tb[Z] * RHS[Z];
    }
    /*
     * dp/dn = rho_f * v_t^2 / R - rho_f * a_s
     * v_t = (v_o - v_s) - (v_o - vs) * n: relative tangential velocity
     * v_o velocity of boundary point; v_s: velocity of solid surface
     * R: radius of curvature;
     * a_s = at + ar x r + w x (w x r): acceleration of solid surface
     * currently, the effect of this condition is found very limited.
     * Therefore, boundary layer pressure condition dp/dn = 0 is used.
     */
    UoO[4] = Uo[4] * weight;
    if (zero > poly->T) { /* adiabatic, dT/dn = 0 */
        UoO[5] = Uo[5] * weight;
    } else { /* otherwise, use specified constant wall temperature, T = Tw */
        UoO[5] = poly->T;
    }
    /* correction step by adding the boundary point as a stencil */
    ApplyWeighting(UoO, part->tinyL, Dist2(p, pO), &weightSum, Uo);
    /* Normalize the weighted values */
    Normalize(DIMUo, weightSum, Uo);
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movl %edi, -0xc(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl %r8d, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
movsd 0xd71e(%rip), %xmm0     # 0x27710
movsd %xmm0, -0x40(%rbp)
movl -0xc(%rbp), %edi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %ecx
movl -0x28(%rbp), %r8d
movl -0x2c(%rbp), %r9d
movq 0x18(%rbp), %rbx
movq 0x20(%rbp), %r11
movq 0x28(%rbp), %r10
movq 0x48(%rbp), %rax
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x1a470
movsd %xmm0, -0x48(%rbp)
movsd 0xd6ce(%rip), %xmm0     # 0x27710
divsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x20d0
movq 0x30(%rbp), %rax
movsd (%rax), %xmm0
movq 0x10(%rbp), %rax
subsd 0x20(%rax), %xmm0
movsd %xmm0, -0x90(%rbp)
movq 0x30(%rbp), %rax
movsd 0x8(%rax), %xmm0
movq 0x10(%rbp), %rax
subsd 0x28(%rax), %xmm0
movsd %xmm0, -0x88(%rbp)
movq 0x30(%rbp), %rax
movsd 0x10(%rax), %xmm0
movq 0x10(%rbp), %rax
subsd 0x30(%rax), %xmm0
movsd %xmm0, -0x80(%rbp)
movq 0x10(%rbp), %rdi
addq $0xb0, %rdi
leaq -0x90(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x99b0
movq 0x10(%rbp), %rax
movsd 0x80(%rax), %xmm0
addsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movq 0x10(%rbp), %rax
movsd 0x88(%rax), %xmm0
addsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movq 0x10(%rbp), %rax
movsd 0x90(%rax), %xmm0
addsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movq 0x10(%rbp), %rax
movsd 0x1b8(%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1a147
movsd -0x70(%rbp), %xmm0
movq 0x40(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movsd -0x68(%rbp), %xmm0
movq 0x40(%rbp), %rax
movsd %xmm0, 0x10(%rax)
movsd -0x60(%rbp), %xmm0
movq 0x40(%rbp), %rax
movsd %xmm0, 0x18(%rax)
jmp 0x1a301
movq 0x48(%rbp), %rax
movsd 0x8(%rax), %xmm0
mulsd -0x50(%rbp), %xmm0
movsd %xmm0, -0xb0(%rbp)
movq 0x48(%rbp), %rax
movsd 0x10(%rax), %xmm0
mulsd -0x50(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
movq 0x48(%rbp), %rax
movsd 0x18(%rax), %xmm0
mulsd -0x50(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
leaq -0xd0(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x20d0
leaq -0xf0(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x20d0
leaq -0x110(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x20d0
movq 0x38(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
leaq -0xf0(%rbp), %rdx
callq 0x9ab0
leaq -0x70(%rbp), %rdi
movq 0x38(%rbp), %rsi
callq 0x9880
movsd %xmm0, -0x110(%rbp)
leaq -0xb0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x9880
movsd %xmm0, -0x108(%rbp)
leaq -0xb0(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x9880
movsd %xmm0, -0x100(%rbp)
movq 0x38(%rbp), %rax
movsd (%rax), %xmm1
movsd -0x110(%rbp), %xmm2
movsd -0xd0(%rbp), %xmm0
mulsd -0x108(%rbp), %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd -0xf0(%rbp), %xmm0
movsd -0x100(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x40(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movq 0x38(%rbp), %rax
movsd 0x8(%rax), %xmm1
movsd -0x110(%rbp), %xmm2
movsd -0xc8(%rbp), %xmm0
mulsd -0x108(%rbp), %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd -0xe8(%rbp), %xmm0
movsd -0x100(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x40(%rbp), %rax
movsd %xmm0, 0x10(%rax)
movq 0x38(%rbp), %rax
movsd 0x10(%rax), %xmm1
movsd -0x110(%rbp), %xmm2
movsd -0xc0(%rbp), %xmm0
mulsd -0x108(%rbp), %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd -0xe0(%rbp), %xmm0
movsd -0x100(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x40(%rbp), %rax
movsd %xmm0, 0x18(%rax)
movq 0x48(%rbp), %rax
movsd 0x20(%rax), %xmm0
mulsd -0x50(%rbp), %xmm0
movq 0x40(%rbp), %rax
movsd %xmm0, 0x20(%rax)
movq 0x10(%rbp), %rax
xorps %xmm0, %xmm0
ucomisd 0x1b0(%rax), %xmm0
jbe 0x1a342
movq 0x48(%rbp), %rax
movsd 0x28(%rax), %xmm0
mulsd -0x50(%rbp), %xmm0
movq 0x40(%rbp), %rax
movsd %xmm0, 0x28(%rax)
jmp 0x1a357
movq 0x10(%rbp), %rax
movsd 0x1b0(%rax), %xmm0
movq 0x40(%rbp), %rax
movsd %xmm0, 0x28(%rax)
movq 0x40(%rbp), %rax
movq %rax, -0x120(%rbp)
movq 0x18(%rbp), %rax
movsd 0x60(%rax), %xmm0
movsd %xmm0, -0x118(%rbp)
movq -0x20(%rbp), %rdi
movq 0x30(%rbp), %rsi
callq 0x9910
movq -0x120(%rbp), %rdi
movaps %xmm0, %xmm1
movsd -0x118(%rbp), %xmm0
movq 0x48(%rbp), %rdx
leaq -0x48(%rbp), %rsi
callq 0x1aa30
movsd -0x48(%rbp), %xmm0
movq 0x48(%rbp), %rsi
movl $0x6, %edi
callq 0x9c60
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %rbp
retq
nopl (%rax)