// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/match/randomcodes-correct.c
// Function: gt_randomcodes_correct_process_kmergroup_end
static inline void gt_randomcodes_correct_process_kmergroup_end(
    const GtSeqnumrelpos *snrp, GtRandomcodesCorrectData *cdata)
{
  cdata->nofkmergroups++;
  if (!cdata->alltrusted)
  {
    unsigned int i, max_count = 0, countpos = 0;
    for (i = 0; i < cdata->alphasize; i++)
    {
      if (cdata->count[i] > max_count)
      {
        max_count = cdata->count[i];
        countpos = i;
      }
    }
    if (max_count >= cdata->c)
    {
      const GtUword trusted_char_seqnumrelpos =
        (cdata->kpositions + countpos * cdata->c)[0];
      GtUchar trusted_char = gt_encseq_get_encoded_char_nospecial(cdata->encseq,
          gt_encseq_seqstartpos(cdata->encseq, gt_seqnumrelpos_decode_seqnum(
              snrp,trusted_char_seqnumrelpos)) + gt_seqnumrelpos_decode_relpos(
              snrp,trusted_char_seqnumrelpos) + cdata->k - 1,
          GT_READMODE_FORWARD);
      for (i = 0; i < cdata->alphasize; i++)
      {
        unsigned int j;
        if (cdata->count[i] < cdata->c)
        {
          for (j = 0; j < cdata->count[i]; j++)
          {
            GtUchar newchar = trusted_char;
            const GtUword
              seqnumrelpos = (cdata->kpositions + i * cdata->c)[j];
            GtUword abspos;
            abspos = gt_encseq_seqstartpos(cdata->encseq,
                gt_seqnumrelpos_decode_seqnum(snrp,seqnumrelpos)) +
              gt_seqnumrelpos_decode_relpos(snrp,seqnumrelpos) + cdata->k - 1;
            if (abspos >= cdata->firstmirrorpos)
            {
              abspos = cdata->totallength - 1UL - abspos;
              newchar = (GtUchar)3 - newchar;
            }
            gt_assert(abspos <= (ULONG_MAX >> 2));
            gt_assert(newchar < (GtUchar)4);
            abspos <<= 2;
            abspos += newchar;
            gt_xfwrite(&abspos, sizeof (abspos), (size_t)1, cdata->outfile);
            cdata->nofcorrections++;
          }
        }
      }
    }
  }
  gt_randomcodes_correct_data_reset(cdata);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
incq 0x48(%rsi)
cmpb $0x0, 0x45(%rsi)
jne 0x1c56fc
movq %rdi, %r14
movl 0x8(%rbx), %ecx
testq %rcx, %rcx
je 0x1c5598
movq 0x28(%rbx), %rsi
xorl %edi, %edi
xorl %edx, %edx
xorl %eax, %eax
movl (%rsi,%rdi,4), %r8d
cmpl %edx, %r8d
cmoval %edi, %eax
cmoval %r8d, %edx
incq %rdi
cmpq %rdi, %rcx
jne 0x1c5580
jmp 0x1c559c
xorl %eax, %eax
xorl %edx, %edx
movl 0x24(%rbx), %ecx
cmpl %ecx, %edx
jb 0x1c56fc
movq (%rbx), %r15
movq 0x30(%rbx), %rdx
imull %eax, %ecx
movq (%rdx,%rcx,8), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x1ec4be
movq %r15, %rdi
movq %rax, %rsi
callq 0xefce0
movq %rax, %r13
movq %r14, %rdi
movq %r12, %rsi
callq 0x1ec4c8
movl 0x20(%rbx), %ecx
addq %r13, %rax
leaq (%rcx,%rax), %rsi
decq %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0xec603
movb %al, 0xe(%rsp)
cmpl $0x0, 0x8(%rbx)
je 0x1c56fc
movb $0x3, %al
subb 0xe(%rsp), %al
movb %al, 0xf(%rsp)
xorl %r15d, %r15d
movq 0x28(%rbx), %rax
movl (%rax,%r15,4), %eax
cmpl 0x24(%rbx), %eax
jae 0x1c56ed
movq 0x28(%rbx), %rax
cmpl $0x0, (%rax,%r15,4)
je 0x1c56ed
xorl %ebp, %ebp
movl 0x24(%rbx), %eax
imull %r15d, %eax
shlq $0x3, %rax
addq 0x30(%rbx), %rax
movq (%rax,%rbp,8), %r12
movq (%rbx), %r13
movq %r14, %rdi
movq %r12, %rsi
callq 0x1ec4be
movq %r13, %rdi
movq %rax, %rsi
callq 0xefce0
movq %rax, %r13
movq %r14, %rdi
movq %r12, %rsi
callq 0x1ec4c8
addq %r13, %rax
movl 0x20(%rbx), %edx
leaq (%rdx,%rax), %rsi
decq %rsi
movq %rsi, 0x10(%rsp)
movb 0xe(%rsp), %cl
cmpq 0x10(%rbx), %rsi
jb 0x1c5696
addq %rdx, %rax
movq 0x18(%rbx), %rcx
subq %rax, %rcx
movq %rcx, 0x10(%rsp)
movb 0xf(%rsp), %cl
movq 0x10(%rsp), %rax
movq %rax, %rdx
shrq $0x3e, %rdx
jne 0x1c573b
cmpb $0x4, %cl
jae 0x1c5736
movzbl %cl, %ecx
leaq (%rcx,%rax,4), %rax
movq %rax, 0x10(%rsp)
movq 0x38(%rbx), %rcx
movl $0x8, %esi
movl $0x1, %edx
leaq 0x10(%rsp), %rdi
callq 0x125658
incq 0x60(%rbx)
incq %rbp
movq 0x28(%rbx), %rax
movl (%rax,%r15,4), %eax
cmpq %rax, %rbp
jb 0x1c562d
incq %r15
movl 0x8(%rbx), %eax
cmpq %rax, %r15
jb 0x1c560b
movw $0x100, 0x44(%rbx)      # imm = 0x100
movl $0x0, 0x40(%rbx)
cmpl $0x0, 0x8(%rbx)
je 0x1c5727
movq 0x28(%rbx), %rax
xorl %ecx, %ecx
movl $0x0, (%rax,%rcx,4)
incq %rcx
movl 0x8(%rbx), %edx
cmpq %rdx, %rcx
jb 0x1c5715
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x69c05
callq 0x69bce