// File: /workspace/github_c_makefile_star2_O2/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 $0x68, %rsp
movq %rdi, %r14
leaq 0xa614(%rip), %rdi      # 0x1d220
leaq 0x8005(%rip), %rsi      # 0x1ac18
callq 0x8820
movq %rax, 0x38(%rsp)
movq (%r14), %rbx
movl 0x28(%r14), %ebp
movl 0x2c(%r14), %edi
movl 0x30(%r14), %esi
callq 0x7649
movl %ebp, %edi
movl %eax, %esi
callq 0x7649
movl %eax, 0x1c(%rsp)
movl 0xa0(%r14), %r15d
xorl %ebp, %ebp
xorpd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd %xmm0, 0x8(%rsp)
cmpl 0xa4(%r14), %r15d
jge 0x12d32
movl 0x98(%r14), %r12d
cmpl 0x9c(%r14), %r12d
jge 0x12d2a
movapd %xmm0, 0x20(%rsp)
movl 0x90(%r14), %r13d
cmpl 0x94(%r14), %r13d
jge 0x12d1c
movl 0x34(%r14), %r8d
movl 0x38(%r14), %ecx
movl %r15d, %edi
movl %r12d, %esi
movl %r13d, %edx
callq 0x75ec
cltq
imulq $0x88, %rax, %rax
movsd 0x10(%rbx,%rax), %xmm0
subsd 0x38(%rbx,%rax), %xmm0
movapd %xmm0, 0x50(%rsp)
movapd %xmm0, %xmm1
andpd 0x5371(%rip), %xmm1     # 0x18040
movapd %xmm1, 0x40(%rsp)
movsd 0x10(%rsp), %xmm0
callq 0x7665
movsd %xmm0, 0x10(%rsp)
movsd 0x8(%rsp), %xmm0
addsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movapd 0x50(%rsp), %xmm1
mulsd %xmm1, %xmm1
movapd 0x20(%rsp), %xmm0
addsd %xmm1, %xmm0
movapd %xmm0, 0x20(%rsp)
incl %ebp
incl %r13d
jmp 0x12c85
incl %r12d
movapd 0x20(%rsp), %xmm0
jmp 0x12c6b
incl %r15d
jmp 0x12c57
cvtsi2sd %ebp, %xmm2
movsd 0x8(%rsp), %xmm1
divsd %xmm2, %xmm1
movsd %xmm1, 0x8(%rsp)
divsd %xmm2, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x12d5a
sqrtsd %xmm0, %xmm0
jmp 0x12d5f
callq 0x2220
movsd %xmm0, 0x20(%rsp)
leaq 0xa4c7(%rip), %rdi      # 0x1d233
pushq $0x23
popq %rsi
pushq $0x1
popq %rdx
movq 0x38(%rsp), %rbx
movq %rbx, %rcx
callq 0x2210
leaq 0xa4d1(%rip), %rsi      # 0x1d257
movq %rbx, %rdi
movl 0x1c(%rsp), %edx
movsd 0x8(%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
movsd 0x10(%rsp), %xmm2
movb $0x3, %al
callq 0x2160
movq %rbx, %rdi
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2080