// File: /workspace/github_c_makefile_star2_O0/jsh58[P]Genrich/Genrich.c
// Function: findPeaks
void findPeaks(File out, File log, bool logOpt, bool gzOut,
    Chrom* chrom, int chromLen, int* sample,
    float minPQval, bool qvalOpt, int minLen, int maxGap,
    float minAUC, bool peaksOpt, uint64_t genomeLen,
    bool verbose) {

  // calculate combined p-values for multiple replicates
  if (*sample > 1) {
    combinePval(chrom, chromLen, *sample);
    (*sample)++;
  }

  // calculate genome length (only chroms that are not
  //   skipped and have had p-values calculated)
  bool genomeOpt = false;
  if (! genomeLen) {
    genomeOpt = true;
    for (int i = 0; i < chromLen; i++) {
      Chrom* chr = chrom + i;
      if (! chr->skip && chr->pval[*sample - 1] != NULL) {
        genomeLen += chr->len;
        for (int j = 0; j < chr->bedLen; j += 2)
          genomeLen -= chr->bed[j+1] - chr->bed[j];
      }
    }
  }

  if (verbose) {
    if (peaksOpt) {
      fprintf(stderr, "Peak-calling parameters:\n");
      fprintf(stderr, "  Genome length: %ldbp\n", genomeLen);
      fprintf(stderr, "  Significance threshold: -log(%c) > %.3f\n",
        qvalOpt ? 'q' : 'p', minPQval);
      fprintf(stderr, "  Min. AUC: %.3f\n", minAUC);
      if (minLen)
        fprintf(stderr, "  Min. peak length: %dbp\n", minLen);
      fprintf(stderr, "  Max. gap between sites: %dbp\n", maxGap);
    } else {
      fprintf(stderr, "- peak-calling skipped -\n");
      fprintf(stderr, "  Genome length: %ldbp\n", genomeLen);
    }
  }

  // compute q-values
  if (qvalOpt)
    computeQval(chrom, chromLen, genomeLen, genomeOpt,
      *sample - 1, verbose);

  // call peaks
  if (peaksOpt) {
    uint64_t peakBP = 0;
    int count = callPeaks(out, log, logOpt, gzOut, chrom,
      chromLen, *sample - 1, minPQval, qvalOpt, minAUC,
      minLen, maxGap, &peakBP);
    if (verbose)
      fprintf(stderr, "Peaks identified: %d (%ldbp)\n",
        count, peakBP);
  } else if (logOpt)
    // not calling peaks -- just log pileups and stats
    logIntervals(log, gzOut, chrom, chromLen, *sample - 1,
      qvalOpt);
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x88, %rsp
movq %rsi, %r10
movq %rdi, %r11
movb %cl, %sil
movb %dl, %dil
movb 0xd0(%rsp), %al
movq 0xc8(%rsp), %rcx
movb 0xc0(%rsp), %cl
movl 0xb8(%rsp), %edx
movl 0xb0(%rsp), %edx
movb 0xa8(%rsp), %dl
movq 0xa0(%rsp), %rbx
movq %r11, 0x80(%rsp)
movq %r10, 0x78(%rsp)
andb $0x1, %dil
movb %dil, 0x77(%rsp)
andb $0x1, %sil
movb %sil, 0x76(%rsp)
movq %r8, 0x68(%rsp)
movl %r9d, 0x64(%rsp)
movss %xmm0, 0x60(%rsp)
andb $0x1, %dl
movb %dl, 0x5f(%rsp)
movss %xmm1, 0x58(%rsp)
andb $0x1, %cl
movb %cl, 0x57(%rsp)
andb $0x1, %al
movb %al, 0x56(%rsp)
movq 0xa0(%rsp), %rax
cmpl $0x1, (%rax)
jle 0x65f5
movq 0x68(%rsp), %rdi
movl 0x64(%rsp), %esi
movq 0xa0(%rsp), %rax
movl (%rax), %edx
callq 0x4710
movq 0xa0(%rsp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movb $0x0, 0x55(%rsp)
cmpq $0x0, 0xc8(%rsp)
jne 0x66f8
movb $0x1, 0x55(%rsp)
movl $0x0, 0x50(%rsp)
movl 0x50(%rsp), %eax
cmpl 0x64(%rsp), %eax
jge 0x66f6
movq 0x68(%rsp), %rax
movslq 0x50(%rsp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
testb $0x1, 0xc(%rax)
jne 0x66e4
movq 0x48(%rsp), %rax
movq 0x48(%rax), %rax
movq 0xa0(%rsp), %rcx
movl (%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x66e4
movq 0x48(%rsp), %rax
movl 0x8(%rax), %eax
addq 0xc8(%rsp), %rax
movq %rax, 0xc8(%rsp)
movl $0x0, 0x44(%rsp)
movl 0x44(%rsp), %eax
movq 0x48(%rsp), %rcx
cmpl 0x18(%rcx), %eax
jge 0x66e2
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rax
movl 0x44(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movq 0x48(%rsp), %rcx
movq 0x10(%rcx), %rcx
movslq 0x44(%rsp), %rdx
subl (%rcx,%rdx,4), %eax
movl %eax, %eax
movl %eax, %ecx
movq 0xc8(%rsp), %rax
subq %rcx, %rax
movq %rax, 0xc8(%rsp)
movl 0x44(%rsp), %eax
addl $0x2, %eax
movl %eax, 0x44(%rsp)
jmp 0x6689
jmp 0x66e4
jmp 0x66e6
movl 0x50(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x50(%rsp)
jmp 0x6616
jmp 0x66f8
testb $0x1, 0x56(%rsp)
je 0x6822
testb $0x1, 0x57(%rsp)
je 0x67e8
movq 0x1c8e3(%rip), %rax     # 0x22ff8
movq (%rax), %rdi
leaq 0x18f6c(%rip), %rsi     # 0x1f68b
movb $0x0, %al
callq 0x21c0
movq 0x1c8cb(%rip), %rax     # 0x22ff8
movq (%rax), %rdi
movq 0xc8(%rsp), %rdx
leaq 0x18f66(%rip), %rsi     # 0x1f6a5
movb $0x0, %al
callq 0x21c0
movq 0x1c8ab(%rip), %rax     # 0x22ff8
movq (%rax), %rdi
movb 0x5f(%rsp), %cl
movl $0x70, %edx
movl $0x71, %eax
testb $0x1, %cl
cmovnel %eax, %edx
movss 0x60(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x18f48(%rip), %rsi     # 0x1f6bd
movb $0x1, %al
callq 0x21c0
movq 0x1c875(%rip), %rax     # 0x22ff8
movq (%rax), %rdi
movss 0x58(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x18f51(%rip), %rsi     # 0x1f6e8
movb $0x1, %al
callq 0x21c0
cmpl $0x0, 0xb0(%rsp)
je 0x67c7
movq 0x1c849(%rip), %rax     # 0x22ff8
movq (%rax), %rdi
movl 0xb0(%rsp), %edx
leaq 0x18f3a(%rip), %rsi     # 0x1f6fa
movb $0x0, %al
callq 0x21c0
movq 0x1c82a(%rip), %rax     # 0x22ff8
movq (%rax), %rdi
movl 0xb8(%rsp), %edx
leaq 0x18f35(%rip), %rsi     # 0x1f714
movb $0x0, %al
callq 0x21c0
jmp 0x6820
movq 0x1c809(%rip), %rax     # 0x22ff8
movq (%rax), %rdi
leaq 0x18f3b(%rip), %rsi     # 0x1f734
movb $0x0, %al
callq 0x21c0
movq 0x1c7f1(%rip), %rax     # 0x22ff8
movq (%rax), %rdi
movq 0xc8(%rsp), %rdx
leaq 0x18e8c(%rip), %rsi     # 0x1f6a5
movb $0x0, %al
callq 0x21c0
jmp 0x6822
testb $0x1, 0x5f(%rsp)
je 0x6862
movq 0x68(%rsp), %rdi
movl 0x64(%rsp), %esi
movq 0xc8(%rsp), %rdx
movb 0x55(%rsp), %cl
movq 0xa0(%rsp), %rax
movl (%rax), %r8d
subl $0x1, %r8d
movb 0x56(%rsp), %al
andb $0x1, %cl
andb $0x1, %al
movzbl %cl, %ecx
movzbl %al, %r9d
callq 0x3780
testb $0x1, 0x57(%rsp)
je 0x6922
movq $0x0, 0x38(%rsp)
movb 0x77(%rsp), %dl
movb 0x76(%rsp), %cl
movq 0x68(%rsp), %r8
movl 0x64(%rsp), %r9d
movq 0xa0(%rsp), %rax
movl (%rax), %ebp
subl $0x1, %ebp
movss 0x60(%rsp), %xmm0
movb 0x5f(%rsp), %bl
movss 0x58(%rsp), %xmm1
movl 0xb0(%rsp), %r11d
movl 0xb8(%rsp), %r10d
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
leaq 0x38(%rsp), %rax
andb $0x1, %dl
andb $0x1, %cl
andb $0x1, %bl
movzbl %dl, %edx
movzbl %cl, %ecx
movl %ebp, (%rsp)
movzbl %bl, %ebx
movl %ebx, 0x8(%rsp)
movl %r11d, 0x10(%rsp)
movl %r10d, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0x5f50
movl %eax, 0x34(%rsp)
testb $0x1, 0x56(%rsp)
je 0x6920
movq 0x1c6f2(%rip), %rax     # 0x22ff8
movq (%rax), %rdi
movl 0x34(%rsp), %edx
movq 0x38(%rsp), %rcx
leaq 0x18e35(%rip), %rsi     # 0x1f74e
movb $0x0, %al
callq 0x21c0
jmp 0x6964
testb $0x1, 0x77(%rsp)
je 0x6962
movb 0x76(%rsp), %sil
movq 0x68(%rsp), %rdx
movl 0x64(%rsp), %ecx
movq 0xa0(%rsp), %rax
movl (%rax), %r8d
subl $0x1, %r8d
movb 0x5f(%rsp), %al
movq 0x78(%rsp), %rdi
andb $0x1, %sil
andb $0x1, %al
movzbl %sil, %esi
movzbl %al, %r9d
callq 0x5760
jmp 0x6964
addq $0x88, %rsp
popq %rbx
popq %rbp
retq
nop