// File: ncbi[P]amr/fasta2parts.cpp
// Function: (anonymous namespace)::ThisApplication::body() const
void body () const final
  {
    const string fName     =               getArg ("in");
    const size_t parts_max = str2<size_t> (getArg ("parts_max"));
    const string dirName   =               getArg ("dir");
    
    if (parts_max <= 1)
      throw runtime_error ("Number of parts must be >= 2");
      

    const size_t chunk_min = (size_t) getFileSize (fName) / parts_max + 1;

    size_t part = 0;
    unique_ptr<OFStream> out;
    size_t seqSize = 0;
    LineInput f (fName); 
    while (f. nextLine ())
    {
      trimTrailing (f. line);
      if (f. line. empty ())
      	continue;
    	if (   f. line [0] == '>'
    	    && seqSize >= chunk_min
    	    && part < parts_max
    	   )
    	{
    	  out. reset ();
    	  seqSize = 0;
    	}
    	if (! out. get ())
    	{
    	  part++;
    	  ASSERT (part <= parts_max);
    	  out. reset (new OFStream (dirName, toString (part), ""));
    	}
   		*out << f. line << endl;
   		seqSize += f. line. size ();
	  }
  }

// Assembly:
subq $0x598, %rsp            # imm = 0x598
movq %rdi, 0x590(%rsp)
movq 0x590(%rsp), %rax
movq %rax, 0x70(%rsp)
leaq 0x54f(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0xbc40
movq 0x78(%rsp), %rdx
leaq 0x7aa41(%rip), %rsi     # 0x8704b
leaq 0x550(%rsp), %rdi
callq 0xcf30
jmp 0xc619
movq 0x70(%rsp), %rsi
leaq 0x570(%rsp), %rdi
leaq 0x550(%rsp), %rdx
callq 0x3b120
jmp 0xc635
leaq 0x550(%rsp), %rdi
callq 0xbdd8
leaq 0x54f(%rsp), %rdi
callq 0xb730
leaq 0x4ef(%rsp), %rdi
movq %rdi, 0x68(%rsp)
callq 0xbc40
movq 0x68(%rsp), %rdx
leaq 0x7abe8(%rip), %rsi     # 0x87255
leaq 0x4f0(%rsp), %rdi
callq 0xcf30
jmp 0xc67c
movq 0x70(%rsp), %rsi
leaq 0x510(%rsp), %rdi
leaq 0x4f0(%rsp), %rdx
callq 0x3b120
jmp 0xc698
leaq 0x510(%rsp), %rdi
callq 0xe7d0
movq %rax, 0x60(%rsp)
jmp 0xc6ac
leaq 0x510(%rsp), %rdi
callq 0xbdd8
leaq 0x4f0(%rsp), %rdi
callq 0xbdd8
leaq 0x4ef(%rsp), %rdi
callq 0xb730
movq 0x60(%rsp), %rax
movq %rax, 0x530(%rsp)
leaq 0x4a7(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0xbc40
movq 0x58(%rsp), %rdx
leaq 0x7a977(%rip), %rsi     # 0x87075
leaq 0x4a8(%rsp), %rdi
callq 0xcf30
jmp 0xc70d
movq 0x70(%rsp), %rsi
leaq 0x4c8(%rsp), %rdi
leaq 0x4a8(%rsp), %rdx
callq 0x3b120
jmp 0xc729
leaq 0x4a8(%rsp), %rdi
callq 0xbdd8
leaq 0x4a7(%rsp), %rdi
callq 0xb730
cmpq $0x1, 0x530(%rsp)
ja 0xc8cc
movl $0x10, %edi
callq 0xb380
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x50(%rsp)
leaq 0x7aa61(%rip), %rsi     # 0x871cf
callq 0xb2c0
jmp 0xc775
movq 0x50(%rsp), %rdi
movq 0xa4867(%rip), %rsi     # 0xb0fe8
movq 0xa47e8(%rip), %rdx     # 0xb0f70
callq 0xbbd0
jmp 0xcf2d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x540(%rsp)
movl %eax, 0x53c(%rsp)
jmp 0xc7c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x540(%rsp)
movl %eax, 0x53c(%rsp)
leaq 0x550(%rsp), %rdi
callq 0xbdd8
leaq 0x54f(%rsp), %rdi
callq 0xb730
jmp 0xcf20
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x540(%rsp)
movl %eax, 0x53c(%rsp)
jmp 0xc835
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x540(%rsp)
movl %eax, 0x53c(%rsp)
jmp 0xc828
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x540(%rsp)
movl %eax, 0x53c(%rsp)
leaq 0x510(%rsp), %rdi
callq 0xbdd8
leaq 0x4f0(%rsp), %rdi
callq 0xbdd8
leaq 0x4ef(%rsp), %rdi
callq 0xb730
jmp 0xcf13
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x540(%rsp)
movl %eax, 0x53c(%rsp)
jmp 0xc87e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x540(%rsp)
movl %eax, 0x53c(%rsp)
leaq 0x4a8(%rsp), %rdi
callq 0xbdd8
leaq 0x4a7(%rsp), %rdi
callq 0xb730
jmp 0xcf13
movq 0x50(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x540(%rsp)
movl %eax, 0x53c(%rsp)
callq 0xb530
jmp 0xcf06
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x540(%rsp)
movl %eax, 0x53c(%rsp)
jmp 0xcf06
leaq 0x570(%rsp), %rdi
callq 0x16e50
movq %rax, 0x48(%rsp)
jmp 0xc8e0
movq 0x48(%rsp), %rax
movq 0x530(%rsp), %rcx
xorl %edx, %edx
movl %edx, 0x44(%rsp)
divq %rcx
incq %rax
movq %rax, 0x498(%rsp)
movq $0x0, 0x490(%rsp)
leaq 0x488(%rsp), %rdi
callq 0xea00
movl 0x44(%rsp), %edx
movq $0x0, 0x480(%rsp)
leaq 0x1d8(%rsp), %rdi
leaq 0x570(%rsp), %rsi
callq 0xea30
jmp 0xc941
jmp 0xc943
leaq 0x1d8(%rsp), %rdi
callq 0xfeb0
movb %al, 0x43(%rsp)
jmp 0xc956
movb 0x43(%rsp), %al
testb $0x1, %al
jne 0xc963
jmp 0xceb0
leaq 0x440(%rsp), %rdi
callq 0x13210
jmp 0xc972
leaq 0x1d8(%rsp), %rdi
addq $0x268, %rdi            # imm = 0x268
callq 0xbb60
testb $0x1, %al
jne 0xc98c
jmp 0xc9c0
jmp 0xc943
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x540(%rsp)
movl %eax, 0x53c(%rsp)
jmp 0xcef9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x540(%rsp)
movl %eax, 0x53c(%rsp)
jmp 0xceec
leaq 0x440(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xbd90
movq %rax, 0x38(%rsp)
jmp 0xc9d8
movq 0x38(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x3e, %eax
jne 0xca26
movq 0x480(%rsp), %rax
cmpq 0x498(%rsp), %rax
jb 0xca26
movq 0x490(%rsp), %rax
cmpq 0x530(%rsp), %rax
jae 0xca26
leaq 0x488(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xeaa0
movq $0x0, 0x480(%rsp)
leaq 0x488(%rsp), %rdi
callq 0xead0
cmpq $0x0, %rax
jne 0xce47
movq 0x490(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x490(%rsp)
callq 0xb090
movl $0x0, (%rax)
movq 0x490(%rsp), %rax
cmpq 0x530(%rsp), %rax
jbe 0xccf9
callq 0xb850
cmpl $0x0, %eax
jne 0xccef
leaq 0x137(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0xbc40
movq 0x30(%rsp), %rdx
leaq 0x7a74e(%rip), %rsi     # 0x871ec
leaq 0x138(%rsp), %rdi
callq 0xcf30
jmp 0xcaad
leaq 0x110(%rsp), %rdi
movl $0x5e, %esi
callq 0xec40
jmp 0xcac1
leaq 0x158(%rsp), %rdi
leaq 0x138(%rsp), %rsi
leaq 0x110(%rsp), %rdx
callq 0xeb50
jmp 0xcae0
leaq 0x7a71e(%rip), %rdx     # 0x87205
leaq 0x178(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0xeb00
jmp 0xcafe
leaq 0xcf(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0xbc40
movq 0x28(%rsp), %rdx
leaq 0x7a6ef(%rip), %rsi     # 0x8720b
leaq 0xd0(%rsp), %rdi
callq 0xcf30
jmp 0xcb2b
leaq 0x7ad72(%rip), %rdx     # 0x878a4
leaq 0xf0(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0xeb00
jmp 0xcb49
leaq 0x198(%rsp), %rdi
leaq 0x178(%rsp), %rsi
leaq 0xf0(%rsp), %rdx
callq 0xeb50
jmp 0xcb68
leaq 0x7a6de(%rip), %rdx     # 0x8724d
leaq 0x1b8(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0xeb00
jmp 0xcb86
leaq 0x1b8(%rsp), %rdi
callq 0x114d0
jmp 0xcb95
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x540(%rsp)
movl %eax, 0x53c(%rsp)
jmp 0xccdd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x540(%rsp)
movl %eax, 0x53c(%rsp)
jmp 0xccd0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x540(%rsp)
movl %eax, 0x53c(%rsp)
jmp 0xccc3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x540(%rsp)
movl %eax, 0x53c(%rsp)
jmp 0xccb6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x540(%rsp)
movl %eax, 0x53c(%rsp)
jmp 0xcc9c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x540(%rsp)
movl %eax, 0x53c(%rsp)
jmp 0xcc8f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x540(%rsp)
movl %eax, 0x53c(%rsp)
jmp 0xcc82
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x540(%rsp)
movl %eax, 0x53c(%rsp)
jmp 0xcc75
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x540(%rsp)
movl %eax, 0x53c(%rsp)
leaq 0x1b8(%rsp), %rdi
callq 0xbdd8
leaq 0x198(%rsp), %rdi
callq 0xbdd8
leaq 0xf0(%rsp), %rdi
callq 0xbdd8
leaq 0xd0(%rsp), %rdi
callq 0xbdd8
leaq 0xcf(%rsp), %rdi
callq 0xb730
leaq 0x178(%rsp), %rdi
callq 0xbdd8
leaq 0x158(%rsp), %rdi
callq 0xbdd8
leaq 0x110(%rsp), %rdi
callq 0xbdd8
leaq 0x138(%rsp), %rdi
callq 0xbdd8
leaq 0x137(%rsp), %rdi
callq 0xb730
jmp 0xceec
movl $0x1, %edi
callq 0xb860
movl $0x200, %edi            # imm = 0x200
callq 0xb690
movq %rax, 0x20(%rsp)
jmp 0xcd0a
movb $0x1, 0x86(%rsp)
leaq 0xa8(%rsp), %rdi
leaq 0x490(%rsp), %rsi
callq 0xed80
jmp 0xcd29
leaq 0x87(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0xbc40
movq 0x18(%rsp), %rdx
leaq 0x7cb87(%rip), %rsi     # 0x898ce
leaq 0x88(%rsp), %rdi
callq 0xcf30
jmp 0xcd56
movq 0x20(%rsp), %rdi
leaq 0x4c8(%rsp), %rsi
leaq 0xa8(%rsp), %rdx
leaq 0x88(%rsp), %rcx
callq 0xee20
jmp 0xcd7a
movq 0x20(%rsp), %rsi
movb $0x0, 0x86(%rsp)
leaq 0x488(%rsp), %rdi
callq 0xeaa0
leaq 0x88(%rsp), %rdi
callq 0xbdd8
leaq 0x87(%rsp), %rdi
callq 0xb730
leaq 0xa8(%rsp), %rdi
callq 0xbdd8
jmp 0xce47
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x540(%rsp)
movl %eax, 0x53c(%rsp)
jmp 0xce27
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x540(%rsp)
movl %eax, 0x53c(%rsp)
jmp 0xce0d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x540(%rsp)
movl %eax, 0x53c(%rsp)
leaq 0x88(%rsp), %rdi
callq 0xbdd8
leaq 0x87(%rsp), %rdi
callq 0xb730
leaq 0xa8(%rsp), %rdi
callq 0xbdd8
testb $0x1, 0x86(%rsp)
jne 0xce33
jmp 0xce42
movq 0x20(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0xb6a0
jmp 0xceec
leaq 0x488(%rsp), %rdi
callq 0xeef0
movq %rax, 0x10(%rsp)
jmp 0xce5b
movq 0x10(%rsp), %rdi
leaq 0x440(%rsp), %rsi
callq 0xb610
movq %rax, 0x8(%rsp)
jmp 0xce74
movq 0x8(%rsp), %rdi
movq 0xa40d0(%rip), %rsi     # 0xb0f50
callq 0xb6f0
jmp 0xce87
leaq 0x1d8(%rsp), %rdi
addq $0x268, %rdi            # imm = 0x268
callq 0xb4f0
addq 0x480(%rsp), %rax
movq %rax, 0x480(%rsp)
jmp 0xc943
leaq 0x1d8(%rsp), %rdi
callq 0xef20
leaq 0x488(%rsp), %rdi
callq 0xef70
leaq 0x4c8(%rsp), %rdi
callq 0xbdd8
leaq 0x570(%rsp), %rdi
callq 0xbdd8
addq $0x598, %rsp            # imm = 0x598
retq
leaq 0x1d8(%rsp), %rdi
callq 0xef20
leaq 0x488(%rsp), %rdi
callq 0xef70
leaq 0x4c8(%rsp), %rdi
callq 0xbdd8
leaq 0x570(%rsp), %rdi
callq 0xbdd8
movq 0x540(%rsp), %rdi
callq 0xbc30
nopl (%rax)