// File: /workspace/github_c_makefile_star2_O3/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 0xdb4a(%rip), %rdx      # 0x1d454
movl $0x50, %esi
movq %r14, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x20b0
leaq 0xc405(%rip), %rsi      # 0x1bd28
movq %r14, 0x8(%rsp)
movq %r14, %rdi
callq 0x9026
movq %rax, %r13
leaq 0xe5fc(%rip), %rdi      # 0x1df36
movl $0x7, %esi
movl $0x1, %edx
movq %rax, %rcx
callq 0x2200
leaq 0xe5eb(%rip), %rdi      # 0x1df3e
movl $0x13, %esi
movl $0x1, %edx
movq %r13, %rcx
callq 0x2200
movl $0xa, %edi
movq %r13, %rsi
callq 0x2100
leaq 0xe5d9(%rip), %rdi      # 0x1df52
movl $0x9, %esi
movl $0x1, %edx
movq %r13, %rcx
callq 0x2200
cmpb $0x0, 0x190(%r15)
movq %r12, %rdx
cmoveq %r15, %rdx
leaq 0xe69f(%rip), %rsi      # 0x1e040
movq %r13, %rdi
xorl %eax, %eax
callq 0x2160
movl $0xa, %edi
movq %r13, %rsi
callq 0x2100
leaq 0xe5ae(%rip), %rdi      # 0x1df6d
movl $0x9, %esi
movl $0x1, %edx
movq %r13, %rcx
callq 0x2200
movsd 0x48(%rbx), %xmm0
leaq 0xe672(%rip), %rsi      # 0x1e04f
movq %r13, %rdi
movb $0x1, %al
callq 0x2160
movq %rbx, 0x10(%rsp)
movl 0x8(%rbx), %edx
leaq 0xe679(%rip), %rsi      # 0x1e06f
movq %r13, %rdi
xorl %eax, %eax
callq 0x2160
cmpl $0x0, 0x288(%r15)
jle 0xfa44
leaq 0x28c(%r15), %rbp
leaq 0xe675(%rip), %rbx      # 0x1e08d
xorl %r14d, %r14d
movq %r13, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movq %r12, %rcx
movq %rbp, %r8
xorl %eax, %eax
callq 0x2160
incq %r14
movslq 0x288(%r15), %rax
addq $0xa, %rbp
cmpq %rax, %r14
jl 0xfa1b
cmpl $0x0, 0x2f0(%r15)
jle 0xfa88
leaq 0x2f4(%r15), %rbp
leaq 0xe652(%rip), %rbx      # 0x1e0ae
xorl %r14d, %r14d
movq %r13, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movq %r12, %rcx
movq %rbp, %r8
xorl %eax, %eax
callq 0x2160
incq %r14
movslq 0x2f0(%r15), %rax
addq $0xa, %rbp
cmpq %rax, %r14
jl 0xfa5f
movl $0xa, %edi
movq %r13, %rsi
callq 0x2100
movq %r13, %rdi
callq 0x2080
leaq 0xd9b0(%rip), %rdx      # 0x1d454
movl $0x50, %esi
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x20b0
leaq 0xe60d(%rip), %rsi      # 0x1e0cf
movq %rbx, %rdi
callq 0x9026
movq %rax, %r14
leaq 0xe5fe(%rip), %rsi      # 0x1e0d2
movq %rax, %rdi
callq 0x8f0d
movq 0x10(%rsp), %rbx
movl 0x38(%rbx), %edx
incl %edx
leaq 0xe5f1(%rip), %rsi      # 0x1e0de
movq %r14, %rdi
xorl %eax, %eax
callq 0x2160
movq %r14, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2190
imull $0xcccccccd, 0x38(%rbx), %eax # imm = 0xCCCCCCCD
addl $0x19999999, %eax       # imm = 0x19999999
cmpl $0x33333333, %eax       # imm = 0x33333333
jae 0xfb26
movl $0xa, %edi
movq %r14, %rsi
callq 0x2100
movsd 0x48(%rbx), %xmm0
leaq 0xfdc0(%rip), %rsi      # 0x1f8f2
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