// File: /workspace/github_c_makefile_star2_O2/mohuangrui[P]ArtraCFD/convective_flux.c
// Function: ComputeFhat
void ComputeFhat(const int tn, const int s, const int k, const int j, const int i,
        const int partn[restrict], const Node *const node, const Model *model, Real Fhat[restrict])
{
    const int h[DIMS][DIMS] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; /* direction indicator */
    const int idxL = IndexNode(k, j, i, partn[Y], partn[X]);
    const int idxR = IndexNode(k + h[s][Z], j + h[s][Y], i + h[s][X], partn[Y], partn[X]);
    /* evaluate interface values by averaging */
    Real Uo[DIMUo]; /* store averaged primitives */
    SymmetricAverage(model->jacobMean, model->gamma, node[idxL].U[tn], node[idxR].U[tn], Uo);
    /* decompose Jacobian matrix */
    Real Lambda[DIMU]; /* eigenvalues */
    Real L[DIMU][DIMU]; /* vector space {Ln} */
    Real R[DIMU][DIMU]; /* vector space {Rn} */
    Eigenvalue(s, Uo, Lambda);
    EigenvectorL(s, model->gamma, Uo, L);
    EigenvectorR(s, Uo, R);
    /* flux vector splitting */
    Real LambdaP[DIMU]; /* eigenvalues */
    Real LambdaN[DIMU]; /* eigenvalues */
    EigenvalueSplitting(model->fluxSplit, Lambda, LambdaP, LambdaN);
    /* construct local characteristic variables for all potential stencils */
    Real W[FTN][DIMU];
    CharacteristicVariable(tn, s, k, j, i, model->sL, model->sR, partn, node, L, W);
    /* construct local characteristic fluxes */
    Real HP[FDN][DIMU]; /* forward characteristic flux stencil */
    Real HN[FDN][DIMU]; /* backward characteristic flux stencil */
    CharacteristicFlux(LambdaP, W, 0, +1, model->sR - model->sL, HP);
    CharacteristicFlux(LambdaN, W, model->sR - model->sL, -1, model->sR - model->sL, HN);
    /* WENO reconstruction */
    Real HhatP[DIMU]; /* forward numerical flux of characteristic fields */
    Real HhatN[DIMU]; /* backward numerical flux of characteristic fields */
    ReconstructFhat[model->sScheme](HP, HhatP);
    ReconstructFhat[model->sScheme](HN, HhatN);
    /* inverse projection */
    InverseProjection(R, HhatP, HhatN, Fhat);
    return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x5a8, %rsp            # imm = 0x5A8
movl %r8d, %ebx
movl %ecx, %ebp
movl %edx, %r13d
movl %esi, %r12d
movl %edi, 0x10(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x40(%rsp)
pushq $0x1
popq %rax
movl %eax, 0x30(%rsp)
movl %eax, 0x40(%rsp)
movl %eax, 0x50(%rsp)
movl (%r9), %r15d
movl 0x4(%r9), %r14d
movl %edx, %edi
movl %ecx, %esi
movl %r8d, %edx
movl %r14d, %ecx
movl %r15d, %r8d
callq 0x75ec
movl %eax, 0xc(%rsp)
movslq %r12d, %rax
movq %rax, 0x28(%rsp)
imulq $0xc, %rax, %r12
movl 0x38(%rsp,%r12), %edi
movl %r13d, 0x1c(%rsp)
addl %r13d, %edi
movl 0x34(%rsp,%r12), %esi
movl %ebp, 0x20(%rsp)
addl %ebp, %esi
movl 0x30(%rsp,%r12), %edx
movl %ebx, 0x24(%rsp)
addl %ebx, %edx
movl %r14d, 0x14(%rsp)
movl %r14d, %ecx
movl %r15d, 0x18(%rsp)
movl %r15d, %r8d
callq 0x75ec
movq 0x5e8(%rsp), %r15
movl 0x14(%r15), %edi
movsd 0x40(%r15), %xmm0
movslq 0xc(%rsp), %rcx
movslq 0x10(%rsp), %rdx
imulq $0x88, %rcx, %rcx
movq 0x5e0(%rsp), %r8
addq %r8, %rcx
imulq $0x28, %rdx, %rbx
leaq (%rbx,%rcx), %rsi
addq $0x10, %rsi
cltq
imulq $0x88, %rax, %rax
addq %r8, %rax
leaq (%rbx,%rax), %rdx
addq $0x10, %rdx
leaq 0x220(%rsp), %rbp
movq %rbp, %rcx
callq 0x7038
leaq 0x120(%rsp), %rdx
movq 0x28(%rsp), %r13
movl %r13d, %edi
movq %rbp, %rsi
callq 0x7291
movsd 0x40(%r15), %xmm0
leaq 0x250(%rsp), %rdx
movl %r13d, %edi
movq %rbp, %rsi
callq 0x72db
leaq 0x4e0(%rsp), %r14
movl %r13d, %edi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x7352
movl 0x18(%r15), %edi
leaq 0xf0(%rsp), %rdx
leaq 0xc0(%rsp), %rcx
leaq 0x120(%rsp), %rsi
callq 0x72c4
movl 0x8(%r15), %ebp
movl 0xc(%r15), %r15d
xorpd %xmm0, %xmm0
movapd %xmm0, 0x150(%rsp)
movapd %xmm0, 0x160(%rsp)
pushq $0x1
popq %rax
movl %eax, 0x150(%rsp)
movl %eax, 0x160(%rsp)
movl %eax, 0x170(%rsp)
addq %rsp, %r12
addq $0x150, %r12            # imm = 0x150
xorl %r13d, %r13d
cmpl %r15d, %ebp
jg 0xb0e1
movl 0x8(%r12), %edi
imull %ebp, %edi
addl 0x1c(%rsp), %edi
movl 0x4(%r12), %esi
imull %ebp, %esi
addl 0x20(%rsp), %esi
movl (%r12), %edx
imull %ebp, %edx
addl 0x24(%rsp), %edx
movl 0x14(%rsp), %ecx
movl 0x18(%rsp), %r8d
callq 0x75ec
cltq
imulq $0x88, %rax, %rax
addq 0x5e0(%rsp), %rax
addq %rbx, %rax
addq $0x10, %rax
leaq 0x250(%rsp), %rcx
xorl %edx, %edx
cmpq $0x5, %rdx
je 0xb0d7
xorpd %xmm0, %xmm0
xorl %esi, %esi
cmpq $0x5, %rsi
je 0xb0bb
movsd (%rcx,%rsi,8), %xmm1
mulsd (%rax,%rsi,8), %xmm1
addsd %xmm1, %xmm0
incq %rsi
jmp 0xb0a2
imulq $0x28, %r13, %rsi
addq %rsp, %rsi
addq $0x320, %rsi            # imm = 0x320
movsd %xmm0, (%rsi,%rdx,8)
incq %rdx
addq $0x28, %rcx
jmp 0xb096
incl %ebp
incq %r13
jmp 0xb03a
movq 0x5e8(%rsp), %r12
movl 0xc(%r12), %ebx
subl 0x8(%r12), %ebx
leaq 0xf0(%rsp), %rdi
leaq 0x320(%rsp), %r15
xorl %ebp, %ebp
pushq $0x1
popq %rcx
leaq 0x150(%rsp), %r9
movq %r15, %rsi
xorl %edx, %edx
movl %ebx, %r8d
callq 0xb1c7
leaq 0xc0(%rsp), %rdi
pushq $-0x1
popq %rcx
leaq 0x410(%rsp), %r13
movq %r15, %rsi
movl %ebx, %edx
movl %ebx, %r8d
movq %r13, %r9
callq 0xb1c7
movslq 0x4(%r12), %rax
leaq 0x18bd4(%rip), %rbx     # 0x23d20
leaq 0x90(%rsp), %rsi
leaq 0x150(%rsp), %rdi
callq *(%rbx,%rax,8)
movslq 0x4(%r12), %rax
leaq 0x60(%rsp), %rsi
movq %r13, %rdi
callq *(%rbx,%rax,8)
movq 0x5f0(%rsp), %rcx
cmpq $0x5, %rbp
je 0xb1b5
xorpd %xmm0, %xmm0
xorl %eax, %eax
cmpq $0x5, %rax
je 0xb1a7
movsd 0x90(%rsp,%rax,8), %xmm1
addsd 0x60(%rsp,%rax,8), %xmm1
mulsd (%r14,%rax,8), %xmm1
addsd %xmm1, %xmm0
incq %rax
jmp 0xb183
movsd %xmm0, (%rcx,%rbp,8)
incq %rbp
addq $0x28, %r14
jmp 0xb177
addq $0x5a8, %rsp            # imm = 0x5A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq