// File: /workspace/github_cpp_makefile_star2_O3/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 0x39a0(%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 0x6673
movsbq (%rax), %rbp
testq %rbp, %rbp
js 0x6673
incq %rax
movq %rax, (%r13)
jmp 0x667e
movq %r13, %rdi
callq 0x40c0
movq %rax, %rbp
testq %rbp, %rbp
movq 0x8(%rsp), %rdi
je 0x683f
movq %r14, 0x30(%rsp)
movq %rbp, 0x38(%rsp)
cmpq $0x0, 0x10(%rdi)
je 0x6808
leaq 0x38(%rsp), %rbx
xorl %r14d, %r14d
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 0x67c7
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 0x38c6(%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 0x674b
movzbl (%rcx), %eax
testb %al, %al
js 0x674d
incq %rcx
movq %rcx, (%r13)
jmp 0x6757
xorl %eax, %eax
movq %r13, %rdi
movl %eax, %esi
callq 0x43e0
testl %eax, %eax
je 0x67a2
movq %r13, %rdi
leaq 0x10(%rsp), %rsi
movl %eax, %edx
callq 0x4150
testb %al, %al
je 0x67a2
movq %rbx, %rdi
xorl %esi, %esi
callq 0x46d8
movq %rbx, %rdi
leaq 0x10(%rsp), %rsi
callq 0x44a0
cmpq $0x0, 0x10(%r15)
je 0x6850
movq %r15, %rdi
movq %rbx, %rsi
callq *0x18(%r15)
movq %rbx, %rdi
callq 0x47de
decq %rbp
jne 0x66d0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x67c7
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42d0
movq (%r13), %rax
cmpq 0x8(%r13), %rax
jae 0x67e3
movsbq (%rax), %rbp
testq %rbp, %rbp
js 0x67e3
incq %rax
movq %rax, (%r13)
jmp 0x67f3
movq %r13, %rdi
callq 0x40c0
movq %rax, %rbp
testb $0x1, %dl
je 0x680d
movq %rbp, 0x38(%rsp)
movq 0x8(%rsp), %rdi
cmpq $0x0, 0x10(%rdi)
jne 0x66a9
callq 0x4130
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 0x6841
movb $0x1, %al
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x4130
movq %rax, %rbx
movl $0x50, %esi
movq %r13, %rdi
jmp 0x68bb
movq %rax, %rbx
movl $0xb0, %esi
movq %r12, %rdi
jmp 0x68bb
movq %rax, %rbx
movl $0x50, %esi
movq %r14, %rdi
jmp 0x68bb
jmp 0x68a1
jmp 0x6880
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x47de
jmp 0x68a4
movq %rax, %rbx
movl $0x50, %esi
movq %r13, %rdi
callq 0x42d0
jmp 0x68a4
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x68c0
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42d0
movq %rbx, %rdi
callq 0x4480