// File: /workspace/github_cpp_makefile_star2_O2/ncbi[P]amr/tsv.cpp
// Function: Common_sp::TextTable::merge(unsigned long, unsigned long, Common_sp::Vector<unsigned long> const&, Common_sp::Vector<unsigned long> const&, Common_sp::Vector<unsigned long> const&, Common_sp::Vector<unsigned long> const&)
void TextTable::merge (RowNum toRowNum,
                       RowNum fromRowNum,
                       const Vector<ColNum> &sum,
                       const Vector<ColNum> &minV,
                       const Vector<ColNum> &maxV,
                       const Vector<ColNum> &aggr) 
{
  ASSERT (toRowNum < fromRowNum);
  
        StringVector& to   = rows [toRowNum];
  const StringVector& from = rows [fromRowNum];

  for (const ColNum i : sum)
  {
    const Header& h = header [i];
    ASSERT (h. numeric);
    ostringstream oss;
    ONumber on (oss, h. decimals, h. scientific);
    const string& s1 = to   [i];
    const string& s2 = from [i];
    const double d1 = strNull (s1) ? 0.0 : stod (s1);
    const double d2 = strNull (s2) ? 0.0 : stod (s2);
    oss << (d1 + d2);
    to [i] = oss. str ();
  }

  for (const ColNum i : minV)
    if (   to [i]. empty ()
        || (   ! from [i]. empty ()
            && compare (to, from, i) == 1
           )
       )
      to [i] = from [i];

  for (const ColNum i : maxV)
    if (   to [i]. empty ()
        || (   ! from [i]. empty ()
            && compare (to, from, i) == -1
           )
       )
      to [i] = from [i];

  for (const ColNum i : aggr)
  {
    if (from [i]. empty ())
      continue;
    if (contains (from [i], aggr_sep))
      throw runtime_error ("Cannot aggregate column " + header [i]. name + " for row " + to_string (fromRowNum + 1) + " because it contains " + strQuote (string (1, aggr_sep)));
    if (to [i]. empty ())
      to [i] = from [i];
    else
      aggregate (to [i], from [i], aggr_sep);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2a8, %rsp            # imm = 0x2A8
movq %r9, 0x118(%rsp)
movq %r8, 0x110(%rsp)
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %r15
callq 0xb060
movq %rax, 0x120(%rsp)
andl $0x0, (%rax)
cmpq %r12, %r14
jae 0x53f44
movq %r15, %r13
addq $0x50, %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x201be
movq %rax, %r14
movq %r15, %rdi
movq %r12, 0x108(%rsp)
movq %r12, %rsi
callq 0x201be
movq %rax, %r12
movq (%rbx), %r15
movq 0x8(%rbx), %rax
movq %rax, 0x128(%rsp)
movq %r13, 0x10(%rsp)
leaq 0x30(%r13), %rax
movq %rax, 0x38(%rsp)
cmpq 0x128(%rsp), %r15
je 0x53b93
movq (%r15), %r13
movq 0x38(%rsp), %rdi
movq %r13, %rsi
callq 0x55318
movq 0x120(%rsp), %rcx
andl $0x0, (%rcx)
cmpb $0x0, 0x30(%rax)
je 0x53d60
movq %rax, %rbx
leaq 0x130(%rsp), %rbp
movq %rbp, %rdi
callq 0xb790
movq 0x38(%rbx), %rdx
movzbl 0x31(%rbx), %ecx
leaq 0x18(%rsp), %rdi
movq %rbp, %rsi
callq 0x3c1e4
movq %r14, %rdi
movq %r13, %rsi
callq 0x1d5ec
movq %rax, %rbx
movq %r12, %rdi
movq %r13, %rsi
callq 0x1d398
movq %rax, %rbp
movq %rbx, %rdi
callq 0x553c9
xorpd %xmm0, %xmm0
movsd %xmm0, 0x40(%rsp)
testb %al, %al
jne 0x53af1
movq %rbx, %rdi
xorl %esi, %esi
callq 0x555bb
movsd %xmm0, 0x40(%rsp)
movq %rbp, %rdi
callq 0x553c9
xorpd %xmm0, %xmm0
testb %al, %al
jne 0x53b0b
movq %rbp, %rdi
xorl %esi, %esi
callq 0x555bb
movsd 0x40(%rsp), %xmm1
addsd %xmm0, %xmm1
leaq 0x130(%rsp), %rdi
movapd %xmm1, %xmm0
callq 0xb920
leaq 0x48(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0xb8f0
movq %r14, %rdi
movq %r13, %rsi
callq 0x1d5ec
movq %rax, %rdi
leaq 0x48(%rsp), %rbx
movq %rbx, %rsi
callq 0xb6f0
movq %rbx, %rdi
callq 0xbb68
movq 0x18(%rsp), %rax
movq (%rax), %rcx
movq -0x18(%rcx), %rdx
movl 0x28(%rsp), %esi
movl %esi, 0x18(%rax,%rdx)
movq -0x18(%rcx), %rcx
movq 0x20(%rsp), %rdx
movq %rdx, 0x8(%rax,%rcx)
leaq 0x130(%rsp), %rdi
callq 0xb120
addq $0x8, %r15
jmp 0x53a54
movq 0x110(%rsp), %rax
movq (%rax), %r13
movq 0x8(%rax), %rbp
movq 0x10(%rsp), %r15
cmpq %rbp, %r13
je 0x53c19
movq (%r13), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1d5ec
cmpq $0x0, 0x8(%rax)
je 0x53bea
movq %r12, %rdi
movq %rbx, %rsi
callq 0x1d398
cmpq $0x0, 0x8(%rax)
je 0x53c13
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x52d4c
cmpl $0x1, %eax
jne 0x53c13
movq %r12, %rdi
movq %rbx, %rsi
callq 0x1d398
movq %rax, %r15
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1d5ec
movq %rax, %rdi
movq %r15, %rsi
movq 0x10(%rsp), %r15
callq 0xb350
addq $0x8, %r13
jmp 0x53ba7
movq 0x118(%rsp), %rax
movq (%rax), %r13
movq 0x8(%rax), %rbp
cmpq %rbp, %r13
je 0x53c9a
movq (%r13), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1d5ec
cmpq $0x0, 0x8(%rax)
je 0x53c6b
movq %r12, %rdi
movq %rbx, %rsi
callq 0x1d398
cmpq $0x0, 0x8(%rax)
je 0x53c94
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x52d4c
cmpl $-0x1, %eax
jne 0x53c94
movq %r12, %rdi
movq %rbx, %rsi
callq 0x1d398
movq %rax, %r15
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1d5ec
movq %rax, %rdi
movq %r15, %rsi
movq 0x10(%rsp), %r15
callq 0xb350
addq $0x8, %r13
jmp 0x53c28
movq 0x2e0(%rsp), %rax
movq (%rax), %rbp
movq 0x8(%rax), %rbx
cmpq %rbx, %rbp
je 0x53d4e
movq (%rbp), %r15
movq %r12, %rdi
movq %r15, %rsi
callq 0x1d398
cmpq $0x0, 0x8(%rax)
je 0x53d45
movq %r12, %rdi
movq %r15, %rsi
callq 0x1d398
movq %rax, %rdi
pushq $0x2c
popq %rsi
callq 0x1c948
testb %al, %al
jne 0x53e3a
movq %r14, %rdi
movq %r15, %rsi
callq 0x1d5ec
cmpq $0x0, 0x8(%rax)
je 0x53d21
movq %r14, %rdi
movq %r15, %rsi
callq 0x1d5ec
movq %rax, %r13
movq %r12, %rdi
movq %r15, %rsi
callq 0x1d398
movq %r13, %rdi
movq %rax, %rsi
pushq $0x2c
popq %rdx
callq 0x557b9
jmp 0x53d45
movq %r12, %rdi
movq %r15, %rsi
callq 0x1d398
movq %rax, %r13
movq %r14, %rdi
movq %r15, %rsi
callq 0x1d5ec
movq %rax, %rdi
movq %r13, %rsi
callq 0xb350
addq $0x8, %rbp
jmp 0x53ca9
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xb6c0
testl %eax, %eax
jne 0x5401e
leaq 0xb835(%rip), %rsi      # 0x5f5a9
leaq 0xc8(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x1b7b6
leaq 0xa8(%rsp), %rdi
movl $0x274, %esi            # imm = 0x274
callq 0x1caa3
leaq 0xe8(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
leaq 0xa8(%rsp), %rdx
callq 0x1ca3c
leaq 0x5e27(%rip), %rdx      # 0x59be3
leaq 0x18(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x1b92d
leaq 0xbb3d(%rip), %rsi      # 0x5f912
leaq 0x68(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0x1b7b6
leaq 0x7b53(%rip), %rdx      # 0x5b93e
leaq 0x88(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x1b92d
leaq 0x48(%rsp), %rdi
leaq 0x18(%rsp), %rsi
leaq 0x88(%rsp), %rdx
callq 0x1ca3c
leaq 0xbb9e(%rip), %rdx      # 0x5f9b9
leaq 0x130(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x1b92d
leaq 0x130(%rsp), %rdi
callq 0x224fc
pushq $0x10
popq %rdi
callq 0xb300
movq %rax, %r14
movq 0x38(%rsp), %rdi
movq %r15, %rsi
callq 0x55318
addq $0x8, %rax
leaq 0xbb67(%rip), %rsi      # 0x5f9c4
leaq 0xc8(%rsp), %rdi
movq %rax, %rdx
callq 0x1b8b7
leaq 0xbb69(%rip), %rdx      # 0x5f9dd
leaq 0xe8(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x1b92d
movq 0x108(%rsp), %rsi
incq %rsi
leaq 0xa8(%rsp), %rdi
callq 0x1c047
leaq 0x18(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
leaq 0xa8(%rsp), %rdx
callq 0x1ca3c
leaq 0xbb25(%rip), %rdx      # 0x5f9e7
leaq 0x48(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x1b92d
leaq 0x78(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x68(%rsp), %rdi
pushq $0x1
popq %rsi
pushq $0x2c
popq %rdx
callq 0xb670
leaq 0x88(%rsp), %rdi
leaq 0x68(%rsp), %rsi
pushq $0x22
popq %rdx
callq 0x243b1
leaq 0x130(%rsp), %rdi
leaq 0x48(%rsp), %rsi
leaq 0x88(%rsp), %rdx
callq 0x1ca3c
movb $0x1, %bpl
leaq 0x130(%rsp), %rsi
movq %r14, %rdi
callq 0xb940
xorl %ebp, %ebp
movq 0x300b3(%rip), %rsi     # 0x83fe8
movq 0x30024(%rip), %rdx     # 0x83f60
movq %r14, %rdi
callq 0xb9d0
callq 0xb6c0
testl %eax, %eax
jne 0x5401e
leaq 0xb651(%rip), %rsi      # 0x5f5a9
leaq 0xc8(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x1b7b6
leaq 0xa8(%rsp), %rdi
movl $0x26c, %esi            # imm = 0x26C
callq 0x1caa3
leaq 0xe8(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
leaq 0xa8(%rsp), %rdx
callq 0x1ca3c
leaq 0x5c43(%rip), %rdx      # 0x59be3
leaq 0x18(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x1b92d
leaq 0xb959(%rip), %rsi      # 0x5f912
leaq 0x68(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0x1b7b6
leaq 0x796f(%rip), %rdx      # 0x5b93e
leaq 0x88(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x1b92d
leaq 0x48(%rsp), %rdi
leaq 0x18(%rsp), %rsi
leaq 0x88(%rsp), %rdx
callq 0x1ca3c
leaq 0xb9a4(%rip), %rdx      # 0x5f9a3
leaq 0x130(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x1b92d
leaq 0x130(%rsp), %rdi
callq 0x224fc
pushq $0x1
popq %rdi
callq 0xb6d0
jmp 0x54062
jmp 0x54074
jmp 0x5409a
jmp 0x540c3
jmp 0x540e9
jmp 0x5410d
movq %rax, %rbx
leaq 0x130(%rsp), %rdi
callq 0xbb68
jmp 0x54053
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x88(%rsp), %rdi
callq 0xbb68
jmp 0x5408e
movq %rax, %rbx
leaq 0x130(%rsp), %rdi
callq 0xbb68
jmp 0x54077
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0xbb68
jmp 0x5409d
jmp 0x54134
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x68(%rsp), %rdi
callq 0xbb68
jmp 0x540b7
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0xbb68
jmp 0x540c6
jmp 0x54160
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x48(%rsp), %rdi
callq 0xbb68
jmp 0x540dd
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0xbb68
jmp 0x540ec
jmp 0x54172
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x18(%rsp), %rdi
callq 0xbb68
jmp 0x540fe
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0xbb68
jmp 0x54110
movq %rax, %rbx
movb $0x1, %bpl
leaq 0xa8(%rsp), %rdi
callq 0xbb68
jmp 0x54125
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
callq 0xbb68
jmp 0x54137
movq %rax, %rbx
movb $0x1, %bpl
leaq 0xe8(%rsp), %rdi
callq 0xbb68
jmp 0x5414c
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0xbb68
jmp 0x54163
movq %rax, %rbx
movb $0x1, %bpl
leaq 0xc8(%rsp), %rdi
callq 0xbb68
testb %bpl, %bpl
jne 0x5417a
jmp 0x541d2
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0xbb68
jmp 0x541d2
movq %rax, %rbx
jmp 0x541d2
movq %rax, %rbx
movq %r14, %rdi
callq 0xb470
jmp 0x541d2
jmp 0x541a0
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0xbb68
jmp 0x541a3
movq %rax, %rbx
jmp 0x541c5
jmp 0x541a0
jmp 0x541a0
jmp 0x541a0
movq %rax, %rbx
movq 0x18(%rsp), %rax
movq (%rax), %rcx
movq -0x18(%rcx), %rdx
movl 0x28(%rsp), %esi
movl %esi, 0x18(%rax,%rdx)
movq -0x18(%rcx), %rcx
movq 0x20(%rsp), %rdx
movq %rdx, 0x8(%rax,%rcx)
leaq 0x130(%rsp), %rdi
callq 0xb120
movq %rbx, %rdi
callq 0xba30