// File: /workspace/github_cpp_makefile_star2_O1/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 0x55804
movq %r12, %rdi
xorl %esi, %esi
callq 0xc5b0
leaq 0x49ae8(%rip), %rsi     # 0x5a680
movq %r14, %rdi
callq 0xc440
testq %rax, %rax
je 0x10cbb
movq %rax, %r12
movl $0x0, (%r15)
leaq 0x48ff8(%rip), %rsi     # 0x59bb2
leaq 0x10(%rsp), %rdx
movq %rax, %rdi
xorl %eax, %eax
callq 0xc670
cmpl $0x1, %eax
jne 0x10bf2
leaq 0x48fdd(%rip), %r13     # 0x59bb2
leaq 0x10(%rsp), %rbp
incl (%r15)
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
xorl %eax, %eax
callq 0xc670
cmpl $0x1, %eax
je 0x10bda
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xc3f0
movslq (%r15), %rax
testq %rax, %rax
je 0x10cc4
movq %r14, 0x8(%rsp)
movq %rax, %rcx
shlq $0x3, %rcx
testl %eax, %eax
movq $-0x1, %rdi
cmovnsq %rcx, %rdi
callq 0xc030
movq %rax, (%rbx)
cmpl $0x0, (%r15)
jle 0x10c69
leaq 0x48f7a(%rip), %rbp     # 0x59bb2
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 0x10ce9
incq %r13
movslq (%r15), %rax
addq $0x8, %r14
cmpq %rax, %r13
jl 0x10c3e
movq %r12, %rdi
callq 0xc360
cmpb $0x1, 0x6de60(%rip)     # 0x7ead8
jne 0x10cb6
leaq 0x48623(%rip), %rdi     # 0x592a4
movq 0x8(%rsp), %rsi
xorl %eax, %eax
callq 0xc070
leaq 0x18(%rsp), %rdi
callq 0x55866
leaq 0x4855a(%rip), %rdi     # 0x591f8
movb $0x1, %al
callq 0xc070
movl (%r15), %esi
leaq 0x4860f(%rip), %rdi     # 0x592be
xorl %eax, %eax
callq 0xc070
movq (%rbx), %rbx
jmp 0x10cd7
leaq 0x48580(%rip), %rdi     # 0x59242
jmp 0x10ccb
leaq 0x4859b(%rip), %rdi     # 0x59266
xorl %ebx, %ebx
movq %r14, %rsi
xorl %eax, %eax
callq 0x581d2
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x48592(%rip), %rdi     # 0x59282
xorl %ebx, %ebx
movl %r13d, %esi
movq 0x8(%rsp), %rdx
xorl %eax, %eax
callq 0x581d2
jmp 0x10cd7