// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
leaq 0xcb6d(%rip), %rdi      # 0x29140
leaq 0xa8a2(%rip), %rsi      # 0x26e7c
callq 0xbf90
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x70(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %edi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x9660
movl -0x70(%rbp), %edi
movl %eax, %esi
callq 0x9660
movl %eax, -0x38(%rbp)
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x20d0
movl $0x0, -0x54(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x60(%rbp)
movq -0x18(%rbp), %rax
movl 0x78(%rax), %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x7c(%rcx), %eax
jge 0x1c795
movq -0x18(%rbp), %rax
movl 0x70(%rax), %eax
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x74(%rcx), %eax
jge 0x1c785
movq -0x18(%rbp), %rax
movl 0x68(%rax), %eax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x6c(%rcx), %eax
jge 0x1c775
movl -0x64(%rbp), %edi
movl -0x68(%rbp), %esi
movl -0x6c(%rbp), %edx
movq -0x18(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x18(%rbp), %rax
movl 0xc(%rax), %r8d
callq 0x9500
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
movslq -0x34(%rbp), %rcx
imulq $0x88, %rcx, %rcx
addq %rcx, %rax
addq $0x10, %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movslq -0x34(%rbp), %rcx
imulq $0x88, %rcx, %rcx
addq %rcx, %rax
addq $0x10, %rax
addq $0x28, %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movsd (%rax), %xmm0
movq -0x30(%rbp), %rax
subsd (%rax), %xmm0
movaps 0x7e5a(%rip), %xmm1     # 0x24570
pand %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x50(%rbp), %xmm0
movsd -0x60(%rbp), %xmm1
callq 0x9710
movsd %xmm0, -0x50(%rbp)
movsd -0x48(%rbp), %xmm0
addsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x40(%rbp), %xmm1
movsd -0x60(%rbp), %xmm0
movsd -0x60(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x1c697
jmp 0x1c777
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x1c67d
jmp 0x1c787
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x1c663
movsd -0x48(%rbp), %xmm0
cvtsi2sdl -0x54(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x40(%rbp), %xmm0
cvtsi2sdl -0x54(%rbp), %xmm1
divsd %xmm1, %xmm0
callq 0x2200
movsd %xmm0, -0x40(%rbp)
movq -0x10(%rbp), %rdi
leaq 0xc988(%rip), %rsi      # 0x29153
movb $0x0, %al
callq 0x2140
movq -0x10(%rbp), %rdi
movl -0x38(%rbp), %edx
movsd -0x48(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
movsd -0x50(%rbp), %xmm2
leaq 0xc988(%rip), %rsi      # 0x29177
movb $0x3, %al
callq 0x2140
movq -0x10(%rbp), %rdi
callq 0x2080
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)