// File: 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 %rbp
movq %rsp, %rbp
subq $0x1d0, %rsp            # imm = 0x1D0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x1a8(%rbp)
movq -0x1a8(%rbp), %rax
movq -0x18(%rbp), %rdi
movq (%rax), %rcx
movl $0x1, %esi
movl $0x4, %edx
callq 0x2320
movq %rax, -0x28(%rbp)
cmpq $0x4, %rax
jne 0x6eb9
movq -0x1a8(%rbp), %rax
movq (%rax), %rcx
leaq -0x2c(%rbp), %rdi
movl $0x1, %esi
movl $0x4, %edx
callq 0x2320
movq %rax, -0x28(%rbp)
cmpq $0x4, -0x28(%rbp)
je 0x6c4d
movq -0x1a8(%rbp), %rax
movq (%rax), %rdi
callq 0x23c0
cmpl $0x0, %eax
je 0x6bd2
jmp 0x6eb9
movq -0x18(%rbp), %rax
movl (%rax), %esi
leaq -0x70(%rbp), %rdi
movq %rdi, -0x1b0(%rbp)
callq 0x6fb0
movq -0x1b0(%rbp), %rdx
leaq 0x2c2a(%rip), %rsi      # 0x9820
leaq -0x50(%rbp), %rdi
callq 0x72b0
jmp 0x6c01
movq -0x1a8(%rbp), %rdi
addq $0x10, %rdi
leaq -0x50(%rbp), %rsi
callq 0x22b0
leaq -0x50(%rbp), %rdi
callq 0x2130
leaq -0x70(%rbp), %rdi
callq 0x2130
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6f91
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x2130
jmp 0x6f9d
cmpl $0x1869f, -0x2c(%rbp)   # imm = 0x1869F
jbe 0x6da2
movq -0x18(%rbp), %rax
movl (%rax), %esi
leaq -0x100(%rbp), %rdi
movq %rdi, -0x1b8(%rbp)
callq 0x6fb0
movq -0x1b8(%rbp), %rdx
leaq 0x2be6(%rip), %rsi      # 0x9867
leaq -0xe0(%rbp), %rdi
callq 0x72b0
jmp 0x6c8f
leaq 0x2bfa(%rip), %rdx      # 0x9890
leaq -0xc0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x7480
jmp 0x6cab
movl -0x2c(%rbp), %esi
leaq -0x120(%rbp), %rdi
callq 0x6fb0
jmp 0x6cbc
leaq -0xa0(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
leaq -0x120(%rbp), %rdx
callq 0x73b0
jmp 0x6cd8
movq -0x1a8(%rbp), %rdi
addq $0x10, %rdi
leaq -0xa0(%rbp), %rsi
callq 0x22b0
leaq -0xa0(%rbp), %rdi
callq 0x2130
leaq -0x120(%rbp), %rdi
callq 0x2130
leaq -0xc0(%rbp), %rdi
callq 0x2130
leaq -0xe0(%rbp), %rdi
callq 0x2130
leaq -0x100(%rbp), %rdi
callq 0x2130
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6f91
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x6d91
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x6d85
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x6d79
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x2130
leaq -0xc0(%rbp), %rdi
callq 0x2130
leaq -0xe0(%rbp), %rdi
callq 0x2130
leaq -0x100(%rbp), %rdi
callq 0x2130
jmp 0x6f9d
movq -0x20(%rbp), %rdi
movl -0x2c(%rbp), %eax
movl %eax, %esi
callq 0x74d0
movq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x7560
movq %rax, %rdi
movq -0x1a8(%rbp), %rax
movl -0x2c(%rbp), %ecx
shll $0x2, %ecx
movl %ecx, %ecx
movl %ecx, %edx
movq (%rax), %rcx
movl $0x1, %esi
callq 0x2320
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movl -0x2c(%rbp), %ecx
shll $0x2, %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
je 0x6e9d
movq -0x1a8(%rbp), %rax
movq (%rax), %rdi
callq 0x23c0
cmpl $0x0, %eax
je 0x6e10
jmp 0x6eb9
movq -0x18(%rbp), %rax
movl (%rax), %esi
leaq -0x160(%rbp), %rdi
movq %rdi, -0x1c0(%rbp)
callq 0x6fb0
movq -0x1c0(%rbp), %rdx
leaq 0x2a6c(%rip), %rsi      # 0x98a3
leaq -0x140(%rbp), %rdi
callq 0x72b0
jmp 0x6e45
movq -0x1a8(%rbp), %rdi
addq $0x10, %rdi
leaq -0x140(%rbp), %rsi
callq 0x22b0
leaq -0x140(%rbp), %rdi
callq 0x2130
leaq -0x160(%rbp), %rdi
callq 0x2130
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6f91
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x160(%rbp), %rdi
callq 0x2130
jmp 0x6f9d
movq -0x1a8(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x6f91
movq -0x1a8(%rbp), %rax
movq (%rax), %rdi
callq 0x23c0
cmpl $0x0, %eax
je 0x6f63
movq -0x1a8(%rbp), %rax
movq (%rax), %rdi
callq 0x23c0
movl %eax, %esi
leaq -0x1a0(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0x6fb0
movq -0x1c8(%rbp), %rdx
leaq 0x29ef(%rip), %rsi      # 0x98f2
leaq -0x180(%rbp), %rdi
callq 0x72b0
jmp 0x6f11
movq -0x1a8(%rbp), %rdi
addq $0x10, %rdi
leaq -0x180(%rbp), %rsi
callq 0x22b0
leaq -0x180(%rbp), %rdi
callq 0x2130
leaq -0x1a0(%rbp), %rdi
callq 0x2130
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6f91
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x2130
jmp 0x6f9d
cmpq $0x0, -0x28(%rbp)
je 0x6f8a
movq -0x1a8(%rbp), %rdi
addq $0x10, %rdi
leaq 0x2997(%rip), %rsi      # 0x9913
callq 0x22f0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6f91
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbp
retq
movq -0x78(%rbp), %rdi
callq 0x2370
nopw %cs:(%rax,%rax)