// File: /workspace/github_c_makefile_star2_O1/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 $0x68, %rsp
movq %rsi, %rbx
movq %rdi, %rax
leaq 0x8355(%rip), %rsi      # 0x20fd0
leaq 0x10(%rsp), %r12
movl $0xa, %ecx
movq %r12, %rdi
rep  movsq (%rsi), %es:(%rdi)
xorl %ecx, %ecx
leaq 0xc(%rsp), %r15
movl %ecx, (%r15)
movw $0x0, 0xa(%rsp)
movl %ecx, 0x4(%rsp)
leaq 0x63c4(%rip), %rsi      # 0x1f06b
movq %rax, %rdi
callq 0x9269
movq %rax, %r14
movl $0x50, %esi
movl $0x1, %edx
movq %r12, %rdi
movq %rax, %rcx
callq 0x2200
movl (%rbx), %eax
movl %eax, (%r15)
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x2200
movl (%r15), %eax
testq %rax, %rax
je 0x18f26
shlq $0x5, %rax
leaq (%rax,%rax,2), %r13
xorl %ebp, %ebp
leaq 0x4(%rsp), %r15
leaq 0xa(%rsp), %r12
movq 0x230(%rbx), %rax
xorps %xmm0, %xmm0
cvtsd2ss (%rax,%rbp), %xmm0
movss %xmm0, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x2200
movq 0x230(%rbx), %rax
xorps %xmm0, %xmm0
cvtsd2ss 0x8(%rax,%rbp), %xmm0
movss %xmm0, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x2200
movq 0x230(%rbx), %rax
xorps %xmm0, %xmm0
cvtsd2ss 0x10(%rax,%rbp), %xmm0
movss %xmm0, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x2200
movq 0x230(%rbx), %rax
xorps %xmm0, %xmm0
cvtsd2ss 0x18(%rax,%rbp), %xmm0
movss %xmm0, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x2200
movq 0x230(%rbx), %rax
xorps %xmm0, %xmm0
cvtsd2ss 0x20(%rax,%rbp), %xmm0
movss %xmm0, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x2200
movq 0x230(%rbx), %rax
xorps %xmm0, %xmm0
cvtsd2ss 0x28(%rax,%rbp), %xmm0
movss %xmm0, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x2200
movq 0x230(%rbx), %rax
xorps %xmm0, %xmm0
cvtsd2ss 0x30(%rax,%rbp), %xmm0
movss %xmm0, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x2200
movq 0x230(%rbx), %rax
xorps %xmm0, %xmm0
cvtsd2ss 0x38(%rax,%rbp), %xmm0
movss %xmm0, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x2200
movq 0x230(%rbx), %rax
xorps %xmm0, %xmm0
cvtsd2ss 0x40(%rax,%rbp), %xmm0
movss %xmm0, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x2200
movq 0x230(%rbx), %rax
xorps %xmm0, %xmm0
cvtsd2ss 0x48(%rax,%rbp), %xmm0
movss %xmm0, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x2200
movq 0x230(%rbx), %rax
xorps %xmm0, %xmm0
cvtsd2ss 0x50(%rax,%rbp), %xmm0
movss %xmm0, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x2200
movq 0x230(%rbx), %rax
xorps %xmm0, %xmm0
cvtsd2ss 0x58(%rax,%rbp), %xmm0
movss %xmm0, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x2200
movl $0x2, %esi
movl $0x1, %edx
movq %r12, %rdi
movq %r14, %rcx
callq 0x2200
addq $0x60, %rbp
cmpq %rbp, %r13
jne 0x18d01
movq %r14, %rdi
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2080