// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/extended/globalchaining.c
// Function: bruteforcechainingscores
static void bruteforcechainingscores(GtChaininfo *chaininfo,
                                     GtUword max_gap_width,
                                     GtFragment *fragments,
                                     GtUword num_of_fragments,
                                     Overlapinfo *overlapinfo)
{
  GtUword previous, leftfrag, rightfrag, overlaplength;
  GtWord weightright, score;
  Maxfragvalue localmaxfrag;
  bool combinable;

  /* get rid of compiler warnings */
  localmaxfrag.maxscore = 0;
  localmaxfrag.maxfragnum = 0;

  if (num_of_fragments > 1UL) {
    chaininfo[0].previousinchain = UNDEFPREVIOUS;
    chaininfo[0].score = fragments[0].weight;
    for (rightfrag = 1UL; rightfrag < num_of_fragments; rightfrag++) {
      weightright = fragments[rightfrag].weight;
      localmaxfrag.defined = false;
      for (leftfrag = 0; leftfrag < rightfrag; leftfrag++) {
        if (max_gap_width != 0 &&
            !check_max_gap_width(fragments, max_gap_width, leftfrag,
                                 rightfrag)) {
          combinable = false;
        }
        else {
          combinable = colinearfragments(fragments, leftfrag, rightfrag);
        }
        if (combinable) {
          score = chaininfo[leftfrag].score
                  - overlapcost(fragments, leftfrag, rightfrag);
          if (score > 0) {
            score += weightright;
            previous = leftfrag;
          }
          else {
            score = weightright;
            previous = UNDEFPREVIOUS;
          }
          if (!localmaxfrag.defined || localmaxfrag.maxscore < score) {
            localmaxfrag.maxscore = score;
            localmaxfrag.maxfragnum = previous;
            localmaxfrag.defined = true;
          }
        }
      }
      if (localmaxfrag.defined) {
        chaininfo[rightfrag].previousinchain = localmaxfrag.maxfragnum;
        chaininfo[rightfrag].score = localmaxfrag.maxscore;
        if (overlapinfo && localmaxfrag.maxfragnum != UNDEFPREVIOUS) {
          overlapinfo[localmaxfrag.maxfragnum].active = false;
          overlapinfo[rightfrag].startofchain = overlapinfo[localmaxfrag
                                                            .maxfragnum]
                                                .startofchain;
          if (GETSTOREDSTARTPOINT(1, rightfrag) <=
              GETSTOREDENDPOINT(1, localmaxfrag.maxfragnum)) {
            overlaplength = GETSTOREDENDPOINT(1, localmaxfrag.maxfragnum)
                            - GETSTOREDSTARTPOINT(1, rightfrag) + 1;
          }
          else {
            overlaplength = 0;
          }
          overlapinfo[rightfrag].dim1lengthofchain += overlapinfo[localmaxfrag
                                                                  .maxfragnum]
                                                      .dim1lengthofchain
                                                      - overlaplength;
        }
      }
      else {
        chaininfo[rightfrag].previousinchain = UNDEFPREVIOUS;
        chaininfo[rightfrag].score = weightright;
      }
    }
  }
}

// Assembly:
subq $0x88, %rsp
movq %rdi, 0x80(%rsp)
movq %rsi, 0x78(%rsp)
movq %rdx, 0x70(%rsp)
movq %rcx, 0x68(%rsp)
movq %r8, 0x60(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
cmpq $0x1, 0x68(%rsp)
jbe 0x491e8f
movq 0x68(%rsp), %rcx
movq 0x80(%rsp), %rax
movq %rcx, (%rax)
movq 0x70(%rsp), %rax
movq 0x20(%rax), %rcx
movq 0x80(%rsp), %rax
movq %rcx, 0x8(%rax)
movq $0x1, 0x48(%rsp)
movq 0x48(%rsp), %rax
cmpq 0x68(%rsp), %rax
jae 0x491e8d
movq 0x70(%rsp), %rax
imulq $0x30, 0x48(%rsp), %rcx
addq %rcx, %rax
movq 0x20(%rax), %rax
movq %rax, 0x38(%rsp)
movb $0x0, 0x28(%rsp)
movq $0x0, 0x50(%rsp)
movq 0x50(%rsp), %rax
cmpq 0x48(%rsp), %rax
jae 0x491d10
cmpq $0x0, 0x78(%rsp)
je 0x491c30
movq 0x70(%rsp), %rdi
movq 0x78(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq 0x48(%rsp), %rcx
callq 0x492350
testb $0x1, %al
jne 0x491c30
movb $0x0, 0x17(%rsp)
jmp 0x491c4a
movq 0x70(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq 0x48(%rsp), %rdx
callq 0x492450
andb $0x1, %al
movb %al, 0x17(%rsp)
testb $0x1, 0x17(%rsp)
je 0x491cfb
movq 0x80(%rsp), %rax
movq 0x50(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x70(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq 0x48(%rsp), %rdx
callq 0x492510
movq %rax, %rcx
movq 0x8(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x30(%rsp)
cmpq $0x0, 0x30(%rsp)
jle 0x491cb9
movq 0x38(%rsp), %rax
addq 0x30(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x58(%rsp)
jmp 0x491ccd
movq 0x38(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x58(%rsp)
testb $0x1, 0x28(%rsp)
je 0x491ce0
movq 0x18(%rsp), %rax
cmpq 0x30(%rsp), %rax
jge 0x491cf9
movq 0x30(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x20(%rsp)
movb $0x1, 0x28(%rsp)
jmp 0x491cfb
jmp 0x491cfd
movq 0x50(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x50(%rsp)
jmp 0x491bf4
testb $0x1, 0x28(%rsp)
je 0x491e3f
movq 0x20(%rsp), %rcx
movq 0x80(%rsp), %rax
movq 0x48(%rsp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq 0x18(%rsp), %rcx
movq 0x80(%rsp), %rax
movq 0x48(%rsp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
cmpq $0x0, 0x60(%rsp)
je 0x491e3d
movq 0x20(%rsp), %rax
cmpq 0x68(%rsp), %rax
je 0x491e3d
movq 0x60(%rsp), %rax
movq 0x20(%rsp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movq 0x60(%rsp), %rax
movq 0x20(%rsp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rcx
movq 0x60(%rsp), %rax
movq 0x48(%rsp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movq 0x70(%rsp), %rax
imulq $0x30, 0x48(%rsp), %rcx
addq %rcx, %rax
movq (%rax), %rax
movq 0x70(%rsp), %rcx
imulq $0x30, 0x20(%rsp), %rdx
addq %rdx, %rcx
cmpq 0x8(%rcx), %rax
ja 0x491e01
movq 0x70(%rsp), %rax
imulq $0x30, 0x20(%rsp), %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq 0x70(%rsp), %rcx
imulq $0x30, 0x48(%rsp), %rdx
addq %rdx, %rcx
subq (%rcx), %rax
addq $0x1, %rax
movq %rax, 0x40(%rsp)
jmp 0x491e0a
movq $0x0, 0x40(%rsp)
movq 0x60(%rsp), %rax
movq 0x20(%rsp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rcx
subq 0x40(%rsp), %rcx
movq 0x60(%rsp), %rax
movq 0x48(%rsp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
addq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
jmp 0x491e78
movq 0x68(%rsp), %rcx
movq 0x80(%rsp), %rax
movq 0x48(%rsp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq 0x38(%rsp), %rcx
movq 0x80(%rsp), %rax
movq 0x48(%rsp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
jmp 0x491e7a
movq 0x48(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x48(%rsp)
jmp 0x491bbf
jmp 0x491e8f
addq $0x88, %rsp
retq
nopw (%rax,%rax)