// File: /workspace/github_cpp_makefile_star2_O3/dacunni[P]stlloader/./stlloader.h
// Function: stlloader::write_stream(std::ostream&, stlloader::Mesh const&, stlloader::Format)
void write_stream(std::ostream & os, const Mesh & mesh, Format format)
{
    switch(format) {
        case Format::ascii:
            {
                std::string solid_name = mesh.name;
                if(solid_name.size() == 0) solid_name = mesh.header;
                if(solid_name.size() == 0) solid_name = "stlloader";
                os << "solid " << solid_name << '\n';
                for(auto & facet : mesh.facets) {
                    os << "facet " << "normal " << facet.normal << '\n';
                    os << "outer loop\n";
                    for(int vi = 0; vi < 3; ++vi) {
                        os << "vertex " << facet.vertices[vi] << '\n';
                    }
                    os << "endloop\n";
                    os << "endfacet\n";
                }
                os << "endsolid " << solid_name << '\n';
            }
            break;
        case Format::binary:
            {
                std::string padded_header = mesh.header;
                if(padded_header.size() == 0) padded_header = mesh.name;
                if(padded_header.size() == 0) padded_header = "stlloader";
                padded_header.resize(STL_BINARY_HDR_SIZE, '\0');
                os << padded_header;
                write_binary_value<uint32_t>(os, mesh.facets.size());
                for(auto & facet : mesh.facets) {
                    write_binary_value(os, facet.normal);
                    for(int vi = 0; vi < 3; ++vi) {
                        write_binary_value(os, facet.vertices[vi]);
                    }
                    write_binary_value(os, uint16_t(0));
                }
            }
            break;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movq %rdi, %rbx
cmpl $0x1, %edx
je 0x383a
testl %edx, %edx
jne 0x3943
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x18(%r14), %rsi
movq 0x20(%r14), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x3d14
cmpq $0x0, 0x8(%r15)
jne 0x36c0
leaq 0x38(%r14), %rsi
leaq 0x8(%rsp), %rdi
callq 0x20f0
cmpq $0x0, 0x10(%rsp)
jne 0x36c0
leaq 0x9cf(%rip), %rcx       # 0x407b
leaq 0x8(%rsp), %rdi
movl $0x9, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x2290
leaq 0x9f7(%rip), %rsi       # 0x40be
movl $0x6, %edx
movq %rbx, %rdi
callq 0x2200
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x2200
leaq 0x4(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x2200
movq (%r14), %r13
movq 0x8(%r14), %r14
cmpq %r14, %r13
je 0x37e7
leaq 0x4(%rsp), %r12
leaq 0x989(%rip), %rbp       # 0x40a0
movl $0x6, %edx
movq %rbx, %rdi
leaq 0x95f(%rip), %rsi       # 0x4085
callq 0x2200
movl $0x7, %edx
movq %rbx, %rdi
leaq 0x952(%rip), %rsi       # 0x408c
callq 0x2200
leaq 0x24(%r13), %rsi
movq %rbx, %rdi
callq 0x34c5
movb $0xa, 0x4(%rsp)
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2200
movl $0xb, %edx
movq %rbx, %rdi
leaq 0x925(%rip), %rsi       # 0x4094
callq 0x2200
xorl %r15d, %r15d
movl $0x7, %edx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x2200
leaq (%r15,%r13), %rsi
movq %rbx, %rdi
callq 0x3462
movb $0xa, 0x4(%rsp)
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2200
addq $0xc, %r15
cmpq $0x24, %r15
jne 0x3777
movl $0x8, %edx
movq %rbx, %rdi
leaq 0x8e7(%rip), %rsi       # 0x40a8
callq 0x2200
movl $0x9, %edx
movq %rbx, %rdi
leaq 0x8dc(%rip), %rsi       # 0x40b1
callq 0x2200
addq $0x30, %r13
cmpq %r14, %r13
jne 0x3717
leaq 0x8cd(%rip), %rsi       # 0x40bb
movl $0x9, %edx
movq %rbx, %rdi
callq 0x2200
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x2200
leaq 0x4(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x2200
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
jne 0x3936
jmp 0x3943
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x38(%r14), %rsi
movq 0x40(%r14), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x3d14
cmpq $0x0, 0x8(%r15)
jne 0x3894
leaq 0x18(%r14), %rsi
leaq 0x8(%rsp), %rdi
callq 0x20f0
cmpq $0x0, 0x10(%rsp)
jne 0x3894
leaq 0x7fb(%rip), %rcx       # 0x407b
leaq 0x8(%rsp), %rdi
movl $0x9, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x2290
leaq 0x8(%rsp), %rdi
movl $0x50, %esi
xorl %edx, %edx
callq 0x2080
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x2200
movq 0x8(%r14), %rax
subq (%r14), %rax
shrq $0x4, %rax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
leaq 0x4(%rsp), %rsi
movl %eax, (%rsi)
movq %rbx, %rdi
callq 0x356c
movq (%r14), %r15
movq 0x8(%r14), %r13
cmpq %r13, %r15
je 0x392c
leaq 0x4(%rsp), %r14
leaq 0x24(%r15), %rsi
movq %rbx, %rdi
callq 0x3611
xorl %ebp, %ebp
leaq (%r15,%rbp), %rsi
movq %rbx, %rdi
callq 0x35e0
addq $0xc, %rbp
cmpq $0x24, %rbp
jne 0x38f6
movw $0x0, 0x4(%rsp)
movl $0x2, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2230
addq $0x30, %r15
cmpq %r13, %r15
jne 0x38e8
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x3943
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21b0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x395e
jmp 0x395e
jmp 0x396d
jmp 0x395e
jmp 0x395e
jmp 0x396d
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
jne 0x397f
jmp 0x398c
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x398c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21b0
movq %rbx, %rdi
callq 0x2320