// File: /workspace/github_c_makefile_star2_O0/mohuangrui[P]ArtraCFD/immersed_boundary.c
// Function: InverseDistanceWeighting
static Real InverseDistanceWeighting(const int tn, const int n[restrict], const Real p[restrict],
        const int h, const int type, const int did, const Partition *const part,
        const Node *const node, const Model *model, Real Uo[restrict])
{
    int idx = 0; /* linear array index math variable */
    const RealVec sMin = {part->domain[X][MIN], part->domain[Y][MIN], part->domain[Z][MIN]};
    const RealVec d = {part->d[X], part->d[Y], part->d[Z]};
    const IntVec ng = {part->ng[X], part->ng[Y], part->ng[Z]};
    Real Uoh[DIMUo] = {0.0}; /* primitive at neighbouring node */
    RealVec ph = {0.0}; /* neighbouring point */
    IntVec nh = {0}; /* neighbouring node */
    Real weightSum = 0.0;
    memset(Uo, 0, DIMUo * sizeof(*Uo));
    /*
     * Search nodes with required "type" in the domain specified by the center node
     * "n" and initial range "h" as interpolation stencils for the interpolated point "p".
     * To preserve symmetry, the search range in each direction should be symmetric, and
     * the search operator on each direction index should be symmetric. In addition,
     * any temporal priority should be strictly prevented in treating the solution nodes.
     */
    for (int r = h, tally = 0; 0 == tally; ++r) {
        for (int kh = -r; kh <= r; ++kh) {
            for (int jh = -r; jh <= r; ++jh) {
                for (int ih = -r; ih <= r; ++ih) {
                    nh[X] = n[X] + ih;
                    nh[Y] = n[Y] + jh;
                    nh[Z] = n[Z] + kh;
                    if (!InPartBox(nh[Z], nh[Y], nh[X], part->ns[PIN])) {
                        continue;
                    }
                    idx = IndexNode(nh[Z], nh[Y], nh[X], part->n[Y], part->n[X]);
                    /* be aware of the validity of ih = jh = kh = 0 */
                    if (did != node[idx].did) {
                        continue; /* skip node not in target domain */
                    }
                    switch (type) {
                        case TYPED: /* use node in target domain */
                            break;
                        case TYPEF: /* use original node in target domain to avoid priority */
                            if ((did != node[idx].gst) || (0 > node[idx].fid)) {
                                continue; /* skip changed node either reconstructed or not */
                            }
                            break;
                        default: /* use node in target domain layer */
                            if (type != node[idx].gst) {
                                continue;
                            }
                            break;
                    }
                    ++tally;
                    ph[X] = MapPoint(nh[X], sMin[X], d[X], ng[X]);
                    ph[Y] = MapPoint(nh[Y], sMin[Y], d[Y], ng[Y]);
                    ph[Z] = MapPoint(nh[Z], sMin[Z], d[Z], ng[Z]);
                    MapPrimitive(model->gamma, model->gasR, node[idx].U[tn], Uoh);
                    ApplyWeighting(Uoh, part->tinyL, Dist2(p, ph), &weightSum, Uo);
                }
            }
        }
    }
    return weightSum;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movq 0x10(%rbp), %rax
movsd 0x3c8(%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
movq 0x10(%rbp), %rax
movsd 0x3d8(%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq 0x10(%rbp), %rax
movsd 0x3e8(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq 0x10(%rbp), %rax
movsd 0x30(%rax), %xmm0
movsd %xmm0, -0x60(%rbp)
movq 0x10(%rbp), %rax
movsd 0x38(%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
movq 0x10(%rbp), %rax
movsd 0x40(%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
movq 0x10(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x6c(%rbp)
movq 0x10(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x68(%rbp)
movq 0x10(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x64(%rbp)
leaq -0xa0(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x20d0
leaq -0xc0(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x20d0
leaq -0xcc(%rbp), %rdi
xorl %esi, %esi
movl $0xc, %edx
callq 0x20d0
xorps %xmm0, %xmm0
movsd %xmm0, -0xd8(%rbp)
movq 0x28(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x20d0
movl -0x1c(%rbp), %eax
movl %eax, -0xdc(%rbp)
movl $0x0, -0xe0(%rbp)
xorl %eax, %eax
cmpl -0xe0(%rbp), %eax
jne 0x1a86f
xorl %eax, %eax
subl -0xdc(%rbp), %eax
movl %eax, -0xe4(%rbp)
movl -0xe4(%rbp), %eax
cmpl -0xdc(%rbp), %eax
jg 0x1a859
xorl %eax, %eax
subl -0xdc(%rbp), %eax
movl %eax, -0xe8(%rbp)
movl -0xe8(%rbp), %eax
cmpl -0xdc(%rbp), %eax
jg 0x1a843
xorl %eax, %eax
subl -0xdc(%rbp), %eax
movl %eax, -0xec(%rbp)
movl -0xec(%rbp), %eax
cmpl -0xdc(%rbp), %eax
jg 0x1a82d
movq -0x10(%rbp), %rax
movl (%rax), %eax
addl -0xec(%rbp), %eax
movl %eax, -0xcc(%rbp)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
addl -0xe8(%rbp), %eax
movl %eax, -0xc8(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
addl -0xe4(%rbp), %eax
movl %eax, -0xc4(%rbp)
movl -0xc4(%rbp), %edi
movl -0xc8(%rbp), %esi
movl -0xcc(%rbp), %edx
movq 0x10(%rbp), %rcx
addq $0x68, %rcx
callq 0x9530
cmpl $0x0, %eax
jne 0x1a659
jmp 0x1a819
movl -0xc4(%rbp), %edi
movl -0xc8(%rbp), %esi
movl -0xcc(%rbp), %edx
movq 0x10(%rbp), %rax
movl 0x10(%rax), %ecx
movq 0x10(%rbp), %rax
movl 0xc(%rax), %r8d
callq 0x9500
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
movq 0x18(%rbp), %rcx
movslq -0x28(%rbp), %rdx
imulq $0x88, %rdx, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
je 0x1a6a0
jmp 0x1a819
movl -0x20(%rbp), %eax
movl %eax, -0xf0(%rbp)
subl $-0x2, %eax
je 0x1a6bf
jmp 0x1a6b0
movl -0xf0(%rbp), %eax
subl $-0x1, %eax
jne 0x1a6f9
jmp 0x1a6bd
jmp 0x1a71a
movl -0x24(%rbp), %eax
movq 0x18(%rbp), %rcx
movslq -0x28(%rbp), %rdx
imulq $0x88, %rdx, %rdx
addq %rdx, %rcx
cmpl 0xc(%rcx), %eax
jne 0x1a6f2
movq 0x18(%rbp), %rcx
movslq -0x28(%rbp), %rax
imulq $0x88, %rax, %rax
addq %rax, %rcx
xorl %eax, %eax
cmpl 0x4(%rcx), %eax
jle 0x1a6f7
jmp 0x1a819
jmp 0x1a71a
movl -0x20(%rbp), %eax
movq 0x18(%rbp), %rcx
movslq -0x28(%rbp), %rdx
imulq $0x88, %rdx, %rdx
addq %rdx, %rcx
cmpl 0xc(%rcx), %eax
je 0x1a718
jmp 0x1a819
jmp 0x1a71a
movl -0xe0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe0(%rbp)
movl -0xcc(%rbp), %edi
movsd -0x40(%rbp), %xmm0
movsd -0x60(%rbp), %xmm1
movl -0x6c(%rbp), %esi
callq 0x9690
movsd %xmm0, -0xc0(%rbp)
movl -0xc8(%rbp), %edi
movsd -0x38(%rbp), %xmm0
movsd -0x58(%rbp), %xmm1
movl -0x68(%rbp), %esi
callq 0x9690
movsd %xmm0, -0xb8(%rbp)
movl -0xc4(%rbp), %edi
movsd -0x30(%rbp), %xmm0
movsd -0x50(%rbp), %xmm1
movl -0x64(%rbp), %esi
callq 0x9690
movsd %xmm0, -0xb0(%rbp)
movq 0x20(%rbp), %rax
movsd 0x40(%rax), %xmm0
movq 0x20(%rbp), %rax
movsd 0x48(%rax), %xmm1
movq 0x18(%rbp), %rdi
movslq -0x28(%rbp), %rax
imulq $0x88, %rax, %rax
addq %rax, %rdi
addq $0x10, %rdi
movslq -0x4(%rbp), %rax
imulq $0x28, %rax, %rax
addq %rax, %rdi
leaq -0xa0(%rbp), %rsi
callq 0x9250
leaq -0xa0(%rbp), %rax
movq %rax, -0x100(%rbp)
movq 0x10(%rbp), %rax
movsd 0x60(%rax), %xmm0
movsd %xmm0, -0xf8(%rbp)
movq -0x18(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x9910
movq -0x100(%rbp), %rdi
movaps %xmm0, %xmm1
movsd -0xf8(%rbp), %xmm0
movq 0x28(%rbp), %rdx
leaq -0xd8(%rbp), %rsi
callq 0x1aa30
movl -0xec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xec(%rbp)
jmp 0x1a5e6
jmp 0x1a82f
movl -0xe8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe8(%rbp)
jmp 0x1a5c6
jmp 0x1a845
movl -0xe4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe4(%rbp)
jmp 0x1a5a6
jmp 0x1a85b
movl -0xdc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xdc(%rbp)
jmp 0x1a58a
movsd -0xd8(%rbp), %xmm0
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq