// File: Altius[P]hotspot2/src/findVarWidthPeaks.cpp
// Function: main
int main(int argc, const char* argv[])
{
  if (2 != argc)
    {
      cerr << "Usage:  [stdin] | " << argv[0] << " minWidth | [stdout],\n"
	   << "where minWidth is the minimum width (in bp) that a variable-width peak must have to be reported.\n"
	   << "6-column input is required, NOT in sort-bed order, but instead, sorted by column 6, then by column 3.\n"
	   << "The input columns are:  chr, pos-1, pos, ID, score, posSummit,\n"
	   << "where \"score\" is the score (e.g., normalized density) at site \"pos\" on chromosome \"chr\"."
	   << "Rows MUST be grouped by column 6 (i.e., sorted by posSummit);\n"
	   << "the sort order of posSummit can be anything (typicaly numeric, but alphabetic would also work).\n"
	   << "All rows with the same posSummit value (column 6) MUST be sorted in ascending order by pos (column 3).\n"
	   << "There will be 7 columns of output:\n"
	   << "chr, beg, end, ID, maxScore, posWithMaxScore, posSummit,\n"
	   << "where (beg, end] are the coordinates of each output variable-width peak (0-based),\n"
	   << "ID and posSummit echo their input values, posWithMaxScore is the central bp within (beg,end]\n"
	   << "where the maximum score was found, and maxScore is that score.\n"
	   << "**YOU MUST CALL sort-bed ON THE OUTPUT BEFORE USING IT IN bedmap/bedops OPERATIONS**."
	   << endl << endl;
      return -1;
    }

  ios_base::sync_with_stdio(false); // calling this static method in this way turns off checks, and can speed up I/O
  
  if (!parseInputFindPeaksWriteOutput(argv[0], atol(argv[1])))
    return -1;

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x2, %eax
cmpl -0x8(%rbp), %eax
je 0x498f
movq 0xa775(%rip), %rdi      # 0xeff0
leaq 0x599c(%rip), %rsi      # 0xa21e
callq 0x2200
movq %rax, %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x2200
movq %rax, %rdi
leaq 0x5991(%rip), %rsi      # 0xa231
callq 0x2200
movq %rax, %rdi
leaq 0x5999(%rip), %rsi      # 0xa248
callq 0x2200
movq %rax, %rdi
leaq 0x59ec(%rip), %rsi      # 0xa2aa
callq 0x2200
movq %rax, %rdi
leaq 0x5a44(%rip), %rsi      # 0xa311
callq 0x2200
movq %rax, %rdi
leaq 0x5a75(%rip), %rsi      # 0xa351
callq 0x2200
movq %rax, %rdi
leaq 0x5abf(%rip), %rsi      # 0xa3aa
callq 0x2200
movq %rax, %rdi
leaq 0x5aef(%rip), %rsi      # 0xa3e9
callq 0x2200
movq %rax, %rdi
leaq 0x5b41(%rip), %rsi      # 0xa44a
callq 0x2200
movq %rax, %rdi
leaq 0x5b9a(%rip), %rsi      # 0xa4b2
callq 0x2200
movq %rax, %rdi
leaq 0x5baf(%rip), %rsi      # 0xa4d6
callq 0x2200
movq %rax, %rdi
leaq 0x5bda(%rip), %rsi      # 0xa510
callq 0x2200
movq %rax, %rdi
leaq 0x5c1f(%rip), %rsi      # 0xa564
callq 0x2200
movq %rax, %rdi
leaq 0x5c6e(%rip), %rsi      # 0xa5c2
callq 0x2200
movq %rax, %rdi
leaq 0x5c9f(%rip), %rsi      # 0xa602
callq 0x2200
movq %rax, %rdi
movq 0xa646(%rip), %rsi      # 0xefb8
callq 0x2230
movq %rax, %rdi
movq 0xa637(%rip), %rsi      # 0xefb8
callq 0x2230
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x49d7
xorl %edi, %edi
callq 0x20c0
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x2290
movq -0x20(%rbp), %rdi
movq %rax, -0x18(%rbp)
leaq -0x18(%rbp), %rsi
callq 0x3970
xorb $-0x1, %al
testb $0x1, %al
jne 0x49c7
jmp 0x49d0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x49d7
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq