// File: /workspace/github_c_makefile_star2_O0/mohuangrui[P]ArtraCFD/ensight_writer.c
// Function: WriteGeometryFile
static void WriteGeometryFile(const Space *space, EnSet *enSet)
{
    /*
     * Write the geometry file in Binary Form.
     * Maximums: maximum number of nodes in a part is 2GB.
     */
    snprintf(enSet->fname, sizeof(EnStr), "%s.geo", enSet->rname);
    FILE *fp = Fopen(enSet->fname, "wb");
    EnReal data = 0.0; /* the Ensight data format */
    const Partition *const part = &(space->part);
    IntVec ne = {0}; /* i, j, k node number in each part */
    /* description at the beginning */
    strncpy(enSet->str, "C Binary", sizeof(EnStr));
    fwrite(enSet->str, sizeof(EnStr), 1, fp);
    strncpy(enSet->str, "Ensight Geometry File", sizeof(EnStr));
    fwrite(enSet->str, sizeof(EnStr), 1, fp);
    strncpy(enSet->str, "Written by ArtraCFD", sizeof(EnStr));
    fwrite(enSet->str, sizeof(EnStr), 1, fp);
    /* node id and extents settings */
    strncpy(enSet->str, "node id off", sizeof(EnStr));
    fwrite(enSet->str, sizeof(EnStr), 1, fp);
    strncpy(enSet->str, "element id off", 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);
        snprintf(enSet->str, sizeof(EnStr), "part %d", p);
        fwrite(enSet->str, sizeof(EnStr), 1, fp);
        strncpy(enSet->str, enSet->dtype, sizeof(EnStr));
        fwrite(enSet->str, sizeof(EnStr), 1, fp);
        ne[X] = part->ns[p][X][MAX] - part->ns[p][X][MIN];
        ne[Y] = part->ns[p][Y][MAX] - part->ns[p][Y][MIN];
        ne[Z] = part->ns[p][Z][MAX] - part->ns[p][Z][MIN];
        fwrite(ne, sizeof(int), 3, fp);
        for (int s = 0; s < DIMS; ++s) {
            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) {
                        ne[X] = i; ne[Y] = j; ne[Z] = k;
                        data = MapPoint(ne[s], part->domain[s][MIN], part->d[s], part->ng[s]);
                        fwrite(&data, sizeof(EnReal), 1, fp);
                    }
                }
            }
        }
    }
    fclose(fp);
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
addq $0xa0, %rdi
movq -0x10(%rbp), %rcx
movl $0x50, %esi
leaq 0x1272b(%rip), %rdx     # 0x28536
movb $0x0, %al
callq 0x20b0
movq -0x10(%rbp), %rdi
addq $0xa0, %rdi
leaq 0x13045(%rip), %rsi     # 0x28e69
callq 0xbf90
movq %rax, -0x18(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x1c(%rbp)
movq -0x8(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x28(%rbp)
leaq -0x34(%rbp), %rdi
xorl %esi, %esi
movl $0xc, %edx
callq 0x20d0
movq -0x10(%rbp), %rdi
addq $0xf0, %rdi
leaq 0x13009(%rip), %rsi     # 0x28e6c
movl $0x50, %edx
callq 0x2040
movq -0x10(%rbp), %rdi
addq $0xf0, %rdi
movq -0x18(%rbp), %rcx
movl $0x50, %esi
movl $0x1, %edx
callq 0x21f0
movq -0x10(%rbp), %rdi
addq $0xf0, %rdi
leaq 0x12fd8(%rip), %rsi     # 0x28e75
movl $0x50, %edx
callq 0x2040
movq -0x10(%rbp), %rdi
addq $0xf0, %rdi
movq -0x18(%rbp), %rcx
movl $0x50, %esi
movl $0x1, %edx
callq 0x21f0
movq -0x10(%rbp), %rdi
addq $0xf0, %rdi
leaq 0x12fb4(%rip), %rsi     # 0x28e8b
movl $0x50, %edx
callq 0x2040
movq -0x10(%rbp), %rdi
addq $0xf0, %rdi
movq -0x18(%rbp), %rcx
movl $0x50, %esi
movl $0x1, %edx
callq 0x21f0
movq -0x10(%rbp), %rdi
addq $0xf0, %rdi
leaq 0x12f8e(%rip), %rsi     # 0x28e9f
movl $0x50, %edx
callq 0x2040
movq -0x10(%rbp), %rdi
addq $0xf0, %rdi
movq -0x18(%rbp), %rcx
movl $0x50, %esi
movl $0x1, %edx
callq 0x21f0
movq -0x10(%rbp), %rdi
addq $0xf0, %rdi
leaq 0x12f60(%rip), %rsi     # 0x28eab
movl $0x50, %edx
callq 0x2040
movq -0x10(%rbp), %rdi
addq $0xf0, %rdi
movq -0x18(%rbp), %rcx
movl $0x50, %esi
movl $0x1, %edx
callq 0x21f0
movq -0x10(%rbp), %rax
movl 0x280(%rax), %eax
movl %eax, -0x38(%rbp)
movl $0x1, -0x3c(%rbp)
movl -0x38(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x284(%rcx), %eax
jge 0x1628c
movq -0x10(%rbp), %rdi
addq $0xf0, %rdi
leaq 0x12f0e(%rip), %rsi     # 0x28eba
movl $0x50, %edx
callq 0x2040
movq -0x10(%rbp), %rdi
addq $0xf0, %rdi
movq -0x18(%rbp), %rcx
movl $0x50, %esi
movl $0x1, %edx
callq 0x21f0
movq -0x18(%rbp), %rcx
leaq -0x3c(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x21f0
movq -0x10(%rbp), %rdi
addq $0xf0, %rdi
movl -0x38(%rbp), %ecx
movl $0x50, %esi
leaq 0x12eba(%rip), %rdx     # 0x28ebf
movb $0x0, %al
callq 0x20b0
movq -0x10(%rbp), %rdi
addq $0xf0, %rdi
movq -0x18(%rbp), %rcx
movl $0x50, %esi
movl $0x1, %edx
callq 0x21f0
movq -0x10(%rbp), %rdi
addq $0xf0, %rdi
movq -0x10(%rbp), %rsi
addq $0x230, %rsi            # imm = 0x230
movl $0x50, %edx
callq 0x2040
movq -0x10(%rbp), %rdi
addq $0xf0, %rdi
movq -0x18(%rbp), %rcx
movl $0x50, %esi
movl $0x1, %edx
callq 0x21f0
movq -0x28(%rbp), %rax
addq $0x68, %rax
movslq -0x38(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movq -0x28(%rbp), %rcx
addq $0x68, %rcx
movslq -0x38(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
subl (%rcx), %eax
movl %eax, -0x34(%rbp)
movq -0x28(%rbp), %rax
addq $0x68, %rax
movslq -0x38(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movq -0x28(%rbp), %rcx
addq $0x68, %rcx
movslq -0x38(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
subl 0x8(%rcx), %eax
movl %eax, -0x30(%rbp)
movq -0x28(%rbp), %rax
addq $0x68, %rax
movslq -0x38(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movq -0x28(%rbp), %rcx
addq $0x68, %rcx
movslq -0x38(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
subl 0x10(%rcx), %eax
movl %eax, -0x2c(%rbp)
leaq -0x34(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl $0x4, %esi
movl $0x3, %edx
callq 0x21f0
movl $0x0, -0x40(%rbp)
cmpl $0x3, -0x40(%rbp)
jge 0x16273
movq -0x28(%rbp), %rax
addq $0x68, %rax
movslq -0x38(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x28(%rbp), %rcx
addq $0x68, %rcx
movslq -0x38(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x14(%rcx), %eax
jge 0x16263
movq -0x28(%rbp), %rax
addq $0x68, %rax
movslq -0x38(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movq -0x28(%rbp), %rcx
addq $0x68, %rcx
movslq -0x38(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0xc(%rcx), %eax
jge 0x16253
movq -0x28(%rbp), %rax
addq $0x68, %rax
movslq -0x38(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x28(%rbp), %rcx
addq $0x68, %rcx
movslq -0x38(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
jge 0x16243
movl -0x4c(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x2c(%rbp)
movslq -0x40(%rbp), %rax
movl -0x34(%rbp,%rax,4), %edi
movq -0x28(%rbp), %rax
addq $0x3c8, %rax            # imm = 0x3C8
movslq -0x40(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd 0x30(%rax,%rcx,8), %xmm1
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
movl 0x18(%rax,%rcx,4), %esi
callq 0x9690
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x1c(%rbp)
movq -0x18(%rbp), %rcx
leaq -0x1c(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x21f0
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x161a4
jmp 0x16245
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x1616d
jmp 0x16255
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x16135
jmp 0x16265
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x16112
jmp 0x16275
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x15f87
movq -0x18(%rbp), %rdi
callq 0x2080
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)