// File: /workspace/github_c_makefile_star2_O1/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 0xe73f(%rip), %rdx      # 0x1e3c4
movl $0x50, %esi
movq %r14, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x20b0
leaq 0xd08a(%rip), %rsi      # 0x1cd28
movq %r14, 0x8(%rsp)
movq %r14, %rdi
callq 0x9269
movq %rax, %r13
leaq 0xf1f1(%rip), %rdi      # 0x1eea6
movl $0x7, %esi
movl $0x1, %edx
movq %rax, %rcx
callq 0x2200
leaq 0xf1e0(%rip), %rdi      # 0x1eeae
movl $0x13, %esi
movl $0x1, %edx
movq %r13, %rcx
callq 0x2200
movl $0xa, %edi
movq %r13, %rsi
callq 0x2100
leaq 0xf1ce(%rip), %rdi      # 0x1eec2
movl $0x9, %esi
movl $0x1, %edx
movq %r13, %rcx
callq 0x2200
cmpb $0x0, 0x190(%r15)
je 0xfd1f
leaq 0xf299(%rip), %rsi      # 0x1efb0
movq %r13, %rdi
movq %r12, %rdx
jmp 0xfd2c
leaq 0xf28a(%rip), %rsi      # 0x1efb0
movq %r13, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2150
movl $0xa, %edi
movq %r13, %rsi
callq 0x2100
leaq 0xf196(%rip), %rdi      # 0x1eedd
movl $0x9, %esi
movl $0x1, %edx
movq %r13, %rcx
callq 0x2200
movsd 0x48(%rbx), %xmm0
leaq 0xf25a(%rip), %rsi      # 0x1efbf
movq %r13, %rdi
movb $0x1, %al
callq 0x2150
movq %rbx, 0x10(%rsp)
movl 0x8(%rbx), %edx
leaq 0xf261(%rip), %rsi      # 0x1efdf
movq %r13, %rdi
xorl %eax, %eax
callq 0x2150
cmpl $0x0, 0x288(%r15)
jle 0xfdcb
leaq 0x28c(%r15), %rbp
leaq 0xf25d(%rip), %r14      # 0x1effd
xorl %ebx, %ebx
movq %r13, %rdi
movq %r14, %rsi
movq %rbp, %rdx
movq %r12, %rcx
movq %rbp, %r8
xorl %eax, %eax
callq 0x2150
incq %rbx
movslq 0x288(%r15), %rax
addq $0xa, %rbp
cmpq %rax, %rbx
jl 0xfda2
cmpl $0x0, 0x2f0(%r15)
jle 0xfe0e
leaq 0x2f4(%r15), %rbp
leaq 0xf23b(%rip), %r14      # 0x1f01e
xorl %ebx, %ebx
movq %r13, %rdi
movq %r14, %rsi
movq %rbp, %rdx
movq %r12, %rcx
movq %rbp, %r8
xorl %eax, %eax
callq 0x2150
incq %rbx
movslq 0x2f0(%r15), %rax
addq $0xa, %rbp
cmpq %rax, %rbx
jl 0xfde5
movl $0xa, %edi
movq %r13, %rsi
callq 0x2100
movq %r13, %rdi
callq 0x2080
leaq 0xe59a(%rip), %rdx      # 0x1e3c4
movl $0x50, %esi
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x20b0
leaq 0xf1f7(%rip), %rsi      # 0x1f03f
movq %rbx, %rdi
callq 0x9269
movq %rax, %r14
leaq 0xf1e8(%rip), %rsi      # 0x1f042
movq %rax, %rdi
callq 0x9150
movq 0x10(%rsp), %rbx
movl 0x38(%rbx), %edx
incl %edx
leaq 0xf1db(%rip), %rsi      # 0x1f04e
movq %r14, %rdi
xorl %eax, %eax
callq 0x2150
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 0xfeac
movl $0xa, %edi
movq %r14, %rsi
callq 0x2100
movsd 0x48(%rbx), %xmm0
leaq 0x109aa(%rip), %rsi     # 0x20862
movq %r14, %rdi
movb $0x1, %al
callq 0x2150
movq %r14, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2080