// File: /workspace/github_c_makefile_star2_O3/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 0x77f5(%rip), %rsi      # 0x20080
leaq 0x10(%rsp), %r15
movl $0xa, %ecx
movq %r15, %rdi
rep  movsq (%rsi), %es:(%rdi)
movw $0x0, 0xa(%rsp)
leaq 0x5852(%rip), %rsi      # 0x1e0fb
movq %rax, %rdi
callq 0x9026
movq %rax, %r14
movl $0x50, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %rax, %rcx
callq 0x2200
movl (%rbx), %eax
leaq 0xc(%rsp), %r15
movl %eax, (%r15)
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x2200
movl (%r15), %eax
testq %rax, %rax
je 0x18b2d
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 0x18908
movq %r14, %rdi
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2080
nop