// File: /workspace/github_c_makefile_star2_O3/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, %ebp
movl %ecx, %r14d
movl %edx, %r15d
movl %esi, 0xc(%rsp)
movl %edi, 0x8(%rsp)
movq 0x5e8(%rsp), %r13
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x40(%rsp)
movl $0x1, %eax
movl %eax, 0x30(%rsp)
movl %eax, 0x40(%rsp)
movl %eax, 0x50(%rsp)
movl (%r9), %r12d
movl 0x4(%r9), %ebx
movl %edx, %edi
movl %ecx, %esi
movl %r8d, %edx
movl %ebx, %ecx
movl %r12d, %r8d
callq 0x7d53
movl %eax, 0x1c(%rsp)
movslq 0xc(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq (%rax,%rax,2), %rax
movl 0x38(%rsp,%rax,4), %edi
movl %r15d, 0x28(%rsp)
addl %r15d, %edi
movq %rax, %r15
movl 0x34(%rsp,%rax,4), %esi
movl %r14d, 0x2c(%rsp)
addl %r14d, %esi
movl 0x30(%rsp,%rax,4), %edx
movl %ebp, 0xc(%rsp)
addl %ebp, %edx
movl %ebx, 0x20(%rsp)
movl %ebx, %ecx
movl %r12d, 0x24(%rsp)
movl %r12d, %r8d
callq 0x7d53
movl 0x14(%r13), %edi
movsd 0x40(%r13), %xmm0
movslq 0x1c(%rsp), %rcx
movslq 0x8(%rsp), %r12
movq %rcx, %rdx
shlq $0x7, %rdx
leaq (%rdx,%rcx,8), %rcx
movq 0x5e0(%rsp), %r8
addq %r8, %rcx
leaq (,%r12,8), %rdx
leaq (%rdx,%rdx,4), %rdx
leaq (%rcx,%rdx), %rsi
addq $0x10, %rsi
cltq
movq %rax, %rcx
shlq $0x7, %rcx
leaq (%rcx,%rax,8), %rax
addq %r8, %rax
addq %rax, %rdx
addq $0x10, %rdx
leaq 0x220(%rsp), %rbp
movq %rbp, %rcx
callq 0x77a8
leaq 0x1f0(%rsp), %rdx
movq 0x10(%rsp), %r14
movl %r14d, %edi
movq %rbp, %rsi
callq 0x7a07
movsd 0x40(%r13), %xmm0
leaq 0x410(%rsp), %rdx
movl %r14d, %edi
movq %rbp, %rsi
callq 0x7a51
leaq 0x4e0(%rsp), %rbx
movl %r14d, %edi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x7ac8
movl 0x18(%r13), %edi
leaq 0x1c0(%rsp), %rdx
leaq 0x190(%rsp), %rcx
leaq 0x1f0(%rsp), %rsi
callq 0x7a3a
movl 0x8(%r13), %ebp
movl 0xc(%r13), %eax
xorpd %xmm0, %xmm0
movapd %xmm0, 0xc0(%rsp)
movapd %xmm0, 0xd0(%rsp)
movl $0x1, %ecx
movl %ecx, 0xc0(%rsp)
movl %ecx, 0xd0(%rsp)
movl %ecx, 0xe0(%rsp)
movl %eax, %r14d
subl %ebp, %r14d
jl 0xb96a
movl 0xc8(%rsp,%r15,4), %eax
movl %eax, 0x10(%rsp)
movl 0xc0(%rsp,%r15,4), %eax
movl %eax, 0x8(%rsp)
movl 0xc4(%rsp,%r15,4), %r13d
incl %r14d
xorl %r15d, %r15d
leaq (%r12,%r12,4), %r12
movl %ebp, %edi
imull 0x10(%rsp), %edi
addl 0x28(%rsp), %edi
movl %ebp, %esi
imull %r13d, %esi
addl 0x2c(%rsp), %esi
movl %ebp, %edx
imull 0x8(%rsp), %edx
addl 0xc(%rsp), %edx
movl 0x20(%rsp), %ecx
movl 0x24(%rsp), %r8d
callq 0x7d53
cltq
movq %rax, %rcx
shlq $0x7, %rcx
leaq (%rcx,%rax,8), %rax
addq 0x5e0(%rsp), %rax
leaq (%rax,%r12,8), %rax
addq $0x10, %rax
leaq 0x410(%rsp), %rcx
xorl %edx, %edx
xorpd %xmm0, %xmm0
xorl %esi, %esi
movsd (%rcx,%rsi,8), %xmm1
mulsd (%rax,%rsi,8), %xmm1
addsd %xmm1, %xmm0
incq %rsi
cmpq $0x5, %rsi
jne 0xb914
leaq (%r15,%r15,4), %rsi
leaq (%rsp,%rsi,8), %rsi
addq $0x250, %rsi            # imm = 0x250
movsd %xmm0, (%rsi,%rdx,8)
incq %rdx
addq $0x28, %rcx
cmpq $0x5, %rdx
jne 0xb90e
incl %ebp
incq %r15
cmpq %r14, %r15
jne 0xb8b9
movq 0x5e8(%rsp), %r13
movl 0x8(%r13), %ebp
movl 0xc(%r13), %eax
subl %ebp, %eax
jle 0xb9fb
leaq 0xc0(%rsp), %rcx
movl %eax, %eax
leaq 0x250(%rsp), %rdx
xorl %esi, %esi
xorl %edi, %edi
movsd 0x1c0(%rsp,%rdi,8), %xmm0
mulsd (%rdx,%rdi,8), %xmm0
movsd %xmm0, (%rcx,%rdi,8)
incq %rdi
cmpq $0x5, %rdi
jne 0xb988
incq %rsi
addq $0x28, %rcx
addq $0x28, %rdx
cmpq %rax, %rsi
jne 0xb986
leaq (%rax,%rax,4), %rcx
leaq (%rsp,%rcx,8), %rcx
addq $0x250, %rcx            # imm = 0x250
leaq 0x340(%rsp), %rdx
xorl %esi, %esi
xorl %edi, %edi
movsd 0x190(%rsp,%rdi,8), %xmm0
mulsd (%rcx,%rdi,8), %xmm0
movsd %xmm0, (%rdx,%rdi,8)
incq %rdi
cmpq $0x5, %rdi
jne 0xb9cf
incq %rsi
addq $0x28, %rdx
addq $-0x28, %rcx
cmpq %rax, %rsi
jne 0xb9cd
movq 0x5f0(%rsp), %r14
movslq 0x4(%r13), %rax
leaq 0x18312(%rip), %r15     # 0x23d20
leaq 0xc0(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq *(%r15,%rax,8)
movslq 0x4(%r13), %rax
leaq 0x340(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq *(%r15,%rax,8)
xorl %eax, %eax
xorpd %xmm0, %xmm0
xorl %ecx, %ecx
movsd 0x90(%rsp,%rcx,8), %xmm1
addsd 0x60(%rsp,%rcx,8), %xmm1
mulsd (%rbx,%rcx,8), %xmm1
addsd %xmm1, %xmm0
incq %rcx
cmpq $0x5, %rcx
jne 0xba3f
movsd %xmm0, (%r14,%rax,8)
incq %rax
addq $0x28, %rbx
cmpq $0x5, %rax
jne 0xba39
addq $0x5a8, %rsp            # imm = 0x5A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)