// File: roberto-bayardo[P]google-extremal-sets/data-source-iterator.cc
// Function: google_extremal_sets::DataSourceIterator::NextText(unsigned int*, std::vector<unsigned int, std::allocator<unsigned int>>*)
int DataSourceIterator::NextText(uint32_t* vector_id, std::vector<uint32_t>* vec) {
  vec->clear();
  // First read the vector ID
  int scan_result = fscanf(data_, "%u", vector_id);
  if (!scan_result) {
    if (ferror(data_)) {
      error_ = "Dataset read error, ferror code=" + ToString(ferror(data_));
      return -1;
    }
    // Otherwise we're eof()
    return 0;
  }
  if (scan_result == EOF)
    return 0;

  // Now read the item ids, until we reach the "0" terminator.
  uint32_t item_id;
  while ((scan_result = fscanf(data_, "%u", &item_id)) != EOF && scan_result != 0) {
    if (item_id)
      vec->push_back(item_id);
    else {
      lines_processed_++;
      return 1;
    }
  }
  if (ferror(data_)) {
    error_ = "Dataset read error, ferror code=" + ToString(ferror(data_));
    return -1;
  }
  error_ = "Dataset format error: Final vector not properly terminated.";
  return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x20(%rbp), %rdi
callq 0x7580
movq -0xc0(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rdx
leaq 0x28c8(%rip), %rsi      # 0x9948
movb $0x0, %al
callq 0x23b0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x713e
movq -0xc0(%rbp), %rax
movq (%rax), %rdi
callq 0x23c0
cmpl $0x0, %eax
je 0x7132
movq -0xc0(%rbp), %rax
movq (%rax), %rdi
callq 0x23c0
movl %eax, %esi
leaq -0x68(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x6fb0
movq -0xc8(%rbp), %rdx
leaq 0x2817(%rip), %rsi      # 0x98f2
leaq -0x48(%rbp), %rdi
callq 0x72b0
jmp 0x70e6
movq -0xc0(%rbp), %rdi
addq $0x10, %rdi
leaq -0x48(%rbp), %rsi
callq 0x22b0
leaq -0x48(%rbp), %rdi
callq 0x2130
leaq -0x68(%rbp), %rdi
callq 0x2130
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7294
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x2130
jmp 0x72a0
movl $0x0, -0x4(%rbp)
jmp 0x7294
cmpl $-0x1, -0x24(%rbp)
jne 0x7150
movl $0x0, -0x4(%rbp)
jmp 0x7294
jmp 0x7152
movq -0xc0(%rbp), %rax
movq (%rax), %rdi
leaq 0x27e5(%rip), %rsi      # 0x9948
leaq -0x78(%rbp), %rdx
movb $0x0, %al
callq 0x23b0
movl %eax, %ecx
movl %ecx, -0x24(%rbp)
xorl %eax, %eax
cmpl $-0x1, %ecx
movb %al, -0xc9(%rbp)
je 0x718d
cmpl $0x0, -0x24(%rbp)
setne %al
movb %al, -0xc9(%rbp)
movb -0xc9(%rbp), %al
testb $0x1, %al
jne 0x7199
jmp 0x71cc
cmpl $0x0, -0x78(%rbp)
je 0x71ae
movq -0x20(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x75a0
jmp 0x71ca
movq -0xc0(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x7294
jmp 0x7152
movq -0xc0(%rbp), %rax
movq (%rax), %rdi
callq 0x23c0
cmpl $0x0, %eax
je 0x7276
movq -0xc0(%rbp), %rax
movq (%rax), %rdi
callq 0x23c0
movl %eax, %esi
leaq -0xb8(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x6fb0
movq -0xd8(%rbp), %rdx
leaq 0x26dc(%rip), %rsi      # 0x98f2
leaq -0x98(%rbp), %rdi
callq 0x72b0
jmp 0x7224
movq -0xc0(%rbp), %rdi
addq $0x10, %rdi
leaq -0x98(%rbp), %rsi
callq 0x22b0
leaq -0x98(%rbp), %rdi
callq 0x2130
leaq -0xb8(%rbp), %rdi
callq 0x2130
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7294
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x2130
jmp 0x72a0
movq -0xc0(%rbp), %rdi
addq $0x10, %rdi
leaq 0x26c3(%rip), %rsi      # 0x994b
callq 0x22f0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0xe0, %rsp
popq %rbp
retq
movq -0x70(%rbp), %rdi
callq 0x2370
nopl (%rax)