// File: /workspace/github_c_makefile_star2_O3/jsh58[P]Genrich/Genrich.c
// Function: saveInterval
uint32_t saveInterval(Chrom* c, int64_t start, int64_t end,
    char* qname, uint8_t count, File bed, bool bedOpt,
    bool gzOut, bool ctrl, int sample, uint64_t* errCount,
    bool verbose) {

  // check validity of positions
  if (start < 0) {
    if (verbose) {
      if (*errCount < MAX_ALNS)
        fprintf(stderr, "Warning! Read %s prevented from extending below 0 on %s\n",
          qname, c->name);
      (*errCount)++;
    }
    start = 0;
  }
  if (start >= c->len) {
    char msg[MAX_ALNS];
    sprintf(msg, "Read %s, ref. %s", qname, c->name);
    exit(error(msg, ERRPOS));
  }
  if (end > c->len) {
    if (verbose) {
      if (*errCount < MAX_ALNS)
        fprintf(stderr, "Warning! Read %s prevented from extending past %d on %s\n",
          qname, c->len, c->name);
      (*errCount)++;
    }
    end = c->len;
  }

  // create 'diff' arrays if necessary
  if (c->diff == NULL) {
    c->diff = (Diff*) memalloc(sizeof(Diff));
    c->diff->frac = (uint8_t*) memalloc((1 + c->len) * sizeof(uint8_t));
    c->diff->cov = (int16_t*) memalloc((1 + c->len) * sizeof(int16_t));
    for (int i = 0; i < 1 + c->len; i++) {
      c->diff->frac[i] = 0;
      c->diff->cov[i] = 0;
    }
  }

  // check for overflow/underflow (c->diff->cov is int16_t)
  if (c->diff->cov[start] == INT16_MAX) {
    if (verbose) {
      fprintf(stderr, "Warning! Read %s, alignment at (%s, %ld-%ld)",
        qname, c->name, start, end);
      fprintf(stderr, " skipped due to overflow\n");
    }
    return 0;
  }
  if (c->diff->cov[end] == INT16_MIN) {
    if (verbose) {
      fprintf(stderr, "Warning! Read %s, alignment at (%s, %ld-%ld)",
        qname, c->name, start, end);
      fprintf(stderr, " skipped due to underflow\n");
    }
    return 0;
  }

  // add counts to diff array(s)
  if (count == 1) {
    c->diff->cov[start]++;
    c->diff->cov[end]--;
  } else {
    // add fractional count
    addFrac(&c->diff->cov[start], &c->diff->frac[start], count);
    subFrac(&c->diff->cov[end], &c->diff->frac[end], count);
  }

  // print BED interval
  if (bedOpt)
    printBED(bed, gzOut, c->name, start, end, qname,
      count, ctrl, sample);

  return end - start;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rcx, %r11
movq %rdx, %r15
movq %rdi, %r14
movb 0xf8(%rsp), %bpl
movl %ebp, %ebx
xorb $0x1, %bl
movq 0xf0(%rsp), %r12
xorl %r13d, %r13d
testq %rsi, %rsi
setns %al
cmovgq %rsi, %r13
orb %bl, %al
jne 0x893e
movq (%r12), %rax
cmpq $0x7f, %rax
jbe 0x8b1a
incq %rax
movq %rax, (%r12)
xorl %r13d, %r13d
movl 0x8(%r14), %ecx
cmpq %rcx, %r13
jae 0x8ba4
cmpq %r15, %rcx
setge %al
cmovlq %rcx, %r15
orb %bl, %al
jne 0x8971
movq (%r12), %rax
cmpq $0x7f, %rax
jbe 0x8b5f
incq %rax
movq %rax, (%r12)
movq %rcx, %r15
movq 0x20(%r14), %rcx
testq %rcx, %rcx
je 0x8983
movq 0x8(%rcx), %rax
jmp 0x8a08
movl %r8d, 0x8(%rsp)
movq %r9, %r12
movq %r11, %rbx
movl $0x10, %edi
callq 0x3913
movq %rax, 0x20(%r14)
movl 0x8(%r14), %edi
incl %edi
callq 0x3913
movq 0x20(%r14), %rcx
movq %rax, (%rcx)
movl 0x8(%r14), %edi
incl %edi
addq %rdi, %rdi
callq 0x3913
movq 0x20(%r14), %rcx
movq %rax, 0x8(%rcx)
cmpl $-0x1, 0x8(%r14)
je 0x89fd
xorl %edx, %edx
movq %rbx, %r11
movq %r12, %r9
movl 0x8(%rsp), %r8d
movq (%rcx), %rax
movb $0x0, (%rax,%rdx)
movq 0x20(%r14), %rcx
movq 0x8(%rcx), %rax
movw $0x0, (%rax,%rdx,2)
incq %rdx
movl 0x8(%r14), %esi
incl %esi
cmpq %rsi, %rdx
jb 0x89d8
jmp 0x8a08
movq %rbx, %r11
movq %r12, %r9
movl 0x8(%rsp), %r8d
movzwl (%rax,%r13,2), %edx
xorl %r12d, %r12d
cmpl $0x7fff, %edx           # imm = 0x7FFF
jne 0x8a37
testb %bpl, %bpl
je 0x8b05
movq %r14, %rdi
movq %r11, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0x2e64
jmp 0x8b05
cmpw (%rax,%r15,2), %r12w
jno 0x8a5d
testb %bpl, %bpl
je 0x8b05
movq %r14, %rdi
movq %r11, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0x2e26
jmp 0x8b05
movb 0xd0(%rsp), %sil
leaq (%rax,%r13,2), %rdi
movzbl %r8b, %r12d
cmpb $0x1, %r8b
jne 0x8a7f
incl %edx
movw %dx, (%rdi)
decw (%rax,%r15,2)
jmp 0x8abb
movq (%rcx), %rsi
addq %r13, %rsi
movl %r12d, %edx
movq %r11, %rbp
movq %r9, %rbx
callq 0x8687
movq 0x20(%r14), %rax
leaq (%r15,%r15), %rdi
addq 0x8(%rax), %rdi
movq (%rax), %rsi
addq %r15, %rsi
movl %r12d, %edx
callq 0x87b0
movb 0xd0(%rsp), %sil
movq %rbx, %r9
movq %rbp, %r11
testb %sil, %sil
je 0x8aff
movl 0xe8(%rsp), %eax
movb 0xe0(%rsp), %cl
movb 0xd8(%rsp), %sil
movq (%r14), %rdx
subq $0x8, %rsp
movzbl %cl, %r10d
movzbl %sil, %esi
movq %r9, %rdi
movq %r13, %rcx
movq %r15, %r8
movq %r11, %r9
pushq %rax
pushq %r10
pushq %r12
callq 0x8894
addq $0x20, %rsp
subl %r13d, %r15d
movl %r15d, %r12d
movl %r12d, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x114d7(%rip), %rax     # 0x19ff8
movq (%rax), %rdi
movq (%r14), %rcx
leaq 0xae60(%rip), %rsi      # 0x1398e
movq %r11, %rdx
xorl %eax, %eax
movq %r11, 0x8(%rsp)
movq %r9, %r13
movl %r8d, %ebp
callq 0x21d0
movl %ebp, %r8d
movb 0xf8(%rsp), %bpl
movq %r13, %r9
movq 0x8(%rsp), %r11
movq (%r12), %rax
jmp 0x8934
movq 0x11492(%rip), %rax     # 0x19ff8
movq (%rax), %rdi
movl %r8d, %ebp
movq (%r14), %r8
leaq 0xae62(%rip), %rsi      # 0x139d8
movq %r11, %rdx
xorl %eax, %eax
movq %r11, %rbx
movq %r9, %r15
callq 0x21d0
movl %ebp, %r8d
movb 0xf8(%rsp), %bpl
movq %r15, %r9
movq %rbx, %r11
movq (%r12), %rax
movl 0x8(%r14), %ecx
jmp 0x8967
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %r11, %rdx
callq 0x2dfe