// File: /workspace/github_c_makefile_star2_O0/mohuangrui[P]ArtraCFD/ensight_writer.c
// Function: WritePolygonPolyData
static void WritePolygonPolyData(const int pm, const int pn, const Geometry *const geo, EnSet *enSet)
{
    snprintf(enSet->fname, sizeof(EnStr), "%s.geo", enSet->bname);
    FILE *fp = Fopen(enSet->fname, "wb");
    EnReal data = 0.0; /* the Ensight data format */
    const Polyhedron *poly = NULL;
    int ne = 0; /* total number of nodes in a 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) {
        poly = geo->poly + p;
        strncpy(enSet->str, "part", sizeof(EnStr));
        fwrite(enSet->str, sizeof(EnStr), 1, fp);
        fwrite(&pnum, sizeof(int), 1, fp);
        snprintf(enSet->str, sizeof(EnStr), "%d %d %d",
                poly->vertN, poly->edgeN, poly->faceN);
        fwrite(enSet->str, sizeof(EnStr), 1, fp);
        strncpy(enSet->str, enSet->dtype, sizeof(EnStr));
        fwrite(enSet->str, sizeof(EnStr), 1, fp);
        ne = poly->vertN;
        fwrite(&ne, sizeof(int), 1, fp);
        for (int s = 0; s < DIMS; ++s) {
            for (int n = 0; n < poly->vertN; ++n) {
                data = poly->v[n][s];
                fwrite(&data, sizeof(EnReal), 1, fp);
            }
        }
        strncpy(enSet->str, "tria3", sizeof(EnStr));
        fwrite(enSet->str, sizeof(EnStr), 1, fp);
        ne = poly->faceN;
        fwrite(&ne, sizeof(int), 1, fp);
        for (int n = 0, m = 0; n < poly->faceN; ++n) {
            for (int s = 0; s < POLYN; ++s) {
                m = poly->f[n][s] + 1;
                fwrite(&m, sizeof(int), 1, fp);
            }
        }
    }
    fclose(fp);
    WritePolyState(pm, pn, geo, enSet);
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq -0x18(%rbp), %rdi
addq $0xa0, %rdi
movq -0x18(%rbp), %rcx
addq $0x50, %rcx
movl $0x50, %esi
leaq 0x10ca1(%rip), %rdx     # 0x28536
movb $0x0, %al
callq 0x20b0
movq -0x18(%rbp), %rdi
addq $0xa0, %rdi
leaq 0x115bb(%rip), %rsi     # 0x28e69
callq 0xbf90
movq %rax, -0x20(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x24(%rbp)
movq $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x18(%rbp), %rdi
addq $0xf0, %rdi
leaq 0x1158c(%rip), %rsi     # 0x28e6c
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), %rdi
addq $0xf0, %rdi
leaq 0x1155b(%rip), %rsi     # 0x28e75
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), %rdi
addq $0xf0, %rdi
leaq 0x11537(%rip), %rsi     # 0x28e8b
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), %rdi
addq $0xf0, %rdi
leaq 0x11511(%rip), %rsi     # 0x28e9f
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), %rdi
addq $0xf0, %rdi
leaq 0x114e3(%rip), %rsi     # 0x28eab
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, -0x38(%rbp)
movl $0x1, -0x3c(%rbp)
movl -0x38(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x284(%rcx), %eax
jge 0x17c95
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x38(%rbp), %rcx
imulq $0x238, %rcx, %rcx      # imm = 0x238
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
addq $0xf0, %rdi
leaq 0x11477(%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 -0x3c(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x21f0
movq -0x18(%rbp), %rdi
addq $0xf0, %rdi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x30(%rbp), %rax
movl 0x4(%rax), %r8d
movq -0x30(%rbp), %rax
movl (%rax), %r9d
movl $0x50, %esi
leaq 0x10a8e(%rip), %rdx     # 0x2853d
movb $0x0, %al
callq 0x20b0
movq -0x18(%rbp), %rdi
addq $0xf0, %rdi
movq -0x20(%rbp), %rcx
movl $0x50, %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
movl 0x8(%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rcx
leaq -0x34(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x21f0
movl $0x0, -0x40(%rbp)
cmpl $0x3, -0x40(%rbp)
jge 0x17baa
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x17b9d
movq -0x30(%rbp), %rax
movq 0x220(%rax), %rax
movslq -0x44(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %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 -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x17b47
jmp 0x17b9f
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x17b3a
movq -0x18(%rbp), %rdi
addq $0xf0, %rdi
leaq 0x11331(%rip), %rsi     # 0x28eed
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
movl (%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rcx
leaq -0x34(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x21f0
movl $0x0, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x48(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x17c7c
movl $0x0, -0x50(%rbp)
cmpl $0x3, -0x50(%rbp)
jge 0x17c6f
movq -0x30(%rbp), %rax
movq 0x200(%rax), %rax
movslq -0x48(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movslq -0x50(%rbp), %rcx
movl (%rax,%rcx,4), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movq -0x20(%rbp), %rcx
leaq -0x4c(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x21f0
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x17c24
jmp 0x17c71
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x17c12
jmp 0x17c7e
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x17a04
movq -0x20(%rbp), %rdi
callq 0x2080
movl -0x4(%rbp), %edi
movl -0x8(%rbp), %esi
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0x177e0
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)