// File: /workspace/github_cpp_makefile_star2_O3/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)
cmpl $0x1, %eax
jbe 0x4285b
movl $0x1, %ebp
jmp 0x429eb
movq %rsi, %r14
movq %rdi, %rbx
testl %edx, %edx
je 0x4288a
movq 0x18(%rbx), %rsi
testq %rsi, %rsi
je 0x4288a
xorl %ebp, %ebp
movq %r14, %rdi
xorl %edx, %edx
callq 0xfab32
testl %eax, %eax
jne 0x42896
leaq 0x10aa58(%rip), %rdi    # 0x14d2dd
jmp 0x429e4
movq %r14, %rdi
callq 0xfab43
movq %rax, 0x18(%rbx)
leaq 0x30(%rbx), %r15
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x27ec0
cmpq $0x1, %rax
jne 0x42998
movslq (%r15), %rax
testq %rax, %rax
jle 0x429a1
shlq $0x4, %rax
leaq (%rax,%rax,4), %r12
movq %r12, %rdi
callq 0x27040
movq %rax, %r15
xorl %r13d, %r13d
leaq (%r15,%r13), %rdi
callq 0x45524
addq $0x50, %r13
cmpq %r13, %r12
jne 0x428db
movq %r15, 0x28(%rbx)
movslq 0x30(%rbx), %rdx
movl $0x50, %esi
movq %r15, %rdi
movq %r14, %rcx
callq 0x27ec0
movl 0x30(%rbx), %ecx
cmpq %rcx, %rax
jne 0x429db
leaq 0x90(%rbx), %rdi
leaq 0x19c079(%rip), %r14    # 0x1de998
leaq 0x8(%r14), %rsi
callq 0xd4746
leaq 0xa8(%rbx), %rdi
addq $0x20, %r14
movq %r14, %rsi
callq 0xd4746
cmpl $0x0, 0x30(%rbx)
jle 0x42851
leaq 0x88(%rbx), %r14
movl $0x10, %r12d
xorl %r13d, %r13d
movq %rsp, %r15
movq 0x28(%rbx), %rax
movsd -0x10(%rax,%r12), %xmm0
movsd -0x8(%rax,%r12), %xmm1
movsd (%rax,%r12), %xmm2
movq %r15, %rdi
callq 0xd43de
movq %r14, %rdi
movq %r15, %rsi
callq 0xbe362
incq %r13
movslq 0x30(%rbx), %rax
addq $0x50, %r12
cmpq %rax, %r13
jl 0x42958
jmp 0x42851
leaq 0x10a961(%rip), %rdi    # 0x14d300
jmp 0x429e2
movq $0x0, 0x28(%rbx)
leaq 0x90(%rbx), %rdi
leaq 0x19bfe1(%rip), %r14    # 0x1de998
leaq 0x8(%r14), %rsi
callq 0xd4746
addq $0xa8, %rbx
addq $0x20, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0xd4746
jmp 0x42851
leaq 0x10a948(%rip), %rdi    # 0x14d32a
xorl %ebp, %ebp
xorl %eax, %eax
callq 0xfb6f2
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %r15, %rdi
movq %r12, %rsi
callq 0x28330
movq %rbx, %rdi
callq 0x28150