// File: /workspace/github_c_makefile_star2_O2/mohuangrui[P]ArtraCFD/stl.c
// Function: WriteStlFile
void WriteStlFile(const char *fname, const Polyhedron *poly)
{
    StlStr header = "binary stl";
    StlLint facetN = 0;
    StlInt attribute = 0;
    StlReal facetData = 0.0;
    FILE *fp = Fopen(fname, "wb");
    fwrite(header, sizeof(StlStr), 1, fp);
    facetN = poly->faceN;
    fwrite(&facetN, sizeof(StlLint), 1, fp);
    for (StlLint n = 0; n < facetN; ++n) {
        facetData = poly->facet[n].N[X];
        fwrite(&facetData, sizeof(StlReal), 1, fp);
        facetData = poly->facet[n].N[Y];
        fwrite(&facetData, sizeof(StlReal), 1, fp);
        facetData = poly->facet[n].N[Z];
        fwrite(&facetData, sizeof(StlReal), 1, fp);
        facetData = poly->facet[n].v0[X];
        fwrite(&facetData, sizeof(StlReal), 1, fp);
        facetData = poly->facet[n].v0[Y];
        fwrite(&facetData, sizeof(StlReal), 1, fp);
        facetData = poly->facet[n].v0[Z];
        fwrite(&facetData, sizeof(StlReal), 1, fp);
        facetData = poly->facet[n].v1[X];
        fwrite(&facetData, sizeof(StlReal), 1, fp);
        facetData = poly->facet[n].v1[Y];
        fwrite(&facetData, sizeof(StlReal), 1, fp);
        facetData = poly->facet[n].v1[Z];
        fwrite(&facetData, sizeof(StlReal), 1, fp);
        facetData = poly->facet[n].v2[X];
        fwrite(&facetData, sizeof(StlReal), 1, fp);
        facetData = poly->facet[n].v2[Y];
        fwrite(&facetData, sizeof(StlReal), 1, fp);
        facetData = poly->facet[n].v2[Z];
        fwrite(&facetData, sizeof(StlReal), 1, fp);
        fwrite(&attribute, sizeof(StlInt), 1, fp);
    }
    fclose(fp);
    return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %rbx
movq %rdi, %rax
leaq 0x7af3(%rip), %rsi      # 0x1eee0
pushq $0xa
popq %rcx
leaq 0x20(%rsp), %r14
movq %r14, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x6(%rsp), %rcx
andw $0x0, (%rcx)
leaq 0x5bd0(%rip), %rsi      # 0x1cfdb
movq %rax, %rdi
callq 0x8820
movq %rax, %r15
pushq $0x50
popq %rsi
pushq $0x1
popq %r12
movq %r14, %rdi
movq %r12, %rdx
movq %rax, %rcx
callq 0x2210
movl (%rbx), %eax
leaq 0x1c(%rsp), %r14
movl %eax, (%r14)
pushq $0x4
popq %r13
movq %r14, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x2210
movl (%r14), %eax
movq %rax, 0x8(%rsp)
xorl %r14d, %r14d
movq %rsp, %rbp
xorl %eax, %eax
cmpq 0x8(%rsp), %rax
jae 0x1763d
movq %rax, 0x10(%rsp)
movq 0x230(%rbx), %rax
cvtsd2ss (%rax,%r14), %xmm0
movss %xmm0, (%rsp)
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x2210
movq 0x230(%rbx), %rax
cvtsd2ss 0x8(%rax,%r14), %xmm0
movss %xmm0, (%rsp)
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x2210
movq 0x230(%rbx), %rax
cvtsd2ss 0x10(%rax,%r14), %xmm0
movss %xmm0, (%rsp)
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x2210
movq 0x230(%rbx), %rax
cvtsd2ss 0x18(%rax,%r14), %xmm0
movss %xmm0, (%rsp)
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x2210
movq 0x230(%rbx), %rax
cvtsd2ss 0x20(%rax,%r14), %xmm0
movss %xmm0, (%rsp)
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x2210
movq 0x230(%rbx), %rax
cvtsd2ss 0x28(%rax,%r14), %xmm0
movss %xmm0, (%rsp)
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x2210
movq 0x230(%rbx), %rax
cvtsd2ss 0x30(%rax,%r14), %xmm0
movss %xmm0, (%rsp)
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x2210
movq 0x230(%rbx), %rax
cvtsd2ss 0x38(%rax,%r14), %xmm0
movss %xmm0, (%rsp)
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x2210
movq 0x230(%rbx), %rax
cvtsd2ss 0x40(%rax,%r14), %xmm0
movss %xmm0, (%rsp)
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x2210
movq 0x230(%rbx), %rax
cvtsd2ss 0x48(%rax,%r14), %xmm0
movss %xmm0, (%rsp)
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x2210
movq 0x230(%rbx), %rax
cvtsd2ss 0x50(%rax,%r14), %xmm0
movss %xmm0, (%rsp)
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x2210
movq 0x230(%rbx), %rax
cvtsd2ss 0x58(%rax,%r14), %xmm0
movss %xmm0, (%rsp)
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x2210
leaq 0x6(%rsp), %rdi
pushq $0x2
popq %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x2210
movq 0x10(%rsp), %rax
incq %rax
addq $0x60, %r14
jmp 0x1745a
movq %r15, %rdi
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2080
nop