// File: /workspace/github_c_makefile_star2_O2/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, %r14
movq %rdi, %r12
movb 0xf8(%rsp), %bpl
movl %ebp, %r13d
xorb $0x1, %r13b
movq 0xf0(%rsp), %rbx
xorl %r15d, %r15d
testq %rsi, %rsi
setns %al
cmovgq %rsi, %r15
orb %r13b, %al
jne 0x7481
movq (%rbx), %rax
cmpq $0x7f, %rax
jbe 0x7695
incq %rax
movq %rax, (%rbx)
xorl %r15d, %r15d
movl 0x8(%r12), %ecx
cmpq %rcx, %r15
jae 0x7720
cmpq %r14, %rcx
setge %al
cmovlq %rcx, %r14
orb %r13b, %al
jne 0x74b4
movq (%rbx), %rax
cmpq $0x7f, %rax
jbe 0x76da
incq %rax
movq %rax, (%rbx)
movq %rcx, %r14
movq 0x20(%r12), %rcx
testq %rcx, %rcx
jne 0x7535
movl %r8d, 0x8(%rsp)
movq %r9, %r13
movq %r11, %rbx
pushq $0x10
popq %rdi
callq 0x2752
movq %rax, 0x20(%r12)
movl 0x8(%r12), %edi
incl %edi
callq 0x2752
movq 0x20(%r12), %rcx
movq %rax, (%rcx)
movl 0x8(%r12), %edi
incl %edi
addq %rdi, %rdi
callq 0x2752
movq 0x20(%r12), %rcx
movq %rax, 0x8(%rcx)
xorl %eax, %eax
movl 0x8(%r12), %edx
incl %edx
cmpq %rdx, %rax
jae 0x752a
movq (%rcx), %rcx
movb $0x0, (%rcx,%rax)
movq 0x20(%r12), %rcx
movq 0x8(%rcx), %rdx
andw $0x0, (%rdx,%rax,2)
incq %rax
jmp 0x7504
movq %rbx, %r11
movq %r13, %r9
movl 0x8(%rsp), %r8d
movq 0x8(%rcx), %rax
movzwl (%rax,%r15,2), %edx
xorl %ebx, %ebx
cmpw $0x7fff, %dx            # imm = 0x7FFF
jne 0x7587
testb %bpl, %bpl
je 0x7681
movq 0xfaa1(%rip), %r13      # 0x16ff8
movq (%r13), %rdi
movq (%r12), %rcx
leaq 0xa3fb(%rip), %rsi      # 0x11961
xorl %ebx, %ebx
movq %r11, %rdx
movq %r15, %r8
movq %r14, %r9
xorl %eax, %eax
callq 0x21c0
movq (%r13), %rcx
leaq 0xa40b(%rip), %rdi      # 0x1198e
pushq $0x19
jmp 0x75cc
cmpw (%rax,%r14,2), %bx
jno 0x75da
testb %bpl, %bpl
je 0x7681
movq 0xfa5a(%rip), %r13      # 0x16ff8
movq (%r13), %rdi
movq (%r12), %rcx
leaq 0xa3b4(%rip), %rsi      # 0x11961
xorl %ebx, %ebx
movq %r11, %rdx
movq %r15, %r8
movq %r14, %r9
xorl %eax, %eax
callq 0x21c0
movq (%r13), %rcx
leaq 0xa3de(%rip), %rdi      # 0x119a8
pushq $0x1a
popq %rsi
pushq $0x1
popq %rdx
callq 0x22b0
jmp 0x7681
movb 0xd0(%rsp), %sil
leaq (%rax,%r15,2), %rdi
movzbl %r8b, %ebx
cmpb $0x1, %r8b
jne 0x75fc
incl %edx
movw %dx, (%rdi)
decw (%rax,%r14,2)
jmp 0x7637
movq (%rcx), %rsi
addq %r15, %rsi
movl %ebx, %edx
movq %r11, %rbp
movq %r9, %r13
callq 0x717b
movq 0x20(%r12), %rax
leaq (%r14,%r14), %rdi
addq 0x8(%rax), %rdi
movq (%rax), %rsi
addq %r14, %rsi
movl %ebx, %edx
callq 0x72cb
movb 0xd0(%rsp), %sil
movq %r13, %r9
movq %rbp, %r11
testb %sil, %sil
je 0x767b
movl 0xe8(%rsp), %eax
movb 0xe0(%rsp), %cl
movb 0xd8(%rsp), %sil
movq (%r12), %rdx
subq $0x8, %rsp
movzbl %cl, %r10d
movzbl %sil, %esi
movq %r9, %rdi
movq %r15, %rcx
movq %r14, %r8
movq %r11, %r9
pushq %rax
pushq %r10
pushq %rbx
callq 0x73d6
addq $0x20, %rsp
subl %r15d, %r14d
movl %r14d, %ebx
movl %ebx, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xf95c(%rip), %rax      # 0x16ff8
movq (%rax), %rdi
movq (%r12), %rcx
leaq 0xa234(%rip), %rsi      # 0x118de
movq %r11, %rdx
xorl %eax, %eax
movq %r11, 0x8(%rsp)
movq %r9, %r15
movl %r8d, %ebp
callq 0x21c0
movl %ebp, %r8d
movb 0xf8(%rsp), %bpl
movq %r15, %r9
movq 0x8(%rsp), %r11
movq (%rbx), %rax
jmp 0x7478
movq 0xf917(%rip), %rax      # 0x16ff8
movq (%rax), %rdi
movl %r8d, %ebp
movq (%r12), %r8
leaq 0xa236(%rip), %rsi      # 0x11928
movq %r11, %rdx
xorl %eax, %eax
movq %r11, %r14
movq %r9, %r13
callq 0x21c0
movl %ebp, %r8d
movb 0xf8(%rsp), %bpl
movq %r13, %r9
movq %r14, %r11
movq (%rbx), %rax
movl 0x8(%r12), %ecx
jmp 0x74ab
movq (%r12), %rcx
leaq 0xa1ec(%rip), %rsi      # 0x11917
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r11, %rdx
xorl %eax, %eax
callq 0x2290
pushq $0x18
popq %rsi
movq %rbx, %rdi
callq 0x2724
pushq $0x1
popq %rdi
callq 0x22a0