// File: /workspace/github_cpp_makefile_star2_O2/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 0x320e
testl %edx, %edx
jne 0x3307
leaq 0x18(%r14), %rsi
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x22a0
cmpq $0x0, 0x8(%r15)
jne 0x3132
leaq 0x38(%r14), %rsi
leaq 0x8(%rsp), %rdi
callq 0x2140
cmpq $0x0, 0x10(%rsp)
jne 0x3132
leaq 0xf53(%rip), %rsi       # 0x407b
leaq 0x8(%rsp), %rdi
callq 0x2360
leaq 0xf85(%rip), %rsi       # 0x40be
movq %rbx, %rdi
callq 0x21f0
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x21e0
pushq $0xa
popq %rsi
movq %rax, %rdi
callq 0x2240
movq (%r14), %r12
movq 0x8(%r14), %r13
pushq $0xa
popq %rbp
leaq 0xf36(%rip), %r15       # 0x40a0
cmpq %r13, %r12
je 0x32d6
movq %rbx, %rdi
leaq 0xf08(%rip), %rsi       # 0x4085
callq 0x21f0
movq %rax, %rdi
leaq 0xf00(%rip), %rsi       # 0x408c
callq 0x21f0
leaq 0x24(%r12), %rsi
movq %rax, %rdi
callq 0x2fb2
movq %rax, %rdi
movl %ebp, %esi
callq 0x2240
movq %rbx, %rdi
leaq 0xee2(%rip), %rsi       # 0x4094
callq 0x21f0
xorl %r14d, %r14d
cmpq $0x24, %r14
je 0x31e7
movq %rbx, %rdi
movq %r15, %rsi
callq 0x21f0
leaq (%r12,%r14), %rsi
movq %rax, %rdi
callq 0x2f6c
movq %rax, %rdi
movl %ebp, %esi
callq 0x2240
addq $0xc, %r14
jmp 0x31ba
movq %rbx, %rdi
leaq 0xeb7(%rip), %rsi       # 0x40a8
callq 0x21f0
movq %rbx, %rdi
leaq 0xeb1(%rip), %rsi       # 0x40b1
callq 0x21f0
addq $0x30, %r12
jmp 0x316a
leaq 0x38(%r14), %rsi
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x22a0
cmpq $0x0, 0x8(%r15)
jne 0x324d
leaq 0x18(%r14), %rsi
leaq 0x8(%rsp), %rdi
callq 0x2140
cmpq $0x0, 0x10(%rsp)
jne 0x324d
leaq 0xe38(%rip), %rsi       # 0x407b
leaq 0x8(%rsp), %rdi
callq 0x2360
leaq 0x8(%rsp), %rdi
pushq $0x50
popq %rsi
xorl %edx, %edx
callq 0x20b0
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x21e0
movq 0x8(%r14), %rax
subq (%r14), %rax
pushq $0x30
popq %rcx
cqto
idivq %rcx
leaq 0x4(%rsp), %rsi
movl %eax, (%rsi)
movq %rbx, %rdi
callq 0x301e
movq (%r14), %r15
movq 0x8(%r14), %r12
leaq 0x4(%rsp), %r14
cmpq %r12, %r15
je 0x32fd
leaq 0x24(%r15), %rsi
movq %rbx, %rdi
callq 0x309d
xorl %r13d, %r13d
cmpq $0x24, %r13
je 0x32bf
leaq (%r15,%r13), %rsi
movq %rbx, %rdi
callq 0x306c
addq $0xc, %r13
jmp 0x32a7
andw $0x0, 0x4(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3008
addq $0x30, %r15
jmp 0x3293
leaq 0xdde(%rip), %rsi       # 0x40bb
movq %rbx, %rdi
callq 0x21f0
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x21e0
pushq $0xa
popq %rsi
movq %rax, %rdi
callq 0x2240
leaq 0x8(%rsp), %rdi
callq 0x2100
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3324
jmp 0x3324
jmp 0x3324
jmp 0x3324
jmp 0x3324
jmp 0x3324
jmp 0x3324
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2100
movq %rbx, %rdi
callq 0x2340