// File: /workspace/github_cpp_makefile_star2_O3/vgteam[P]stream/src/stream.hpp
// Function: bool stream::write<Person>(std::ostream&, unsigned long, std::function<Person (unsigned long)>&)
bool write(std::ostream& out, uint64_t count, std::function<T(uint64_t)>& lambda) {

    ::google::protobuf::io::ZeroCopyOutputStream *raw_out =
          new ::google::protobuf::io::OstreamOutputStream(&out);
    ::google::protobuf::io::GzipOutputStream *gzip_out =
          new ::google::protobuf::io::GzipOutputStream(raw_out);
    ::google::protobuf::io::CodedOutputStream *coded_out =
          new ::google::protobuf::io::CodedOutputStream(gzip_out);

    // prefix the chunk with the number of objects
    coded_out->WriteVarint64(count);

    std::string s;
    uint64_t written = 0;
    for (uint64_t n = 0; n < count; ++n, ++written) {
        lambda(n).SerializeToString(&s);
        // and prefix each object with its size
        coded_out->WriteVarint32(s.size());
        coded_out->WriteRaw(s.data(), s.size());
    }

    delete coded_out;
    delete gzip_out;
    delete raw_out;

    return !count || written == count;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdx, %r15
movq %rsi, %rbp
movq %rdi, %rbx
movl $0x48, %edi
callq 0x42c0
movq %rax, %r14
movq %rax, %rdi
movq %rbx, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x40f0
movl $0xa8, %edi
callq 0x42c0
movq %rax, %r12
movq %rax, %rdi
movq %r14, %rsi
callq 0x44c0
movl $0x50, %edi
callq 0x42c0
movq %rax, %r13
movq %rax, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x4320
movq 0x40(%r13), %rax
cmpq %rax, (%r13)
jbe 0x64ba
cmpq $0x7f, %rbp
ja 0x62ce
movb %bpl, (%rax)
incq %rax
jmp 0x632e
movl %ebp, %ecx
orb $-0x80, %cl
movb %cl, (%rax)
movq %rbp, %rcx
shrq $0x7, %rcx
cmpq $0x3fff, %rbp           # imm = 0x3FFF
ja 0x630a
movb %cl, 0x1(%rax)
addq $0x2, %rax
movq %rax, 0x40(%r13)
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movq %rax, (%rsp)
movb $0x0, (%rax)
jmp 0x6353
addq $0x2, %rax
movq %rcx, %rdx
movl %edx, %esi
orb $-0x80, %sil
movb %sil, -0x1(%rax)
shrq $0x7, %rcx
incq %rax
cmpq $0x3fff, %rdx           # imm = 0x3FFF
ja 0x630e
movb %cl, -0x1(%rax)
movq %rax, 0x40(%r13)
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movq %rax, (%rsp)
movb $0x0, (%rax)
testq %rbp, %rbp
je 0x6469
movq %rbp, 0x38(%rsp)
movq %r12, 0x28(%rsp)
movq %r14, 0x30(%rsp)
xorl %r12d, %r12d
leaq 0x48(%rsp), %rbp
movq %r12, 0x40(%rsp)
cmpq $0x0, 0x10(%r15)
je 0x64ca
movq %rbp, %rdi
movq %r15, %rsi
leaq 0x40(%rsp), %rdx
callq *0x18(%r15)
movq %rbp, %rdi
leaq 0x8(%rsp), %rsi
callq 0x41a0
movq %rbp, %rdi
callq 0x47de
movq 0x10(%rsp), %r14
movq 0x40(%r13), %rbx
cmpq %rbx, (%r13)
jbe 0x643c
cmpl $0x7f, %r14d
ja 0x63bf
movb %r14b, (%rbx)
incq %rbx
jmp 0x63fd
movl %r14d, %eax
orb $-0x80, %al
movb %al, (%rbx)
movl %r14d, %eax
shrl $0x7, %eax
cmpl $0x3fff, %r14d          # imm = 0x3FFF
ja 0x63de
movb %al, 0x1(%rbx)
addq $0x2, %rbx
jmp 0x63fd
addq $0x2, %rbx
movl %eax, %ecx
movl %ecx, %edx
orb $-0x80, %dl
movb %dl, -0x1(%rbx)
shrl $0x7, %eax
incq %rbx
cmpl $0x3fff, %ecx           # imm = 0x3FFF
ja 0x63e2
movb %al, -0x1(%rbx)
movq %rbx, 0x40(%r13)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq (%r13), %rax
subq %rbx, %rax
movslq %edx, %r14
cmpq %r14, %rax
jl 0x644f
movq %rbx, %rdi
movq %r14, %rdx
callq 0x4240
addq %r14, %rbx
movq %rbx, 0x40(%r13)
incq %r12
cmpq 0x38(%rsp), %r12
jne 0x636a
jmp 0x645f
movq %r13, %rdi
movq %rbx, %rsi
callq 0x43f0
movq %rax, %rbx
jmp 0x63b1
movq %r13, %rdi
movq %rbx, %rcx
callq 0x4210
movq %rax, %rbx
jmp 0x6428
movq 0x30(%rsp), %r14
movq 0x28(%rsp), %r12
movq %r13, %rdi
callq 0x42a0
movl $0x50, %esi
movq %r13, %rdi
callq 0x42d0
movq (%r12), %rax
movq %r12, %rdi
callq *0x8(%rax)
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
movq 0x8(%rsp), %rdi
cmpq (%rsp), %rdi
je 0x64a9
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42d0
movb $0x1, %al
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, %rdi
movq %rax, %rsi
callq 0x43f0
jmp 0x62c0
callq 0x4130
jmp 0x64fa
movq %rax, %rbx
movl $0x50, %esi
movq %r13, %rdi
jmp 0x651f
movq %rax, %rbx
movl $0xa8, %esi
movq %r12, %rdi
jmp 0x651f
movq %rax, %rbx
movl $0x48, %esi
movq %r14, %rdi
jmp 0x651f
jmp 0x64fa
movq %rax, %rbx
jmp 0x650c
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x47de
movq 0x8(%rsp), %rdi
cmpq (%rsp), %rdi
je 0x6524
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42d0
movq %rbx, %rdi
callq 0x4480