// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/apps/mshalign/mshalign.cpp
// Function: ReadWeights(char const*, double*&, int&)
static RNScalar *
ReadWeights(const char *filename, RNScalar *& weights, int& nweights)
{
  // Start statistics
  RNTime start_time;
  start_time.Read();

  // Open file
  FILE *fp = fopen(filename, "r");
  if (!fp) {
    RNFail("Unable to open edge weight file %s\n", filename);
    return NULL;
  }

  // Count weights
  nweights = 0;
  RNScalar dummy;
  while (fscanf(fp, "%lf", &dummy) == 1) nweights++;
  fseek(fp, 0, SEEK_SET);

  // Check number of weights
  if (nweights == 0) {
    RNFail("There are no weights in %s\n", filename);
    return NULL;
  }

  // Allocate array for weights
  weights = new RNScalar [ nweights ];
  if (!weights) {
    RNFail("Unable to allocate weights for %s\n", filename);
    return NULL;
  }

  // Read weights
  for (int i = 0; i < nweights; i++) {
    if (fscanf(fp, "%lf", &weights[i]) != 1) {
      RNFail("Unable to read weight %d from %s\n", i, filename);
      return NULL;
    }
  }

  // Close file
  fclose(fp);

  // Print message
  if (print_verbose) {
    printf("Read weights from %s ...\n", filename);
    printf("  Time = %.2f seconds\n", start_time.Elapsed());
    printf("  # Weights = %d\n", nweights);
  }

  // Return weights
  return weights;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x18(%rsp), %r12
movq %r12, %rdi
callq 0x54c8c
movq %r12, %rdi
xorl %esi, %esi
callq 0xc5b0
leaq 0x48a81(%rip), %rsi     # 0x59670
movq %r14, %rdi
callq 0xc440
testq %rax, %rax
je 0x10d12
movq %rax, %r12
movq %r14, 0x8(%rsp)
movl $0x0, (%r15)
leaq 0x47f89(%rip), %rsi     # 0x58b9f
leaq 0x10(%rsp), %rdx
movq %rax, %rdi
xorl %eax, %eax
callq 0xc670
cmpl $0x1, %eax
jne 0x10c4e
leaq 0x47f6e(%rip), %r13     # 0x58b9f
leaq 0x10(%rsp), %rbp
incl (%r15)
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
xorl %eax, %eax
callq 0xc670
cmpl $0x1, %eax
je 0x10c36
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xc3f0
movslq (%r15), %r14
testq %r14, %r14
je 0x10d20
movq %r14, %rax
shlq $0x3, %rax
testl %r14d, %r14d
movq $-0x1, %rdi
cmovnsq %rax, %rdi
callq 0xc030
movq %rax, (%rbx)
testl %r14d, %r14d
jle 0x10cc0
leaq 0x47f10(%rip), %rbp     # 0x58b9f
xorl %r14d, %r14d
xorl %r13d, %r13d
movq (%rbx), %rdx
addq %r14, %rdx
movq %r12, %rdi
movq %rbp, %rsi
xorl %eax, %eax
callq 0xc670
cmpl $0x1, %eax
jne 0x10d47
incq %r13
movslq (%r15), %rax
addq $0x8, %r14
cmpq %rax, %r13
jl 0x10c95
movq %r12, %rdi
callq 0xc360
cmpb $0x1, 0x6ce09(%rip)     # 0x7dad8
jne 0x10d0d
leaq 0x475c9(%rip), %rdi     # 0x582a1
movq 0x8(%rsp), %rsi
xorl %eax, %eax
callq 0xc070
leaq 0x18(%rsp), %rdi
callq 0x54cee
leaq 0x47500(%rip), %rdi     # 0x581f5
movb $0x1, %al
callq 0xc070
movl (%r15), %esi
leaq 0x475b5(%rip), %rdi     # 0x582bb
xorl %eax, %eax
callq 0xc070
movq (%rbx), %rbx
jmp 0x10d35
leaq 0x47526(%rip), %rdi     # 0x5823f
xorl %ebx, %ebx
movq %r14, %rsi
jmp 0x10d2e
leaq 0x4753c(%rip), %rdi     # 0x58263
xorl %ebx, %ebx
movq 0x8(%rsp), %rsi
xorl %eax, %eax
callq 0x573ee
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x47531(%rip), %rdi     # 0x5827f
xorl %ebx, %ebx
movl %r13d, %esi
movq 0x8(%rsp), %rdx
xorl %eax, %eax
callq 0x573ee
jmp 0x10d35