// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVScanline.cpp
// Function: gaps::GSVScanline::ReadPoints(_IO_FILE*, int)
int GSVScanline::
ReadPoints(FILE *fp, RNBoolean seek) 
{
  // Check read counter
  if (++read_count > 1) return 1;
  assert(!points);

  // Seek within file
  if (seek && (file_offset > 0)) {
    if (!RNFileSeek(fp, file_offset, RN_FILE_SEEK_SET)) {
      RNFail("Unable to seek to scanline points\n");
      return 0;
    }
  }
  else {
    // Update file offset
    file_offset = RNFileTell(fp);
  }

  // Read number of points 
  if (fread(&npoints, sizeof(int), 1, fp) != (unsigned int) 1) {
    RNFail("Unable to read number of scanline points\n");
    return 0;
  }

  // Check number of points
  if (npoints > 0) {
    // Allocate points 
    points = new GSVPoint [ npoints ];
    if (!points) {
      RNFail("Unable to allocate scanline points\n");
      return 0;
    }
    
    // Read points
    if (fread(points, sizeof(GSVPoint), npoints, fp) != (unsigned int) npoints) {
      RNFail("Unable to read scanline points\n");
      return 0;
    }
    
    // Update bounding box
    bbox = R3null_box;
    for (int i = 0; i < npoints; i++) {
      bbox.Union(points[i].Position());
    }
  }
  else {
    // No points
    points = NULL;
    bbox = R3null_box;
  }

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl 0x20(%rdi), %eax
incl %eax
movl %eax, 0x20(%rdi)
pushq $0x1
popq %r12
cmpl $0x1, %eax
jbe 0x3f7c7
movl %r12d, %ebp
jmp 0x3f8f2
movq %rsi, %r15
movq %rdi, %rbx
testl %edx, %edx
je 0x3f7f6
movq 0x18(%rbx), %rsi
testq %rsi, %rsi
je 0x3f7f6
xorl %ebp, %ebp
movq %r15, %rdi
xorl %edx, %edx
callq 0xe3986
testl %eax, %eax
jne 0x3f802
leaq 0xecaac(%rip), %rdi     # 0x12c29d
jmp 0x3f8eb
movq %r15, %rdi
callq 0xe3997
movq %rax, 0x18(%rbx)
leaq 0x30(%rbx), %r14
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
movq %r15, %rcx
callq 0x27ee0
cmpq $0x1, %rax
jne 0x3f8b9
movslq (%r14), %rax
testq %rax, %rax
jle 0x3f8c2
imulq $0x50, %rax, %r12
movq %r12, %rdi
callq 0x27040
movq %rax, %r13
xorl %ebp, %ebp
movq %r13, %rdi
addq %rbp, %rdi
callq 0x42260
addq $0x50, %rbp
cmpq %rbp, %r12
jne 0x3f83e
movq %r13, 0x28(%rbx)
movslq 0x30(%rbx), %rdx
pushq $0x50
popq %rsi
movq %r13, %rdi
movq %r15, %rcx
callq 0x27ee0
movl 0x30(%rbx), %ecx
cmpq %rcx, %rax
jne 0x3f8e2
leaq 0x88(%rbx), %r15
leaq 0x18813a(%rip), %rsi    # 0x1c79b8
movq %r15, %rdi
callq 0x30d44
xorl %r13d, %r13d
movq %rsp, %r12
xorl %ebp, %ebp
movslq (%r14), %rax
cmpq %rax, %rbp
jge 0x3f903
movq 0x28(%rbx), %rsi
addq %r13, %rsi
movq %r12, %rdi
callq 0x310c8
movq %r15, %rdi
movq %r12, %rsi
callq 0xad308
incq %rbp
addq $0x50, %r13
jmp 0x3f88e
leaq 0xeca00(%rip), %rdi     # 0x12c2c0
jmp 0x3f8e9
andq $0x0, 0x28(%rbx)
addq $0x88, %rbx
leaq 0x1880e3(%rip), %rsi    # 0x1c79b8
movq %rbx, %rdi
callq 0x30d44
jmp 0x3f7bf
leaq 0xeca01(%rip), %rdi     # 0x12c2ea
xorl %ebp, %ebp
xorl %eax, %eax
callq 0xe434a
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x1
popq %rbp
jmp 0x3f8f2
movq %rax, %rbx
movq %r13, %rdi
movq %r12, %rsi
callq 0x28360
movq %rbx, %rdi
callq 0x28170