// File: /workspace/github_c_makefile_star2_O1/mohuangrui[P]ArtraCFD/numerical_test.c
// Function: ComputeSolutionError
void ComputeSolutionError(Space *space)
{
    FILE *fp = Fopen("solution_error.csv", "w");
    const Partition *const part = &(space->part);
    Node *const node = space->node;
    Real *restrict Us = NULL; /* numerical solution */
    Real *restrict Ue = NULL; /* exact solution */
    int idx = 0; /* linear array index math variable */
    const int meshN = MaxInt(part->m[X], MaxInt(part->m[Y], part->m[Z]));
    Real norm[3] = {0.0}; /* Lp norms */
    int N = 0; /* number of nodes */
    Real err = 0.0; /* solution error */
    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) {
                idx = IndexNode(k, j, i, part->n[Y], part->n[X]);
                Us = node[idx].U[TO];
                Ue = node[idx].U[TN];
                err = fabs(Us[0] - Ue[0]);
                norm[0] = MaxReal(norm[0], err);
                norm[1] = norm[1] + err;
                norm[2] = norm[2] + err * err;
                ++N;
            }
        }
    }
    norm[1] = norm[1] / N;
    norm[2] = sqrt(norm[2] / N);
    fprintf(fp, "# mesh, l1 norm, l2 norm, max norm\n");
    fprintf(fp, "%d, %.6g, %.6g, %.6g\n", meshN, norm[1], norm[2], norm[0]);
    fclose(fp);
    return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %r14
leaq 0xb3f4(%rip), %rdi      # 0x1f338
leaq 0x8ddd(%rip), %rsi      # 0x1cd28
callq 0x9269
movq %rax, %r12
movq (%r14), %rbx
movl 0x28(%r14), %ebp
movl 0x2c(%r14), %edi
movl 0x30(%r14), %esi
callq 0x7f00
movl %ebp, %edi
movl %eax, %esi
callq 0x7f00
movl %eax, %ebp
movl 0xa0(%r14), %r15d
xorpd %xmm3, %xmm3
xorps %xmm0, %xmm0
xorpd %xmm1, %xmm1
xorpd %xmm4, %xmm4
xorpd %xmm2, %xmm2
cmpl 0xa4(%r14), %r15d
jge 0x14086
movl %ebp, 0x24(%rsp)
movq %r12, 0x28(%rsp)
xorl %ebp, %ebp
movl 0x98(%r14), %r12d
cmpl 0x9c(%r14), %r12d
jge 0x14062
movl 0x90(%r14), %r13d
cmpl 0x94(%r14), %r13d
jge 0x1405a
movsd %xmm0, 0x10(%rsp)
movsd %xmm4, 0x8(%rsp)
movsd %xmm1, 0x18(%rsp)
movl 0x34(%r14), %r8d
movl 0x38(%r14), %ecx
movl %r15d, %edi
movl %r12d, %esi
movl %r13d, %edx
callq 0x7ea3
cltq
movq %rax, %rcx
shlq $0x7, %rcx
leaq (%rcx,%rax,8), %rax
movsd 0x10(%rbx,%rax), %xmm0
subsd 0x38(%rbx,%rax), %xmm0
movapd %xmm0, 0x40(%rsp)
movapd %xmm0, %xmm1
andpd 0x6021(%rip), %xmm1     # 0x1a040
movapd %xmm1, 0x30(%rsp)
movsd 0x10(%rsp), %xmm0
callq 0x7f1c
movsd 0x8(%rsp), %xmm4
movsd 0x18(%rsp), %xmm1
addsd 0x30(%rsp), %xmm1
movapd 0x40(%rsp), %xmm2
mulsd %xmm2, %xmm2
addsd %xmm2, %xmm4
incl %ebp
incl %r13d
jmp 0x13fbf
incl %r12d
jmp 0x13fab
incl %r15d
cmpl 0xa4(%r14), %r15d
jl 0x13fa4
xorps %xmm2, %xmm2
cvtsi2sd %ebp, %xmm2
movq 0x28(%rsp), %r12
movl 0x24(%rsp), %ebp
xorpd %xmm3, %xmm3
movsd %xmm0, 0x10(%rsp)
divsd %xmm2, %xmm1
movsd %xmm1, 0x18(%rsp)
divsd %xmm2, %xmm4
ucomisd %xmm3, %xmm4
jb 0x140a9
xorps %xmm0, %xmm0
sqrtsd %xmm4, %xmm0
jmp 0x140b2
movapd %xmm4, %xmm0
callq 0x2210
movsd %xmm0, 0x8(%rsp)
leaq 0xb28c(%rip), %rdi      # 0x1f34b
movl $0x23, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x2200
leaq 0xb297(%rip), %rsi      # 0x1f36f
movq %r12, %rdi
movl %ebp, %edx
movsd 0x18(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
movsd 0x10(%rsp), %xmm2
movb $0x3, %al
callq 0x2150
movq %r12, %rdi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2080