// File: /workspace/github_cpp_makefile_star2_O1/vgteam[P]stream/src/stream.hpp
// Function: bool stream::for_each<Person>(std::istream&, std::function<void (Person&)>&, std::function<void (unsigned long)>&)
bool for_each(std::istream& in,
              std::function<void(T&)>& lambda,
              std::function<void(uint64_t)>& handle_count) {

    ::google::protobuf::io::ZeroCopyInputStream *raw_in =
          new ::google::protobuf::io::IstreamInputStream(&in);
    ::google::protobuf::io::GzipInputStream *gzip_in =
          new ::google::protobuf::io::GzipInputStream(raw_in);
    ::google::protobuf::io::CodedInputStream *coded_in =
          new ::google::protobuf::io::CodedInputStream(gzip_in);

    uint64_t count;
    coded_in->ReadVarint64((::google::protobuf::uint64*) &count);
    // this loop handles a chunked file with many pieces
    // such as we might write in a multithreaded process
    if (!count) return !count;
    do {

        handle_count(count);

        std::string s;
        for (uint64_t i = 0; i < count; ++i) {
            uint32_t msgSize = 0;
            delete coded_in;
            coded_in = new ::google::protobuf::io::CodedInputStream(gzip_in);
            // the messages are prefixed by their size
            coded_in->ReadVarint32(&msgSize);
            if ((msgSize > 0) &&
                (coded_in->ReadString(&s, msgSize))) {
                T object;
                object.ParseFromString(s);
                lambda(object);
            }
        }
    } while (coded_in->ReadVarint64((::google::protobuf::uint64*) &count));

    delete coded_in;
    delete gzip_in;
    delete raw_in;

    return !count;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdx, 0x8(%rsp)
movq %rsi, %r15
movq %rdi, %rbx
movl $0x50, %edi
callq 0x42c0
movq %rax, %r14
movq %rax, %rdi
movq %rbx, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x42b0
movl $0xb0, %edi
callq 0x42c0
movq %rax, %r12
movq %rax, %rdi
movq %r14, %rsi
xorl %edx, %edx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x4430
movl $0x50, %edi
callq 0x42c0
movq %rax, %r13
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %r12, 0x10(%rax)
xorl %eax, %eax
movq %rax, 0x18(%r13)
movq %rax, 0x1e(%r13)
movq $0x7fffffff, 0x28(%r13) # imm = 0x7FFFFFFF
movl $0x7fffffff, 0x30(%r13) # imm = 0x7FFFFFFF
movq 0x3a32(%rip), %rax      # 0x9fe0
movl (%rax), %eax
movl %eax, 0x34(%r13)
movl %eax, 0x38(%r13)
movups %xmm0, 0x40(%r13)
movq %r13, %rdi
callq 0x4040
movq (%r13), %rax
cmpq 0x8(%r13), %rax
jae 0x65e1
movsbq (%rax), %rbp
testq %rbp, %rbp
js 0x65e1
incq %rax
movq %rax, (%r13)
jmp 0x65ec
movq %r13, %rdi
callq 0x40c0
movq %rax, %rbp
testq %rbp, %rbp
movq 0x8(%rsp), %rdi
je 0x679e
movq %r14, 0x30(%rsp)
leaq 0x38(%rsp), %rbx
xorl %r14d, %r14d
movq %rbp, 0x38(%rsp)
cmpq $0x0, 0x10(%rdi)
je 0x67b4
movq %rbx, %rsi
callq *0x18(%rdi)
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movb $0x0, 0x20(%rsp)
testq %rbp, %rbp
je 0x6719
movq %r13, %rdi
callq 0x43a0
movl $0x50, %esi
movq %r13, %rdi
callq 0x42d0
movl $0x50, %edi
callq 0x42c0
movq %rax, %r13
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %r12, 0x10(%rax)
movq %r14, 0x18(%rax)
movq %r14, 0x1e(%rax)
movq $0x7fffffff, 0x28(%rax) # imm = 0x7FFFFFFF
movl $0x7fffffff, 0x30(%rax) # imm = 0x7FFFFFFF
movq 0x3958(%rip), %rax      # 0x9fe0
movl (%rax), %eax
movl %eax, 0x34(%r13)
movl %eax, 0x38(%r13)
movups %xmm0, 0x40(%r13)
movq %r13, %rdi
callq 0x4040
movq (%r13), %rcx
cmpq 0x8(%r13), %rcx
jae 0x66b9
movzbl (%rcx), %eax
testb %al, %al
js 0x66bb
incq %rcx
movq %rcx, (%r13)
jmp 0x66c5
xorl %eax, %eax
movq %r13, %rdi
movl %eax, %esi
callq 0x43e0
testl %eax, %eax
je 0x6710
movq %r13, %rdi
leaq 0x10(%rsp), %rsi
movl %eax, %edx
callq 0x4150
testb %al, %al
je 0x6710
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4696
movq %rbx, %rdi
leaq 0x10(%rsp), %rsi
callq 0x44a0
cmpq $0x0, 0x10(%r15)
je 0x67af
movq %r15, %rdi
movq %rbx, %rsi
callq *0x18(%r15)
movq %rbx, %rdi
callq 0x479a
decq %rbp
jne 0x663e
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x6735
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42d0
movq (%r13), %rax
cmpq 0x8(%r13), %rax
jae 0x6753
movsbq (%rax), %rbp
testq %rbp, %rbp
js 0x6753
incq %rax
movq %rax, (%r13)
movb $0x1, %dl
jmp 0x675e
movq %r13, %rdi
callq 0x40c0
movq %rax, %rbp
testb $0x1, %dl
movq 0x8(%rsp), %rdi
jne 0x6607
movq %r13, %rdi
callq 0x43a0
movl $0x50, %esi
movq %r13, %rdi
callq 0x42d0
movq (%r12), %rax
movq %r12, %rdi
callq *0x8(%rax)
movq 0x30(%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
testq %rbp, %rbp
sete %al
jmp 0x67a0
movb $0x1, %al
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x4130
callq 0x4130
movq %rax, %rbx
movl $0x50, %esi
movq %r13, %rdi
jmp 0x681f
movq %rax, %rbx
movl $0xb0, %esi
movq %r12, %rdi
jmp 0x681f
movq %rax, %rbx
movl $0x50, %esi
movq %r14, %rdi
jmp 0x681f
jmp 0x6805
jmp 0x67e4
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x479a
jmp 0x6808
movq %rax, %rbx
movl $0x50, %esi
movq %r13, %rdi
callq 0x42d0
jmp 0x6808
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x6824
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42d0
movq %rbx, %rdi
callq 0x4480