// File: /workspace/github_cpp_makefile_star2_O1/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 0x3865
testl %edx, %edx
jne 0x3969
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 0x3d3a
cmpq $0x0, 0x8(%r15)
jne 0x36c8
leaq 0x38(%r14), %rsi
leaq 0x8(%rsp), %rdi
callq 0x20f0
movq 0x10(%rsp), %rdx
testq %rdx, %rdx
jne 0x36eb
leaq 0x9a2(%rip), %rcx       # 0x407b
leaq 0x8(%rsp), %rdi
movl $0x9, %r8d
xorl %esi, %esi
callq 0x2290
leaq 0x9cc(%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 0x3812
leaq 0x4(%rsp), %r12
leaq 0x95e(%rip), %rbp       # 0x40a0
movl $0x6, %edx
movq %rbx, %rdi
leaq 0x934(%rip), %rsi       # 0x4085
callq 0x2200
movl $0x7, %edx
movq %rbx, %rdi
leaq 0x927(%rip), %rsi       # 0x408c
callq 0x2200
leaq 0x24(%r13), %rsi
movq %rbx, %rdi
callq 0x34cb
movb $0xa, 0x4(%rsp)
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2200
movl $0xb, %edx
movq %rbx, %rdi
leaq 0x8fa(%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 0x3468
movb $0xa, 0x4(%rsp)
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2200
addq $0xc, %r15
cmpq $0x24, %r15
jne 0x37a2
movl $0x8, %edx
movq %rbx, %rdi
leaq 0x8bc(%rip), %rsi       # 0x40a8
callq 0x2200
movl $0x9, %edx
movq %rbx, %rdi
leaq 0x8b1(%rip), %rsi       # 0x40b1
callq 0x2200
addq $0x30, %r13
cmpq %r14, %r13
jne 0x3742
leaq 0x8a2(%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 0x395c
jmp 0x3969
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 0x3d3a
cmpq $0x0, 0x8(%r15)
jne 0x389c
leaq 0x18(%r14), %rsi
leaq 0x8(%rsp), %rdi
callq 0x20f0
movq 0x10(%rsp), %rdx
testq %rdx, %rdx
jne 0x38bf
leaq 0x7ce(%rip), %rcx       # 0x407b
leaq 0x8(%rsp), %rdi
movl $0x9, %r8d
xorl %esi, %esi
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 0x3597
movq (%r14), %r15
movq 0x8(%r14), %r13
cmpq %r13, %r15
je 0x3952
leaq 0x4(%rsp), %r14
leaq 0x24(%r15), %rsi
movq %rbx, %rdi
callq 0x363c
xorl %ebp, %ebp
leaq (%r15,%rbp), %rsi
movq %rbx, %rdi
callq 0x360b
addq $0xc, %rbp
cmpq $0x24, %rbp
jne 0x3921
movw $0x0, 0x4(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x355a
addq $0x30, %r15
cmpq %r13, %r15
jne 0x3913
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x3969
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 0x3984
jmp 0x3984
jmp 0x3993
jmp 0x3984
jmp 0x3984
jmp 0x3993
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
jne 0x39a5
jmp 0x39b2
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x39b2
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21b0
movq %rbx, %rdi
callq 0x2320