// File: /workspace/github_cpp_makefile_star2_O1/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, %r12
movq %rsi, %r15
movq %rdi, %r14
movl $0x48, %edi
callq 0x42c0
movq %rax, %rbp
movq %rax, %rdi
movq %r14, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x40f0
movl $0xa8, %edi
callq 0x42c0
movq %rax, %rbx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x44c0
movl $0x50, %edi
callq 0x42c0
movq %rax, %r13
movq %rax, %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq 0x4320
movq 0x40(%r13), %rax
cmpq %rax, (%r13)
jbe 0x6423
movq %rax, 0x40(%r13)
cmpq $0x7f, %r15
ja 0x6234
movb %r15b, (%rax)
incq %rax
jmp 0x6279
movl %r15d, %ecx
orb $-0x80, %cl
movb %cl, (%rax)
movq %r15, %rcx
shrq $0x7, %rcx
cmpq $0x3fff, %r15           # imm = 0x3FFF
ja 0x6255
movb %cl, 0x1(%rax)
addq $0x2, %rax
jmp 0x6279
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 0x6259
movb %cl, -0x1(%rax)
movq %rbx, 0x38(%rsp)
movq %rax, 0x40(%r13)
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
testq %r15, %r15
je 0x63be
movq %rbp, 0x30(%rsp)
movq %r15, 0x8(%rsp)
xorl %ebx, %ebx
leaq 0x48(%rsp), %rbp
movq %rbx, 0x40(%rsp)
cmpq $0x0, 0x10(%r12)
je 0x6433
movq %rbp, %rdi
movq %r12, %rsi
leaq 0x40(%rsp), %rdx
callq *0x18(%r12)
movq %rbp, %rdi
leaq 0x10(%rsp), %rsi
callq 0x41a0
movq %rbp, %rdi
callq 0x479a
movq 0x18(%rsp), %r15
movq 0x40(%r13), %r14
cmpq %r14, (%r13)
jbe 0x638c
movq %r14, 0x40(%r13)
cmpl $0x7f, %r15d
ja 0x630b
movb %r15b, (%r14)
incq %r14
jmp 0x634d
movl %r15d, %eax
orb $-0x80, %al
movb %al, (%r14)
movl %r15d, %eax
shrl $0x7, %eax
cmpl $0x3fff, %r15d          # imm = 0x3FFF
ja 0x632c
movb %al, 0x1(%r14)
addq $0x2, %r14
jmp 0x634d
addq $0x2, %r14
movl %eax, %ecx
movl %ecx, %edx
orb $-0x80, %dl
movb %dl, -0x1(%r14)
shrl $0x7, %eax
incq %r14
cmpl $0x3fff, %ecx           # imm = 0x3FFF
ja 0x6330
movb %al, -0x1(%r14)
movq %r14, 0x40(%r13)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq (%r13), %rax
subq %r14, %rax
movslq %edx, %r15
cmpq %r15, %rax
jl 0x639f
movq %r14, %rdi
movq %r15, %rdx
callq 0x4240
addq %r15, %r14
movq %r14, 0x40(%r13)
incq %rbx
cmpq 0x8(%rsp), %rbx
jne 0x62b0
jmp 0x63af
movq %r13, %rdi
movq %r14, %rsi
callq 0x43f0
movq %rax, %r14
jmp 0x62f9
movq %r13, %rdi
movq %r14, %rcx
callq 0x4210
movq %rax, %r14
jmp 0x6378
movq 0x8(%rsp), %r15
movq %r15, %rbx
movq 0x30(%rsp), %rbp
jmp 0x63c0
xorl %ebx, %ebx
movq %r13, %rdi
callq 0x42a0
movl $0x50, %esi
movq %r13, %rdi
callq 0x42d0
movq 0x38(%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq (%rbp), %rax
movq %rbp, %rdi
callq *0x8(%rax)
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x6406
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42d0
testq %r15, %r15
sete %cl
cmpq %r15, %rbx
sete %al
orb %cl, %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 0x6222
callq 0x4130
jmp 0x6463
movq %rax, %rbx
movl $0x50, %esi
movq %r13, %rdi
jmp 0x648c
movq %rbx, %rdi
movq %rax, %rbx
movl $0xa8, %esi
jmp 0x648c
movq %rax, %rbx
movl $0x48, %esi
movq %rbp, %rdi
jmp 0x648c
jmp 0x6463
movq %rax, %rbx
jmp 0x6475
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x479a
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x6491
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42d0
movq %rbx, %rdi
callq 0x4480
nop