// File: /workspace/github_c_makefile_star2_O0/mohuangrui[P]ArtraCFD/ensight_writer.c
// Function: WriteStructuredData
static void WriteStructuredData(const Space *space, const Model *model, EnSet *enSet)
{
    FILE *fp = NULL;
    EnReal data = 0.0; /* the Ensight data format */
    const Partition *const part = &(space->part);
    const Node *const node = space->node;
    const Real *restrict U = NULL;
    int idx = 0; /* linear array index math variable */
    for (int s = 0; s < enSet->scaN; ++s) {
        snprintf(enSet->fname, sizeof(EnStr), "%s.%s", enSet->bname, enSet->sca[s]);
        fp = Fopen(enSet->fname, "wb");
        /* first line description per file */
        strncpy(enSet->str, "scalar variable", sizeof(EnStr));
        fwrite(enSet->str, sizeof(EnStr), 1, fp);
        for (int p = enSet->part[MIN], pnum = 1; p < enSet->part[MAX]; ++p, ++pnum) {
            /* binary file format */
            strncpy(enSet->str, "part", sizeof(EnStr));
            fwrite(enSet->str, sizeof(EnStr), 1, fp);
            fwrite(&pnum, sizeof(int), 1, fp);
            strncpy(enSet->str, enSet->dtype, sizeof(EnStr));
            fwrite(enSet->str, sizeof(EnStr), 1, fp);
            /* now output the scalar value at each node in current part */
            for (int k = part->ns[p][Z][MIN]; k < part->ns[p][Z][MAX]; ++k) {
                for (int j = part->ns[p][Y][MIN]; j < part->ns[p][Y][MAX]; ++j) {
                    for (int i = part->ns[p][X][MIN]; i < part->ns[p][X][MAX]; ++i) {
                        idx = IndexNode(k, j, i, part->n[Y], part->n[X]);
                        U = node[idx].U[TO];
                        switch (s) {
                            case 0: /* rho */
                                data = U[0];
                                break;
                            case 1: /* u */
                                data = U[1] / U[0];
                                break;
                            case 2: /* v */
                                data = U[2] / U[0];
                                break;
                            case 3: /* w */
                                data = U[3] / U[0];
                                break;
                            case 4: /* p */
                                data = ComputePressure(model->gamma, U);
                                break;
                            case 5: /* T */
                                data = ComputeTemperature(model->cv, U);
                                break;
                            case 6: /* node flag */
                                data = node[idx].did;
                                break;
                            default:
                                break;
                        }
                        fwrite(&data, sizeof(EnReal), 1, fp);
                    }
                }
            }
        }
        fclose(fp);
    }
    for (int s = 0; s < enSet->vecN; ++s) {
        snprintf(enSet->fname, sizeof(EnStr), "%s.%s", enSet->bname, enSet->vec[s]);
        fp = Fopen(enSet->fname, "wb");
        /* binary file format */
        strncpy(enSet->str, "vector variable", sizeof(EnStr));
        fwrite(enSet->str, sizeof(EnStr), 1, fp);
        for (int p = enSet->part[MIN], pnum = 1; p < enSet->part[MAX]; ++p, ++pnum) {
            strncpy(enSet->str, "part", sizeof(EnStr));
            fwrite(enSet->str, sizeof(EnStr), 1, fp);
            fwrite(&pnum, sizeof(int), 1, fp);
            strncpy(enSet->str, enSet->dtype, sizeof(EnStr));
            fwrite(enSet->str, sizeof(EnStr), 1, fp);
            for (int n = 1; n < 4; ++n) {
                for (int k = part->ns[p][Z][MIN]; k < part->ns[p][Z][MAX]; ++k) {
                    for (int j = part->ns[p][Y][MIN]; j < part->ns[p][Y][MAX]; ++j) {
                        for (int i = part->ns[p][X][MIN]; i < part->ns[p][X][MAX]; ++i) {
                            idx = IndexNode(k, j, i, part->n[Y], part->n[X]);
                            U = node[idx].U[TO];
                            data = U[n] / U[0];
                            fwrite(&data, sizeof(EnReal), 1, fp);
                        }
                    }
                }
            }
        }
        fclose(fp);
    }
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x24(%rbp)
movq -0x8(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x288(%rcx), %eax
jge 0x1697d
movq -0x18(%rbp), %rdi
addq $0xa0, %rdi
movq -0x18(%rbp), %rcx
addq $0x50, %rcx
movq -0x18(%rbp), %r8
addq $0x28c, %r8             # imm = 0x28C
movslq -0x48(%rbp), %rax
imulq $0xa, %rax, %rax
addq %rax, %r8
movl $0x50, %esi
leaq 0x11ef8(%rip), %rdx     # 0x28524
movb $0x0, %al
callq 0x20b0
movq -0x18(%rbp), %rdi
addq $0xa0, %rdi
leaq 0x12824(%rip), %rsi     # 0x28e69
callq 0xbf90
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
addq $0xf0, %rdi
leaq 0x12867(%rip), %rsi     # 0x28ec7
movl $0x50, %edx
callq 0x2040
movq -0x18(%rbp), %rdi
addq $0xf0, %rdi
movq -0x20(%rbp), %rcx
movl $0x50, %esi
movl $0x1, %edx
callq 0x21f0
movq -0x18(%rbp), %rax
movl 0x280(%rax), %eax
movl %eax, -0x4c(%rbp)
movl $0x1, -0x50(%rbp)
movl -0x4c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x284(%rcx), %eax
jge 0x16966
movq -0x18(%rbp), %rdi
addq $0xf0, %rdi
leaq 0x127f9(%rip), %rsi     # 0x28eba
movl $0x50, %edx
callq 0x2040
movq -0x18(%rbp), %rdi
addq $0xf0, %rdi
movq -0x20(%rbp), %rcx
movl $0x50, %esi
movl $0x1, %edx
callq 0x21f0
movq -0x20(%rbp), %rcx
leaq -0x50(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x21f0
movq -0x18(%rbp), %rdi
addq $0xf0, %rdi
movq -0x18(%rbp), %rsi
addq $0x230, %rsi            # imm = 0x230
movl $0x50, %edx
callq 0x2040
movq -0x18(%rbp), %rdi
addq $0xf0, %rdi
movq -0x20(%rbp), %rcx
movl $0x50, %esi
movl $0x1, %edx
callq 0x21f0
movq -0x30(%rbp), %rax
addq $0x68, %rax
movslq -0x4c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
movq -0x30(%rbp), %rcx
addq $0x68, %rcx
movslq -0x4c(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x14(%rcx), %eax
jge 0x1694d
movq -0x30(%rbp), %rax
addq $0x68, %rax
movslq -0x4c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
movq -0x30(%rbp), %rcx
addq $0x68, %rcx
movslq -0x4c(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0xc(%rcx), %eax
jge 0x1693d
movq -0x30(%rbp), %rax
addq $0x68, %rax
movslq -0x4c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movq -0x30(%rbp), %rcx
addq $0x68, %rcx
movslq -0x4c(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
jge 0x1692d
movl -0x54(%rbp), %edi
movl -0x58(%rbp), %esi
movl -0x5c(%rbp), %edx
movq -0x30(%rbp), %rax
movl 0xc(%rax), %r8d
movl 0x10(%rax), %ecx
callq 0x9500
movl %eax, -0x44(%rbp)
movq -0x38(%rbp), %rax
movslq -0x44(%rbp), %rdx
movq %rdx, %rcx
shlq $0x7, %rcx
leaq (%rcx,%rdx,8), %rcx
leaq 0x10(%rax,%rcx), %rax
movq %rax, -0x40(%rbp)
movl -0x48(%rbp), %eax
movq %rax, -0x80(%rbp)
subq $0x6, %rax
ja 0x16906
movq -0x80(%rbp), %rax
leaq 0x11d0f(%rip), %rcx     # 0x28548
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x40(%rbp), %rax
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x24(%rbp)
jmp 0x16908
movq -0x40(%rbp), %rax
movsd 0x8(%rax), %xmm0
movq -0x40(%rbp), %rax
divsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x24(%rbp)
jmp 0x16908
movq -0x40(%rbp), %rax
movsd 0x10(%rax), %xmm0
movq -0x40(%rbp), %rax
divsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x24(%rbp)
jmp 0x16908
movq -0x40(%rbp), %rax
movsd 0x18(%rax), %xmm0
movq -0x40(%rbp), %rax
divsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x24(%rbp)
jmp 0x16908
movq -0x10(%rbp), %rax
movsd 0x40(%rax), %xmm0
movq -0x40(%rbp), %rdi
callq 0x9160
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x24(%rbp)
jmp 0x16908
movq -0x10(%rbp), %rax
movsd 0x50(%rax), %xmm0
movq -0x40(%rbp), %rdi
callq 0x9370
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x24(%rbp)
jmp 0x16908
movq -0x38(%rbp), %rax
movslq -0x44(%rbp), %rcx
imulq $0x88, %rcx, %rcx
addq %rcx, %rax
cvtsi2ssl (%rax), %xmm0
movss %xmm0, -0x24(%rbp)
jmp 0x16908
jmp 0x16908
movq -0x20(%rbp), %rcx
leaq -0x24(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x21f0
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x167c6
jmp 0x1692f
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x1678f
jmp 0x1693f
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x16757
jmp 0x1694f
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x1669c
movq -0x20(%rbp), %rdi
callq 0x2080
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x165e4
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x2f0(%rcx), %eax
jge 0x16c6f
movq -0x18(%rbp), %rdi
addq $0xa0, %rdi
movq -0x18(%rbp), %rcx
addq $0x50, %rcx
movq -0x18(%rbp), %r8
addq $0x2f4, %r8             # imm = 0x2F4
movslq -0x60(%rbp), %rax
imulq $0xa, %rax, %rax
addq %rax, %r8
movl $0x50, %esi
leaq 0x11b58(%rip), %rdx     # 0x28524
movb $0x0, %al
callq 0x20b0
movq -0x18(%rbp), %rdi
addq $0xa0, %rdi
leaq 0x12484(%rip), %rsi     # 0x28e69
callq 0xbf90
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
addq $0xf0, %rdi
leaq 0x124d7(%rip), %rsi     # 0x28ed7
movl $0x50, %edx
callq 0x2040
movq -0x18(%rbp), %rdi
addq $0xf0, %rdi
movq -0x20(%rbp), %rcx
movl $0x50, %esi
movl $0x1, %edx
callq 0x21f0
movq -0x18(%rbp), %rax
movl 0x280(%rax), %eax
movl %eax, -0x64(%rbp)
movl $0x1, -0x68(%rbp)
movl -0x64(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x284(%rcx), %eax
jge 0x16c58
movq -0x18(%rbp), %rdi
addq $0xf0, %rdi
leaq 0x12459(%rip), %rsi     # 0x28eba
movl $0x50, %edx
callq 0x2040
movq -0x18(%rbp), %rdi
addq $0xf0, %rdi
movq -0x20(%rbp), %rcx
movl $0x50, %esi
movl $0x1, %edx
callq 0x21f0
movq -0x20(%rbp), %rcx
leaq -0x68(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x21f0
movq -0x18(%rbp), %rdi
addq $0xf0, %rdi
movq -0x18(%rbp), %rsi
addq $0x230, %rsi            # imm = 0x230
movl $0x50, %edx
callq 0x2040
movq -0x18(%rbp), %rdi
addq $0xf0, %rdi
movq -0x20(%rbp), %rcx
movl $0x50, %esi
movl $0x1, %edx
callq 0x21f0
movl $0x1, -0x6c(%rbp)
cmpl $0x4, -0x6c(%rbp)
jge 0x16c3f
movq -0x30(%rbp), %rax
addq $0x68, %rax
movslq -0x64(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %eax
movq -0x30(%rbp), %rcx
addq $0x68, %rcx
movslq -0x64(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x14(%rcx), %eax
jge 0x16c2f
movq -0x30(%rbp), %rax
addq $0x68, %rax
movslq -0x64(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
movq -0x30(%rbp), %rcx
addq $0x68, %rcx
movslq -0x64(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0xc(%rcx), %eax
jge 0x16c1f
movq -0x30(%rbp), %rax
addq $0x68, %rax
movslq -0x64(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x78(%rbp)
movl -0x78(%rbp), %eax
movq -0x30(%rbp), %rcx
addq $0x68, %rcx
movslq -0x64(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
jge 0x16c0f
movl -0x70(%rbp), %edi
movl -0x74(%rbp), %esi
movl -0x78(%rbp), %edx
movq -0x30(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x30(%rbp), %rax
movl 0xc(%rax), %r8d
callq 0x9500
movl %eax, -0x44(%rbp)
movq -0x38(%rbp), %rax
movslq -0x44(%rbp), %rcx
imulq $0x88, %rcx, %rcx
addq %rcx, %rax
addq $0x10, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movslq -0x6c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x40(%rbp), %rax
divsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x24(%rbp)
movq -0x20(%rbp), %rcx
leaq -0x24(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x21f0
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x16b77
jmp 0x16c11
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x16b40
jmp 0x16c21
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x16b08
jmp 0x16c31
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x16ae5
jmp 0x16c41
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x16a3c
movq -0x20(%rbp), %rdi
callq 0x2080
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x16984
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)