// File: /workspace/github_c_makefile_star2_O2/mohuangrui[P]ArtraCFD/ensight_writer.c
// Function: WriteCaseFile
static void WriteCaseFile(const Time *time, EnSet *enSet)
{
    snprintf(enSet->fname, sizeof(EnStr), "%s.case", enSet->bname);
    FILE *fp = Fopen(enSet->fname, "w");
    fprintf(fp, "FORMAT\n");
    fprintf(fp, "type: ensight gold\n");
    fprintf(fp, "\n");
    fprintf(fp, "GEOMETRY\n");
    if ('\0' == *enSet->gtag) {
        fprintf(fp, "model: %s.geo\n", enSet->rname);
    } else {
        fprintf(fp, "model: %s.geo\n", enSet->bname);
    }
    fprintf(fp, "\n");
    fprintf(fp, "VARIABLE\n");
    fprintf(fp, "constant per case:  Time  %.6g\n", time->now);
    fprintf(fp, "constant per case:  Step  %d\n", time->stepC);
    for (int n = 0; n < enSet->scaN; ++n) {
        fprintf(fp, "scalar per node:     %3s  %s.%s\n",
                enSet->sca[n], enSet->bname, enSet->sca[n]);
    }
    for (int n = 0; n < enSet->vecN; ++n) {
        fprintf(fp, "vector per node:     %3s  %s.%s\n",
                enSet->vec[n], enSet->bname, enSet->vec[n]);
    }
    fprintf(fp, "\n");
    fclose(fp);
    /* add case to the transient case file */
    snprintf(enSet->fname, sizeof(EnStr), "%s.case", enSet->rname);
    fp = Fopen(enSet->fname, "r+");
    /* seek the target line for adding information */
    ReadInLine(fp, "time set: 1");
    fprintf(fp, "number of steps:          %d", (time->dataC + 1));
    /* add the time flag of current export to the transient case */
    fseek(fp, 0, SEEK_END); /* seek to the end of file */
    if ((time->dataC % 5) == 0) { /* print to a new line every x outputs */
        fprintf(fp, "\n");
    }
    fprintf(fp, "%.6g ", time->now);
    fclose(fp);
    return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r15
movq %rdi, %rbx
leaq 0xa0(%rsi), %r14
leaq 0x50(%rsi), %r12
leaq 0xd542(%rip), %rdx      # 0x1c334
pushq $0x50
popq %rsi
movq %r14, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x20b0
leaq 0xbe0f(%rip), %rsi      # 0x1ac18
movq %r14, 0x8(%rsp)
movq %r14, %rdi
callq 0x8820
movq %rax, %r13
leaq 0xdff6(%rip), %rdi      # 0x1ce16
pushq $0x7
popq %rsi
pushq $0x1
popq %rbp
movq %rbp, %rdx
movq %rax, %rcx
callq 0x2210
leaq 0xdfe6(%rip), %rdi      # 0x1ce1e
pushq $0x13
popq %rsi
movq %rbp, %rdx
movq %r13, %rcx
callq 0x2210
pushq $0xa
popq %rdi
movq %r13, %rsi
callq 0x2100
leaq 0xdfda(%rip), %rdi      # 0x1ce32
pushq $0x9
popq %r14
movq %r14, %rsi
movq %rbp, %rdx
movq %r13, %rcx
callq 0x2210
cmpb $0x0, 0x190(%r15)
movq %r12, %rdx
cmoveq %r15, %rdx
leaq 0xe0a0(%rip), %rsi      # 0x1cf20
movq %r13, %rdi
xorl %eax, %eax
callq 0x2160
pushq $0xa
popq %rdi
movq %r13, %rsi
callq 0x2100
leaq 0xdfb1(%rip), %rdi      # 0x1ce4d
movq %r14, %rsi
movq %rbp, %rdx
movq %r13, %rcx
callq 0x2210
movsd 0x48(%rbx), %xmm0
leaq 0xe079(%rip), %rsi      # 0x1cf2f
movq %r13, %rdi
movb $0x1, %al
callq 0x2160
movq %rbx, 0x10(%rsp)
movl 0x8(%rbx), %edx
leaq 0xe080(%rip), %rsi      # 0x1cf4f
movq %r13, %rdi
xorl %eax, %eax
callq 0x2160
leaq 0x28c(%r15), %rbx
leaq 0xe086(%rip), %rbp      # 0x1cf6d
xorl %r14d, %r14d
movslq 0x288(%r15), %rax
cmpq %rax, %r14
jge 0xef15
movq %r13, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
movq %r12, %rcx
movq %rbx, %r8
xorl %eax, %eax
callq 0x2160
incq %r14
addq $0xa, %rbx
jmp 0xeeea
leaq 0x2f4(%r15), %rbp
leaq 0xe06b(%rip), %rbx      # 0x1cf8e
xorl %r14d, %r14d
movslq 0x2f0(%r15), %rax
cmpq %rax, %r14
jge 0xef51
movq %r13, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movq %r12, %rcx
movq %rbp, %r8
xorl %eax, %eax
callq 0x2160
incq %r14
addq $0xa, %rbp
jmp 0xef26
pushq $0xa
popq %rdi
movq %r13, %rsi
callq 0x2100
movq %r13, %rdi
callq 0x2080
leaq 0xd3c9(%rip), %rdx      # 0x1c334
pushq $0x50
popq %rsi
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x20b0
leaq 0xe028(%rip), %rsi      # 0x1cfaf
movq %rbx, %rdi
callq 0x8820
movq %rax, %r14
leaq 0xe019(%rip), %rsi      # 0x1cfb2
movq %rax, %rdi
callq 0x8730
movq 0x10(%rsp), %rbx
movl 0x38(%rbx), %edx
incl %edx
leaq 0xe00c(%rip), %rsi      # 0x1cfbe
movq %r14, %rdi
xorl %eax, %eax
callq 0x2160
pushq $0x2
popq %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x21a0
movl 0x38(%rbx), %eax
pushq $0x5
popq %rcx
cltd
idivl %ecx
testl %edx, %edx
jne 0xefe1
pushq $0xa
popq %rdi
movq %r14, %rsi
callq 0x2100
movsd 0x48(%rbx), %xmm0
leaq 0xf75d(%rip), %rsi      # 0x1e74a
movq %r14, %rdi
movb $0x1, %al
callq 0x2160
movq %r14, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2080