// File: /workspace/github_cpp_makefile_star2_O1/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 0x42d23
movl $0x1, %ebp
jmp 0x42eb3
movq %rsi, %r14
movq %rdi, %rbx
testl %edx, %edx
je 0x42d52
movq 0x18(%rbx), %rsi
testq %rsi, %rsi
je 0x42d52
xorl %ebp, %ebp
movq %r14, %rdi
xorl %edx, %edx
callq 0xfc9e6
testl %eax, %eax
jne 0x42d5e
leaq 0x10c560(%rip), %rdi    # 0x14f2ad
jmp 0x42eac
movq %r14, %rdi
callq 0xfc9f7
movq %rax, 0x18(%rbx)
leaq 0x30(%rbx), %r15
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x27ed0
cmpq $0x1, %rax
jne 0x42e60
movslq (%r15), %rax
testq %rax, %rax
jle 0x42e69
shlq $0x4, %rax
leaq (%rax,%rax,4), %r12
movq %r12, %rdi
callq 0x27040
movq %rax, %r15
xorl %r13d, %r13d
leaq (%r15,%r13), %rdi
callq 0x459f0
addq $0x50, %r13
cmpq %r13, %r12
jne 0x42da3
movq %r15, 0x28(%rbx)
movslq 0x30(%rbx), %rdx
movl $0x50, %esi
movq %r15, %rdi
movq %r14, %rcx
callq 0x27ed0
movl 0x30(%rbx), %ecx
cmpq %rcx, %rax
jne 0x42ea3
leaq 0x90(%rbx), %rdi
leaq 0x19dbc1(%rip), %r14    # 0x1e09a8
leaq 0x8(%r14), %rsi
callq 0xd619c
leaq 0xa8(%rbx), %rdi
addq $0x20, %r14
movq %r14, %rsi
callq 0xd619c
cmpl $0x0, 0x30(%rbx)
jle 0x42d19
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 0xd5e2e
movq %r14, %rdi
movq %r15, %rsi
callq 0xbfa56
incq %r13
movslq 0x30(%rbx), %rax
addq $0x50, %r12
cmpq %rax, %r13
jl 0x42e20
jmp 0x42d19
leaq 0x10c469(%rip), %rdi    # 0x14f2d0
jmp 0x42eaa
movq $0x0, 0x28(%rbx)
leaq 0x90(%rbx), %rdi
leaq 0x19db29(%rip), %r14    # 0x1e09a8
leaq 0x8(%r14), %rsi
callq 0xd619c
addq $0xa8, %rbx
addq $0x20, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0xd619c
jmp 0x42d19
leaq 0x10c450(%rip), %rdi    # 0x14f2fa
xorl %ebp, %ebp
xorl %eax, %eax
callq 0xfd64a
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 0x28340
movq %rbx, %rdi
callq 0x28160