// File: /workspace/github_c_makefile_star2_O3/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 0xa84c(%rip), %rdi      # 0x1e3c8
leaq 0x81a5(%rip), %rsi      # 0x1bd28
callq 0x9026
movq %rax, %r12
movq (%r14), %rbx
movl 0x28(%r14), %ebp
movl 0x2c(%r14), %edi
movl 0x30(%r14), %esi
callq 0x7db0
movl %ebp, %edi
movl %eax, %esi
callq 0x7db0
movl %eax, %ebp
movl 0xa0(%r14), %r15d
movl 0xa4(%r14), %ecx
xorps %xmm0, %xmm0
xorpd %xmm1, %xmm1
xorpd %xmm3, %xmm3
xorpd %xmm2, %xmm2
cmpl %ecx, %r15d
jge 0x13cd8
movl %ebp, 0x24(%rsp)
movq %r12, 0x28(%rsp)
movl 0x9c(%r14), %eax
xorl %ebp, %ebp
movl 0x98(%r14), %r12d
cmpl %eax, %r12d
jge 0x13cbc
movl 0x94(%r14), %ecx
movl 0x90(%r14), %r13d
cmpl %ecx, %r13d
jge 0x13ca9
movsd %xmm0, 0x10(%rsp)
movsd %xmm3, 0x8(%rsp)
movsd %xmm1, 0x18(%rsp)
movl 0x34(%r14), %r8d
movl 0x38(%r14), %ecx
movl %r15d, %edi
movl %r12d, %esi
movl %r13d, %edx
callq 0x7d53
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 0x53e4(%rip), %xmm1     # 0x19040
movapd %xmm1, 0x30(%rsp)
movsd 0x10(%rsp), %xmm0
callq 0x7dcc
movsd 0x8(%rsp), %xmm3
movsd 0x18(%rsp), %xmm1
addsd 0x30(%rsp), %xmm1
movapd 0x40(%rsp), %xmm2
mulsd %xmm2, %xmm2
addsd %xmm2, %xmm3
incl %ebp
incl %r13d
movl 0x94(%r14), %ecx
cmpl %ecx, %r13d
jl 0x13c09
movl 0x9c(%r14), %eax
incl %r12d
cmpl %eax, %r12d
jl 0x13bf9
movl 0xa4(%r14), %ecx
incl %r15d
cmpl %ecx, %r15d
jl 0x13be2
xorps %xmm2, %xmm2
cvtsi2sd %ebp, %xmm2
movq 0x28(%rsp), %r12
movl 0x24(%rsp), %ebp
movsd %xmm0, 0x10(%rsp)
divsd %xmm2, %xmm1
movsd %xmm1, 0x18(%rsp)
divsd %xmm2, %xmm3
ucomisd 0x531c(%rip), %xmm3     # 0x19010
jb 0x13cff
xorps %xmm0, %xmm0
sqrtsd %xmm3, %xmm0
jmp 0x13d08
movapd %xmm3, %xmm0
callq 0x2210
movsd %xmm0, 0x8(%rsp)
leaq 0xa6c6(%rip), %rdi      # 0x1e3db
movl $0x23, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x2200
leaq 0xa6d1(%rip), %rsi      # 0x1e3ff
movq %r12, %rdi
movl %ebp, %edx
movsd 0x18(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
movsd 0x10(%rsp), %xmm2
movb $0x3, %al
callq 0x2160
movq %r12, %rdi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2080