// File: /workspace/github_cpp_makefile_star2_O2/roberto-bayardo[P]google-extremal-sets/data-source-iterator.cc
// Function: google_extremal_sets::DataSourceIterator::Next(unsigned int*, std::vector<unsigned int, std::allocator<unsigned int>>*)
int DataSourceIterator::Next(uint32_t* vector_id, std::vector<uint32_t>* vec) {
  size_t bytes_read;
  uint32_t vector_size;

  while ((bytes_read = fread(vector_id, 1, 4, data_)) == 4) {
    bytes_read = fread(&vector_size, 1, 4, data_);
    if (bytes_read != 4) {
      if (ferror(data_))
        break;
      error_ = "Dataset format error. Partial vector length encountered "
          "for vector id " + ToString(*vector_id);
      return -1;
    }
    if (vector_size > kMaxVectorSize) {
      error_ = "Dataset format error. Size of vector id " +
          ToString(*vector_id) +
          " exceeds maximum: " +
          ToString(vector_size);
      return -1;
    }
    vec->resize(vector_size);
    bytes_read = fread(&((*vec)[0]), 1, 4 * vector_size, data_);
    if (bytes_read != 4 * vector_size) {
      if (ferror(data_))
        break;
      error_ = "Dataset format error. Dataset truncated while reading "
          "features from vector id " +
          ToString(*vector_id);
      return -1;
    }
    lines_processed_++;
    return 1;
  }
  if (ferror(data_)) {
    error_ = "Dataset read error, ferror code=" + ToString(ferror(data_));
    return -1;
  }
  if (bytes_read != 0) {
    error_ = "Dataset format error. Partial vector id encountered.";
    return -1;
  }
  return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb0, %rsp
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %rcx
pushq $0x1
popq %rsi
pushq $0x4
popq %rdx
movq %r14, %rdi
callq 0x2260
movq (%rbx), %r13
cmpq $0x4, %rax
jne 0x3992
leaq 0xc(%rsp), %rdi
pushq $0x1
popq %rsi
pushq $0x4
popq %rdx
movq %r13, %rcx
callq 0x2260
cmpq $0x4, %rax
jne 0x3997
movl 0xc(%rsp), %r15d
cmpq $0x186a0, %r15          # imm = 0x186A0
jb 0x3a30
movl (%r14), %esi
leaq 0x90(%rsp), %r14
movq %r14, %rdi
callq 0x3b20
leaq 0x1f5d(%rip), %rsi      # 0x5867
leaq 0x70(%rsp), %rdi
movq %r14, %rdx
callq 0x3cb1
leaq 0x1f72(%rip), %rdx      # 0x5890
leaq 0x10(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x3d78
leaq 0x50(%rsp), %rdi
movl %r15d, %esi
callq 0x3b20
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x3d11
addq $0x10, %rbx
leaq 0x30(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2210
movq %r14, %rdi
callq 0x20c0
leaq 0x50(%rsp), %rdi
callq 0x20c0
leaq 0x10(%rsp), %rdi
callq 0x20c0
leaq 0x70(%rsp), %rdi
callq 0x20c0
leaq 0x90(%rsp), %rdi
jmp 0x39fd
movq %rax, %r15
jmp 0x39ad
movq %rax, %r15
movq (%rbx), %r13
movq %r13, %rdi
callq 0x22e0
testl %eax, %eax
je 0x3a65
movq %r13, %rdi
callq 0x22e0
testl %eax, %eax
je 0x3a16
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl %eax, %esi
callq 0x3b20
leaq 0x1f23(%rip), %rsi      # 0x58f2
leaq 0x30(%rsp), %rdi
movq %r14, %rdx
callq 0x3cb1
addq $0x10, %rbx
leaq 0x30(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2210
movq %r14, %rdi
callq 0x20c0
leaq 0x10(%rsp), %rdi
callq 0x20c0
pushq $-0x1
popq %rax
addq $0xb0, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
testq %r15, %r15
je 0x3a61
addq $0x10, %rbx
leaq 0x1eed(%rip), %rsi      # 0x5913
movq %rbx, %rdi
callq 0x2300
jmp 0x3a02
movq %r12, %rdi
movq %r15, %rsi
callq 0x3d98
movq (%r12), %rdi
leal (,%r15,4), %r12d
movq (%rbx), %rcx
pushq $0x1
popq %rsi
movq %r12, %rdx
callq 0x2260
cmpq %r12, %rax
jne 0x3a8e
incl 0x8(%rbx)
pushq $0x1
jmp 0x3a04
xorl %eax, %eax
jmp 0x3a05
movl (%r14), %esi
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x3b20
leaq 0x1da4(%rip), %rsi      # 0x5820
leaq 0x30(%rsp), %rdi
movq %r14, %rdx
callq 0x3cb1
jmp 0x39dc
movq %rax, %r15
movq (%rbx), %r13
movq %r13, %rdi
callq 0x22e0
testl %eax, %eax
jne 0x39ad
movl (%r14), %esi
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x3b20
leaq 0x1de8(%rip), %rsi      # 0x58a3
leaq 0x30(%rsp), %rdi
movq %r14, %rdx
callq 0x3cb1
jmp 0x39dc
jmp 0x3b0b
jmp 0x3b0b
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x20c0
jmp 0x3ae3
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x20c0
jmp 0x3af2
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x20c0
jmp 0x3b01
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
jmp 0x3b13
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x20c0
movq %rbx, %rdi
callq 0x22b0