// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/match/diagband-struct.c
// Function: gt_diagband_struct_reset
void gt_diagband_struct_reset(GtDiagbandStruct *diagband_struct,
                              const GtSeedpairPositions *seedstore,
                              const GtDiagbandseedMaximalmatch *memstore,
                              GtUword segment_length)
{
  gt_assert(diagband_struct != NULL);
  if (diagband_struct->used_diagbands * 3 >= diagband_struct->num_diagbands)
  { /* >= 33% of diagbands are used */
    memset(diagband_struct->score,0,
           sizeof *diagband_struct->score * diagband_struct->num_diagbands);
    memset(diagband_struct->lastpos,0,
           sizeof *diagband_struct->lastpos * diagband_struct->num_diagbands);
    diagband_struct->reset_with_memset++;
  } else
  {
    GtUword idx;

    if (seedstore != NULL)
    {
      for (idx = 0; idx < segment_length; idx++)
      {
        const GtUword diagband_idx
          = GT_DIAGBANDSEED_DIAGONALBAND(diagband_struct->amaxlen,
                                         diagband_struct->logdiagbandwidth,
                                         seedstore[idx].apos,
                                         seedstore[idx].bpos);
        diagband_struct->score[diagband_idx] = 0;
        diagband_struct->lastpos[diagband_idx] = 0;
      }
    } else
    {
      gt_assert(memstore != NULL);
      for (idx = 0; idx < segment_length; idx++)
      {
        const GtUword diagband_idx
          = GT_DIAGBANDSEED_DIAGONALBAND(diagband_struct->amaxlen,
                                         diagband_struct->logdiagbandwidth,
                                         memstore[idx].apos,
                                         memstore[idx].bpos);
        diagband_struct->score[diagband_idx] = 0;
        diagband_struct->lastpos[diagband_idx] = 0;
      }
    }
    diagband_struct->reset_from_matches++;
  }
  diagband_struct->used_diagbands = 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
testq %rdi, %rdi
je 0x3081ed
movq %rcx, %rax
movq %rdi, %rbx
movq 0x10(%rdi), %rcx
movq 0x18(%rdi), %rdi
leaq (%rdi,%rdi,2), %rdi
cmpq %rcx, %rdi
jae 0x308169
testq %rsi, %rsi
je 0x3081a5
movl $0x20, %edi
testq %rax, %rax
je 0x308193
movq (%rbx), %rdx
movq 0x8(%rbx), %rcx
movq 0x30(%rbx), %r8
movq 0x38(%rbx), %r9
xorl %r10d, %r10d
xorl %r11d, %r11d
movl (%rsi,%r11,8), %r14d
movl 0x4(%rsi,%r11,8), %r15d
addq %rdx, %r15
subq %r14, %r15
shrq %cl, %r15
movl %r10d, (%r8,%r15,4)
movl %r10d, (%r9,%r15,4)
incq %r11
cmpq %r11, %rax
jne 0x308145
jmp 0x308193
movq 0x30(%rbx), %rdi
shlq $0x2, %rcx
xorl %esi, %esi
movq %rcx, %rdx
callq 0x173a0
movq 0x10(%rbx), %rdx
movq 0x38(%rbx), %rdi
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x173a0
movl $0x28, %edi
incq (%rbx,%rdi)
movq $0x0, 0x18(%rbx)
popq %rbx
popq %r14
popq %r15
retq
testq %rdx, %rdx
je 0x3081f2
movl $0x20, %edi
testq %rax, %rax
je 0x308193
movq (%rbx), %rsi
movq 0x8(%rbx), %rcx
movq 0x30(%rbx), %r8
movq 0x38(%rbx), %r9
addq $0x4, %rdx
xorl %r10d, %r10d
movl -0x4(%rdx), %r11d
movl (%rdx), %r14d
addq %rsi, %r14
subq %r11, %r14
shrq %cl, %r14
movl %r10d, (%r8,%r14,4)
movl %r10d, (%r9,%r14,4)
addq $0xc, %rdx
decq %rax
jne 0x3081ca
jmp 0x308193
callq 0x8f068
callq 0x8f02f