// File: /workspace/github_c_makefile_star2_O0/mohuangrui[P]ArtraCFD/numerical_test.c
// Function: ComputeSolutionFunctional
void ComputeSolutionFunctional(const Time *time, Space *space, const Model *model)
{
    FILE *fp = Fopen("solution_functional.csv", "a");
    if (0 == time->stepC) { /* initialization step */
        fprintf(fp, "# time, kinetic energy, enstrophy \n");
    }
    const Partition *const part = &(space->part);
    Node *const node = space->node;
    Real *restrict U = NULL; /* numerical solution */
    int idx = 0; /* linear array index math variable */
    const RealVec d = {part->d[X], part->d[Y], part->d[Z]};
    const int h[DIMS][DIMS] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; /* direction indicator */
    Real rho = model->refRho; /* density */
    RealVec V = {0.0}; /* velocity */
    RealVec W = {0.0}; /* vorticity */
    Real Vs[DIMS][TTN] = {{0.0}}; /* velocity stencil */
    Real dV[DIMS][DIMS] = {{0.0}}; /* velocity gradient */
    Real Ek = 0.0; /* kinetic energy */
    Real Ee = 0.0; /* enstrophy */
    int N = 0; /* number of nodes */
    for (int k = part->ns[PIN][Z][MIN]; k < part->ns[PIN][Z][MAX]; ++k) {
        for (int j = part->ns[PIN][Y][MIN]; j < part->ns[PIN][Y][MAX]; ++j) {
            for (int i = part->ns[PIN][X][MIN]; i < part->ns[PIN][X][MAX]; ++i) {
                for (int s = 0; s < DIMS; ++s) {
                    for (int n = -TCN; n <= TCN; ++n) {
                        idx = IndexNode(k + n * h[s][Z], j + n * h[s][Y], i + n * h[s][X], part->n[Y], part->n[X]);
                        U = node[idx].U[TO];
                        Vs[X][TCN+n] = U[1] / U[0];
                        Vs[Y][TCN+n] = U[2] / U[0];
                        Vs[Z][TCN+n] = U[3] / U[0];
                    }
                    dV[X][s] = (-Vs[X][TCN+2] + 8.0 * Vs[X][TCN+1] - 8.0 * Vs[X][TCN-1] + Vs[X][TCN-2]) / (12.0 * d[s]);
                    dV[Y][s] = (-Vs[Y][TCN+2] + 8.0 * Vs[Y][TCN+1] - 8.0 * Vs[Y][TCN-1] + Vs[Y][TCN-2]) / (12.0 * d[s]);
                    dV[Z][s] = (-Vs[Z][TCN+2] + 8.0 * Vs[Z][TCN+1] - 8.0 * Vs[Z][TCN-1] + Vs[Z][TCN-2]) / (12.0 * d[s]);
                }
                idx = IndexNode(k, j, i, part->n[Y], part->n[X]);
                U = node[idx].U[TO];
                rho = U[0];
                V[X] = U[1] / U[0];
                V[Y] = U[2] / U[0];
                V[Z] = U[3] / U[0];
                W[X] = dV[Z][Y] - dV[Y][Z];
                W[Y] = dV[X][Z] - dV[Z][X];
                W[Z] = dV[Y][X] - dV[X][Y];
                Ek = Ek + rho * Dot(V,V);
                Ee = Ee + rho * Dot(W,W);
                ++N;
            }
        }
    }
    Ek = 0.5 * Ek / N;
    Ee = 0.5 * Ee / N;
    fprintf(fp, "%.6g, %.6g, %.6g\n", time->now, Ek, Ee);
    fclose(fp);
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq 0xc95f(%rip), %rdi      # 0x2918d
leaq 0xb14a(%rip), %rsi      # 0x2797f
callq 0xbf90
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rcx
xorl %eax, %eax
cmpl 0x8(%rcx), %eax
jne 0x1c85b
movq -0x20(%rbp), %rdi
leaq 0xc951(%rip), %rsi      # 0x291a5
movb $0x0, %al
callq 0x2140
movq -0x10(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movq -0x28(%rbp), %rax
movsd 0x30(%rax), %xmm0
movsd %xmm0, -0x60(%rbp)
movq -0x28(%rbp), %rax
movsd 0x38(%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0x28(%rbp), %rax
movsd 0x40(%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
movl $0x24, %edx
callq 0x20d0
movl $0x1, -0x90(%rbp)
movl $0x1, -0x80(%rbp)
movl $0x1, -0x70(%rbp)
movq -0x18(%rbp), %rax
movsd 0x60(%rax), %xmm0
movsd %xmm0, -0x98(%rbp)
leaq -0xb0(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x20d0
leaq -0xd0(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x20d0
leaq -0x150(%rbp), %rdi
xorl %esi, %esi
movl $0x78, %edx
callq 0x20d0
leaq -0x1a0(%rbp), %rdi
xorl %esi, %esi
movl $0x48, %edx
callq 0x20d0
xorps %xmm0, %xmm0
movsd %xmm0, -0x1a8(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x1b0(%rbp)
movl $0x0, -0x1b4(%rbp)
movq -0x28(%rbp), %rax
movl 0x78(%rax), %eax
movl %eax, -0x1b8(%rbp)
movl -0x1b8(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x7c(%rcx), %eax
jge 0x1ce7e
movq -0x28(%rbp), %rax
movl 0x70(%rax), %eax
movl %eax, -0x1bc(%rbp)
movl -0x1bc(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x74(%rcx), %eax
jge 0x1ce68
movq -0x28(%rbp), %rax
movl 0x68(%rax), %eax
movl %eax, -0x1c0(%rbp)
movl -0x1c0(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x6c(%rcx), %eax
jge 0x1ce52
movl $0x0, -0x1c4(%rbp)
cmpl $0x3, -0x1c4(%rbp)
jge 0x1cc9d
movl $0xfffffffe, -0x1c8(%rbp) # imm = 0xFFFFFFFE
cmpl $0x2, -0x1c8(%rbp)
jg 0x1cb09
movl -0x1b8(%rbp), %edi
movl -0x1c8(%rbp), %eax
movslq -0x1c4(%rbp), %rdx
leaq -0x90(%rbp), %rcx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
imull 0x8(%rcx), %eax
addl %eax, %edi
movl -0x1bc(%rbp), %esi
movl -0x1c8(%rbp), %eax
movslq -0x1c4(%rbp), %rdx
leaq -0x90(%rbp), %rcx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
imull 0x4(%rcx), %eax
addl %eax, %esi
movl -0x1c0(%rbp), %edx
movl -0x1c8(%rbp), %eax
movslq -0x1c4(%rbp), %r8
leaq -0x90(%rbp), %rcx
imulq $0xc, %r8, %r8
addq %r8, %rcx
imull (%rcx), %eax
addl %eax, %edx
movq -0x28(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x28(%rbp), %rax
movl 0xc(%rax), %r8d
callq 0x9500
movl %eax, -0x3c(%rbp)
movq -0x30(%rbp), %rax
movslq -0x3c(%rbp), %rcx
imulq $0x88, %rcx, %rcx
addq %rcx, %rax
addq $0x10, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movsd 0x8(%rax), %xmm0
movq -0x38(%rbp), %rax
divsd (%rax), %xmm0
movl -0x1c8(%rbp), %eax
addl $0x2, %eax
cltq
movsd %xmm0, -0x150(%rbp,%rax,8)
movq -0x38(%rbp), %rax
movsd 0x10(%rax), %xmm0
movq -0x38(%rbp), %rax
divsd (%rax), %xmm0
movl -0x1c8(%rbp), %eax
addl $0x2, %eax
cltq
movsd %xmm0, -0x128(%rbp,%rax,8)
movq -0x38(%rbp), %rax
movsd 0x18(%rax), %xmm0
movq -0x38(%rbp), %rax
divsd (%rax), %xmm0
movl -0x1c8(%rbp), %eax
addl $0x2, %eax
cltq
movsd %xmm0, -0x100(%rbp,%rax,8)
movl -0x1c8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c8(%rbp)
jmp 0x1c9d4
movsd -0x130(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd -0x138(%rbp), %xmm1
movsd 0xc600(%rip), %xmm2     # 0x29138
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd -0x148(%rbp), %xmm0
movsd 0xc5e0(%rip), %xmm2     # 0x29130
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
addsd -0x150(%rbp), %xmm0
movslq -0x1c4(%rbp), %rax
movsd 0xc5b9(%rip), %xmm1     # 0x29128
mulsd -0x60(%rbp,%rax,8), %xmm1
divsd %xmm1, %xmm0
movslq -0x1c4(%rbp), %rax
movsd %xmm0, -0x1a0(%rbp,%rax,8)
movsd -0x108(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd -0x110(%rbp), %xmm1
movsd 0xc580(%rip), %xmm2     # 0x29138
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd -0x120(%rbp), %xmm0
movsd 0xc560(%rip), %xmm2     # 0x29130
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
addsd -0x128(%rbp), %xmm0
movslq -0x1c4(%rbp), %rax
movsd 0xc539(%rip), %xmm1     # 0x29128
mulsd -0x60(%rbp,%rax,8), %xmm1
divsd %xmm1, %xmm0
movslq -0x1c4(%rbp), %rax
movsd %xmm0, -0x188(%rbp,%rax,8)
movsd -0xe0(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd -0xe8(%rbp), %xmm1
movsd 0xc500(%rip), %xmm2     # 0x29138
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd -0xf8(%rbp), %xmm0
movsd 0xc4e0(%rip), %xmm2     # 0x29130
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
addsd -0x100(%rbp), %xmm0
movslq -0x1c4(%rbp), %rax
movsd 0xc4b9(%rip), %xmm1     # 0x29128
mulsd -0x60(%rbp,%rax,8), %xmm1
divsd %xmm1, %xmm0
movslq -0x1c4(%rbp), %rax
movsd %xmm0, -0x170(%rbp,%rax,8)
movl -0x1c4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c4(%rbp)
jmp 0x1c9bd
movl -0x1b8(%rbp), %edi
movl -0x1bc(%rbp), %esi
movl -0x1c0(%rbp), %edx
movq -0x28(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x28(%rbp), %rax
movl 0xc(%rax), %r8d
callq 0x9500
movl %eax, -0x3c(%rbp)
movq -0x30(%rbp), %rax
movslq -0x3c(%rbp), %rcx
imulq $0x88, %rcx, %rcx
addq %rcx, %rax
addq $0x10, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x98(%rbp)
movq -0x38(%rbp), %rax
movsd 0x8(%rax), %xmm0
movq -0x38(%rbp), %rax
divsd (%rax), %xmm0
movsd %xmm0, -0xb0(%rbp)
movq -0x38(%rbp), %rax
movsd 0x10(%rax), %xmm0
movq -0x38(%rbp), %rax
divsd (%rax), %xmm0
movsd %xmm0, -0xa8(%rbp)
movq -0x38(%rbp), %rax
movsd 0x18(%rax), %xmm0
movq -0x38(%rbp), %rax
divsd (%rax), %xmm0
movsd %xmm0, -0xa0(%rbp)
movsd -0x168(%rbp), %xmm0
subsd -0x178(%rbp), %xmm0
movsd %xmm0, -0xd0(%rbp)
movsd -0x190(%rbp), %xmm0
subsd -0x170(%rbp), %xmm0
movsd %xmm0, -0xc8(%rbp)
movsd -0x188(%rbp), %xmm0
subsd -0x198(%rbp), %xmm0
movsd %xmm0, -0xc0(%rbp)
movsd -0x1a8(%rbp), %xmm0
movsd %xmm0, -0x1e8(%rbp)
movsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x1e0(%rbp)
leaq -0xb0(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x9880
movsd -0x1e8(%rbp), %xmm1
movaps %xmm0, %xmm2
movsd -0x1e0(%rbp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x1a8(%rbp)
movsd -0x1b0(%rbp), %xmm0
movsd %xmm0, -0x1d8(%rbp)
movsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x1d0(%rbp)
leaq -0xd0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x9880
movsd -0x1d8(%rbp), %xmm1
movaps %xmm0, %xmm2
movsd -0x1d0(%rbp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x1b0(%rbp)
movl -0x1b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1b4(%rbp)
movl -0x1c0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c0(%rbp)
jmp 0x1c9a0
jmp 0x1ce54
movl -0x1bc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1bc(%rbp)
jmp 0x1c980
jmp 0x1ce6a
movl -0x1b8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1b8(%rbp)
jmp 0x1c960
movsd 0xa882(%rip), %xmm0     # 0x27708
mulsd -0x1a8(%rbp), %xmm0
cvtsi2sdl -0x1b4(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x1a8(%rbp)
movsd 0xa85e(%rip), %xmm0     # 0x27708
mulsd -0x1b0(%rbp), %xmm0
cvtsi2sdl -0x1b4(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x1b0(%rbp)
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rax
movsd 0x48(%rax), %xmm0
movsd -0x1a8(%rbp), %xmm1
movsd -0x1b0(%rbp), %xmm2
leaq 0xc291(%rip), %rsi      # 0x2917b
movb $0x3, %al
callq 0x2140
movq -0x20(%rbp), %rdi
callq 0x2080
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)