// File: /workspace/github_cpp_makefile_star2_O1/ncbi[P]amr/tsv.cpp
// Function: Common_sp::TextTable::group(Common_sp::StringVector const&, Common_sp::StringVector const&, Common_sp::StringVector const&, Common_sp::StringVector const&, Common_sp::StringVector const&)
void TextTable::group (const StringVector &by,
                       const StringVector &sum,
                       const StringVector &minV,
                       const StringVector &maxV,
                       const StringVector &aggr)
{
  const Vector<ColNum> byIndex   (columns2nums (by));
  const Vector<ColNum> sumIndex  (columns2nums (sum));
  const Vector<ColNum> minIndex  (columns2nums (minV));
  const Vector<ColNum> maxIndex  (columns2nums (maxV));
  const Vector<ColNum> aggrIndex (columns2nums (aggr));
  
  // QC
  {
    ColumnPartitionQC cp;
    cp. add (by, "group by");
    cp. add (sum, "sum");
    cp. add (minV, "min");
    cp. add (maxV, "max");
    cp. add (aggr, "aggregation");
  }
  for (const string& s : sum)
    if (! header [col2num (s)]. numeric)
      throw runtime_error ("Summation column " + strQuote (s) + " is not numeric");

  sort (by);
  
  RowNum i = 0;  
  FFOR_START (RowNum, j, 1, rows. size ())
  {
    ASSERT (i < j);
    if (rows [i]. same (rows [j], byIndex))
      merge (i, j, sumIndex, minIndex, maxIndex, aggrIndex);
    else
    {
      i++;
      if (i < j)
        rows [i] = std::move (rows [j]);
    }
  }
  if (! rows. empty ())
    i++;

  ASSERT (rows. size () >= i);
  FFOR (RowNum, k, rows. size () - i)
    rows. pop_back ();
    
  StringVector newColumns;
  newColumns << by << sum << minV << maxV << aggr;
  filterColumns (newColumns);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
movq %r9, %r13
movq %r8, 0x90(%rsp)
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %rdx
movq %rdi, %rbp
leaq 0x1d8(%rsp), %rdi
movq %rbp, %rsi
movq %rdx, 0x80(%rsp)
callq 0x86572
leaq 0x1b8(%rsp), %rdi
movq %rbp, %rsi
movq %r14, 0x88(%rsp)
movq %r14, %rdx
callq 0x86572
leaq 0x198(%rsp), %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x86572
leaq 0x178(%rsp), %rdi
movq %rbp, %rsi
movq 0x90(%rsp), %rdx
callq 0x86572
movq %rbx, 0x98(%rsp)
leaq 0x158(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x86572
leaq 0x38(%rsp), %rax
movl $0x0, (%rax)
xorl %ecx, %ecx
movq %rcx, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
leaq 0x20(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xdfee(%rip), %rsi      # 0x9087f
leaq 0xdfef(%rip), %rdx      # 0x90887
leaq 0x10(%rsp), %rdi
callq 0x2fdd8
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
movq 0x80(%rsp), %rsi
callq 0x833b6
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x828d0
movq 0x20(%rsp), %rsi
incq %rsi
callq 0xa5a0
leaq 0x10(%rsp), %rdi
movq %r12, (%rdi)
leaq 0xdfa9(%rip), %rsi      # 0x90888
leaq 0xdfa5(%rip), %rdx      # 0x9088b
callq 0x2fdd8
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
movq 0x88(%rsp), %rsi
callq 0x833b6
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x82919
movq 0x20(%rsp), %rsi
incq %rsi
callq 0xa5a0
leaq 0x10(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x7a60(%rip), %rsi      # 0x8a388
leaq 0x7a5c(%rip), %rdx      # 0x8a38b
callq 0x2fdd8
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
movq 0x98(%rsp), %rsi
callq 0x833b6
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x82962
movq 0x20(%rsp), %rsi
incq %rsi
callq 0xa5a0
leaq 0x10(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x97ec(%rip), %rsi      # 0x8c15d
leaq 0x97e8(%rip), %rdx      # 0x8c160
callq 0x2fdd8
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
movq 0x90(%rsp), %rsi
callq 0x833b6
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x829ab
movq 0x20(%rsp), %rsi
incq %rsi
callq 0xa5a0
leaq 0x10(%rsp), %rdi
movq %r12, (%rdi)
leaq 0xded2(%rip), %rsi      # 0x9088c
leaq 0xded6(%rip), %rdx      # 0x90897
callq 0x2fdd8
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
movq %r13, %rsi
callq 0x833b6
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x829ef
movq 0x20(%rsp), %rsi
incq %rsi
callq 0xa5a0
leaq 0x30(%rsp), %rdi
callq 0x2c75c
movq 0x88(%rsp), %rax
movq (%rax), %r15
movq 0x8(%rax), %rbx
cmpq %rbx, %r15
je 0x82a3a
leaq 0x30(%rbp), %r14
movq %rbp, %rdi
movq %r15, %rsi
callq 0x2edd4
movq %r14, %rdi
movq %rax, %rsi
callq 0x86268
cmpb $0x0, 0x30(%rax)
je 0x82caa
addq $0x20, %r15
cmpq %rbx, %r15
jne 0x82a11
movq %r13, 0x108(%rsp)
movq %rbp, %rdi
movq 0x80(%rsp), %rsi
callq 0x826c6
leaq 0x50(%rbp), %r15
movq 0x58(%rbp), %r13
movq %rbp, 0xa0(%rsp)
subq 0x50(%rbp), %r13
sarq $0x5, %r13
cmpq $0x2, %r13
jb 0x82b4d
movl $0x1, %ebp
xorl %r12d, %r12d
callq 0xa070
movq %rax, 0x110(%rsp)
movq 0x110(%rsp), %rax
movl $0x0, (%rax)
cmpq %rbp, %r12
jae 0x82d18
movq %r15, %rdi
movq %r12, %rsi
callq 0x3208a
movq %rax, %r14
movq %r15, %rdi
movq %rbp, %rsi
callq 0x3208a
movq %r14, %rdi
movq %rax, %rsi
leaq 0x1d8(%rsp), %rdx
callq 0x43160
testb %al, %al
je 0x82b09
leaq 0x158(%rsp), %rax
movq %rax, (%rsp)
movq 0xa0(%rsp), %rdi
movq %r12, %rsi
movq %rbp, %rdx
leaq 0x1b8(%rsp), %rcx
leaq 0x198(%rsp), %r8
leaq 0x178(%rsp), %r9
callq 0x836d8
jmp 0x82b3f
incq %r12
cmpq %rbp, %r12
jae 0x82b3f
movq %r15, %rdi
movq %rbp, %rsi
callq 0x3208a
movq %rax, %r14
movq %r15, %rdi
movq %r12, %rsi
callq 0x3208a
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
callq 0x32bb2
movb 0x18(%r14), %al
movb %al, 0x18(%rbx)
incq %rbp
cmpq %rbp, %r13
jne 0x82a89
jmp 0x82b50
xorl %r12d, %r12d
movq 0xa0(%rsp), %r13
movq 0x58(%r13), %rbx
xorl %r14d, %r14d
subq 0x50(%r13), %rbx
setne %r14b
addq %r12, %r14
callq 0xa070
movl $0x0, (%rax)
sarq $0x5, %rbx
subq %r14, %rbx
jb 0x82e03
movq 0x98(%rsp), %r14
je 0x82b99
movq %r15, %rdi
callq 0x866ec
decq %rbx
jne 0x82b8c
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rdi
movups %xmm0, 0x9(%rdi)
movaps %xmm0, (%rdi)
movq 0x80(%rsp), %rsi
callq 0x86756
movq %rax, %rdi
movq 0x88(%rsp), %rsi
callq 0x86756
movq %rax, %rdi
movq %r14, %rsi
callq 0x86756
movq %rax, %rdi
movq 0x90(%rsp), %rsi
callq 0x86756
movq %rax, %rdi
movq 0x108(%rsp), %rsi
callq 0x86756
leaq 0x30(%rsp), %rsi
movq %r13, %rdi
callq 0x82498
leaq 0x30(%rsp), %rdi
callq 0x32c12
movq 0x158(%rsp), %rdi
testq %rdi, %rdi
je 0x82c24
movq 0x168(%rsp), %rsi
subq %rdi, %rsi
callq 0xa5a0
movq 0x178(%rsp), %rdi
testq %rdi, %rdi
je 0x82c41
movq 0x188(%rsp), %rsi
subq %rdi, %rsi
callq 0xa5a0
movq 0x198(%rsp), %rdi
testq %rdi, %rdi
je 0x82c5e
movq 0x1a8(%rsp), %rsi
subq %rdi, %rsi
callq 0xa5a0
movq 0x1b8(%rsp), %rdi
testq %rdi, %rdi
je 0x82c7b
movq 0x1c8(%rsp), %rsi
subq %rdi, %rsi
callq 0xa5a0
movq 0x1d8(%rsp), %rdi
testq %rdi, %rdi
je 0x82c98
movq 0x1e8(%rsp), %rsi
subq %rdi, %rsi
callq 0xa5a0
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0xa2c0
movq %rax, %r14
leaq 0x60(%rsp), %rdi
movq %r15, %rsi
movl $0x22, %edx
callq 0x38d2b
leaq 0xdbc8(%rip), %rsi      # 0x90898
leaq 0x10(%rsp), %rdi
leaq 0x60(%rsp), %rdx
callq 0x2c037
leaq 0xdbc4(%rip), %rsi      # 0x908aa
leaq 0x10(%rsp), %rdi
callq 0xaac0
leaq 0x40(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x82db7
movups (%rcx), %xmm0
movups %xmm0, (%r15)
jmp 0x82dc4
callq 0xa6b0
testl %eax, %eax
jne 0x82ea2
leaq 0xf8(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xd8c1(%rip), %rsi      # 0x905f9
leaq 0xd8ca(%rip), %rdx      # 0x90609
leaq 0xe8(%rsp), %rdi
callq 0x2fdd8
leaq 0x118(%rsp), %rdi
movl $0x24d, %esi            # imm = 0x24D
callq 0x2d60a
leaq 0x138(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
leaq 0x118(%rsp), %rdx
callq 0x2d562
leaq 0x7e63(%rip), %rsi      # 0x8abe5
leaq 0x138(%rsp), %rdi
callq 0xaac0
leaq 0x70(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x82eac
movups (%rcx), %xmm0
movups %xmm0, (%r15)
jmp 0x82eb9
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
movq 0x8(%rax), %rdx
leaq 0x30(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movb $0x1, %bpl
movq %r14, %rdi
callq 0xa930
xorl %ebp, %ebp
movq 0x2d1f4(%rip), %rsi     # 0xaffe8
movq 0x2d165(%rip), %rdx     # 0xaff60
movq %r14, %rdi
callq 0xa9b0
callq 0xa6b0
testl %eax, %eax
jne 0x82ea2
leaq 0xf8(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xd7d6(%rip), %rsi      # 0x905f9
leaq 0xd7df(%rip), %rdx      # 0x90609
leaq 0xe8(%rsp), %rdi
callq 0x2fdd8
leaq 0x118(%rsp), %rdi
movl $0x25a, %esi            # imm = 0x25A
callq 0x2d60a
leaq 0x138(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
leaq 0x118(%rsp), %rdx
callq 0x2d562
leaq 0x7d78(%rip), %rsi      # 0x8abe5
leaq 0x138(%rsp), %rdi
callq 0xaac0
leaq 0x70(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x82fac
movups (%rcx), %xmm0
movups %xmm0, (%r15)
jmp 0x82fb9
movl $0x1, %edi
callq 0xa6c0
movq %rdx, 0x60(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x70(%rsp)
movq 0x8(%rax), %rdx
movq %rdx, 0x68(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0xd8(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xd9d5(%rip), %rsi      # 0x908ba
leaq 0xda5c(%rip), %rdx      # 0x90948
leaq 0xc8(%rsp), %rdi
callq 0x2fdd8
leaq 0x9a33(%rip), %rsi      # 0x8c933
leaq 0xc8(%rsp), %rdi
callq 0xaac0
leaq 0xb8(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x82f32
movups (%rcx), %xmm0
movups %xmm0, (%r13)
jmp 0x82f45
movq %rdx, 0xa8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xb8(%rsp)
movq 0x8(%rax), %rsi
leaq 0xa8(%rsp), %rdx
movq %rsi, 0x8(%rdx)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x10(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x2d562
leaq 0xd9cf(%rip), %rsi      # 0x90949
leaq 0x10(%rsp), %rdi
callq 0xaac0
leaq 0x40(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x83032
movups (%rcx), %xmm0
movups %xmm0, (%rbp)
jmp 0x8303f
movq %rdx, 0x60(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x70(%rsp)
movq 0x8(%rax), %rdx
movq %rdx, 0x68(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0xd8(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xd8d5(%rip), %rsi      # 0x908ba
leaq 0xd95c(%rip), %rdx      # 0x90948
leaq 0xc8(%rsp), %rdi
callq 0x2fdd8
leaq 0x9933(%rip), %rsi      # 0x8c933
leaq 0xc8(%rsp), %rdi
callq 0xaac0
leaq 0xb8(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x83060
movups (%rcx), %xmm0
movups %xmm0, (%r13)
jmp 0x83073
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
movq 0x8(%rax), %rdx
leaq 0x30(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
callq 0x3523b
movq %rdx, 0xa8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xb8(%rsp)
movq 0x8(%rax), %rsi
leaq 0xa8(%rsp), %rdx
movq %rsi, 0x8(%rdx)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x10(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x2d562
leaq 0xd8a7(%rip), %rsi      # 0x9094f
leaq 0x10(%rsp), %rdi
callq 0xaac0
leaq 0x40(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x830d3
movups (%rcx), %xmm0
movups %xmm0, (%rbp)
jmp 0x830e0
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
movq 0x8(%rax), %rdx
leaq 0x30(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
callq 0x3523b
jmp 0x8310e
jmp 0x8312a
jmp 0x8314d
jmp 0x83171
jmp 0x83198
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %rbp, %rdi
je 0x8312d
movq 0x40(%rsp), %rsi
incq %rsi
callq 0xa5a0
jmp 0x8312d
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x83150
movq 0x20(%rsp), %rsi
incq %rsi
callq 0xa5a0
jmp 0x83150
jmp 0x831b9
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
cmpq %r13, %rdi
je 0x83174
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0xa5a0
jmp 0x83174
jmp 0x831df
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
cmpq %r12, %rdi
je 0x8319b
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0xa5a0
jmp 0x8319b
jmp 0x83268
movq %rax, %rbx
movq 0x60(%rsp), %rdi
cmpq %r15, %rdi
je 0x831bc
movq 0x70(%rsp), %rsi
incq %rsi
callq 0xa5a0
jmp 0x831bc
jmp 0x83319
movq %rax, %rbx
leaq 0x148(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x831e2
movq 0x148(%rsp), %rsi
incq %rsi
callq 0xa5a0
jmp 0x831e2
movq %rax, %rbx
leaq 0x128(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8326b
movq 0x128(%rsp), %rsi
incq %rsi
callq 0xa5a0
jmp 0x8326b
jmp 0x83319
jmp 0x8321a
jmp 0x83236
jmp 0x8321a
jmp 0x83236
jmp 0x8321a
jmp 0x83236
jmp 0x8321a
jmp 0x83236
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x83239
movq 0x20(%rsp), %rsi
incq %rsi
callq 0xa5a0
jmp 0x83239
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x2c75c
jmp 0x8331c
movq %rax, %rbx
jmp 0x83339
movq %rax, %rbx
jmp 0x83356
movq %rax, %rbx
jmp 0x83373
movq %rax, %rbx
jmp 0x83390
movq %rax, %rbx
movq 0xe8(%rsp), %rdi
cmpq %r14, %rdi
je 0x8331c
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0xa5a0
jmp 0x8331c
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x832b3
movq 0x40(%rsp), %rsi
incq %rsi
callq 0xa5a0
jmp 0x832b3
movq %rax, %rbx
movb $0x1, %bpl
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x832d4
movq 0x20(%rsp), %rsi
incq %rsi
callq 0xa5a0
jmp 0x832d4
jmp 0x83319
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x83306
movq 0x70(%rsp), %rsi
incq %rsi
callq 0xa5a0
jmp 0x83306
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x32c12
jmp 0x8331c
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x8331c
movq %r14, %rdi
callq 0xa440
jmp 0x8331c
jmp 0x83319
jmp 0x83319
movq %rax, %rbx
movq 0x158(%rsp), %rdi
testq %rdi, %rdi
je 0x83339
movq 0x168(%rsp), %rsi
subq %rdi, %rsi
callq 0xa5a0
movq 0x178(%rsp), %rdi
testq %rdi, %rdi
je 0x83356
movq 0x188(%rsp), %rsi
subq %rdi, %rsi
callq 0xa5a0
movq 0x198(%rsp), %rdi
testq %rdi, %rdi
je 0x83373
movq 0x1a8(%rsp), %rsi
subq %rdi, %rsi
callq 0xa5a0
movq 0x1b8(%rsp), %rdi
testq %rdi, %rdi
je 0x83390
movq 0x1c8(%rsp), %rsi
subq %rdi, %rsi
callq 0xa5a0
movq 0x1d8(%rsp), %rdi
testq %rdi, %rdi
je 0x833ad
movq 0x1e8(%rsp), %rsi
subq %rdi, %rsi
callq 0xa5a0
movq %rbx, %rdi
callq 0xaa10
nop