// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/extended/scorehandler.c
// Function: gt_scorehandler2costhandler
GtScoreHandler *gt_scorehandler2costhandler(const GtScoreHandler *scorehandler)
{
  GtScoreHandler *costhandler;

  gt_assert(scorehandler != NULL);
  if (scorehandler->scorematrix == NULL)
  {
    GtWord matchscore, mismatchscore, gap_extension, gap_opening,
           maxscore = GT_MAX(GT_MAX(GT_DIV2(scorehandler->matchscore+1),
                         GT_DIV2(scorehandler->mismatchscore+1)),
                     GT_MAX(1 + scorehandler->gap_extension,0));

    matchscore = 2 * maxscore - scorehandler->matchscore;
    mismatchscore = 2 * maxscore - scorehandler->mismatchscore;
    gap_extension = maxscore - scorehandler->gap_extension;
    gap_opening = -scorehandler->gap_opening;
    costhandler = gt_scorehandler_new(matchscore,
                                      mismatchscore,
                                      gap_opening,
                                      gap_extension);
    if (!scorehandler->mappedsequence)
    {
      gt_scorehandler_plain(costhandler);
    }
  } else
  {
    int maxscore;
    GtWord gap_extension, gap_opening;
    unsigned int i, j,
                 dim = gt_score_matrix_get_dimension(scorehandler->scorematrix);
    GtScoreMatrix *costmatrix
      = gt_score_matrix_clone_empty(scorehandler->scorematrix);

    for (maxscore = 0, i = 0; i < dim; i++)
    {
      for (j = 0; j < dim; j++)
      {
        int val = gt_score_matrix_get_score(scorehandler->scorematrix, i, j);

        if (val > maxscore)
        {
          maxscore = val;
        }
      }
    }
    maxscore = GT_MAX(GT_DIV2(maxscore+1), 1 + scorehandler->gap_extension);
    for (i = 0; i < dim; i++)
    {
      for (j = 0; j < dim; j++)
      {
        /* translate */
        int score = gt_score_matrix_get_score(scorehandler->scorematrix,i,j);
        gt_score_matrix_set_score(costmatrix, i, j, 2 * maxscore - score);
      }
    }
    gap_extension = maxscore - scorehandler->gap_extension;
    gap_opening = -scorehandler->gap_opening;
    costhandler = gt_scorehandler_new( 0,0, gap_opening, gap_extension);
    gt_scorehandler_add_scorematrix(costhandler,costmatrix);
  }
  return costhandler;
}

// Assembly:
subq $0xa8, %rsp
movq %rdi, 0xa0(%rsp)
cmpq $0x0, 0xa0(%rsp)
jne 0x1d14a2
movq 0x46ab2f(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x344b98(%rip), %rsi    # 0x516013
leaq 0x393404(%rip), %rdx    # 0x564886
leaq 0x39351c(%rip), %rcx    # 0x5649a5
leaq 0x3933da(%rip), %r8     # 0x56486a
movl $0x85, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1d14a4
movq 0xa0(%rsp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x1d16bf
movq 0xa0(%rsp), %rax
movq (%rax), %rax
addq $0x1, %rax
sarq %rax
movq 0xa0(%rsp), %rcx
movq 0x8(%rcx), %rcx
addq $0x1, %rcx
sarq %rcx
cmpq %rcx, %rax
jle 0x1d14fa
movq 0xa0(%rsp), %rax
movq (%rax), %rax
addq $0x1, %rax
sarq %rax
movq %rax, 0x30(%rsp)
jmp 0x1d1512
movq 0xa0(%rsp), %rax
movq 0x8(%rax), %rax
addq $0x1, %rax
sarq %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0xa0(%rsp), %rax
movq 0x18(%rax), %rax
addq $0x1, %rax
cmpq $0x0, %rax
jle 0x1d1549
movq 0xa0(%rsp), %rax
movq 0x18(%rax), %rax
addq $0x1, %rax
movq %rax, 0x20(%rsp)
jmp 0x1d1552
xorl %eax, %eax
movq %rax, 0x20(%rsp)
jmp 0x1d1552
movq 0x28(%rsp), %rax
movq 0x20(%rsp), %rcx
cmpq %rcx, %rax
jle 0x1d15c8
movq 0xa0(%rsp), %rax
movq (%rax), %rax
addq $0x1, %rax
sarq %rax
movq 0xa0(%rsp), %rcx
movq 0x8(%rcx), %rcx
addq $0x1, %rcx
sarq %rcx
cmpq %rcx, %rax
jle 0x1d15a4
movq 0xa0(%rsp), %rax
movq (%rax), %rax
addq $0x1, %rax
sarq %rax
movq %rax, 0x18(%rsp)
jmp 0x1d15bc
movq 0xa0(%rsp), %rax
movq 0x8(%rax), %rax
addq $0x1, %rax
sarq %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x10(%rsp)
jmp 0x1d1608
movq 0xa0(%rsp), %rax
movq 0x18(%rax), %rax
addq $0x1, %rax
cmpq $0x0, %rax
jle 0x1d15f5
movq 0xa0(%rsp), %rax
movq 0x18(%rax), %rax
addq $0x1, %rax
movq %rax, 0x8(%rsp)
jmp 0x1d15fe
xorl %eax, %eax
movq %rax, 0x8(%rsp)
jmp 0x1d15fe
movq 0x8(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x70(%rsp), %rax
shlq %rax
movq 0xa0(%rsp), %rcx
subq (%rcx), %rax
movq %rax, 0x90(%rsp)
movq 0x70(%rsp), %rax
shlq %rax
movq 0xa0(%rsp), %rcx
subq 0x8(%rcx), %rax
movq %rax, 0x88(%rsp)
movq 0x70(%rsp), %rax
movq 0xa0(%rsp), %rcx
subq 0x18(%rcx), %rax
movq %rax, 0x80(%rsp)
movq 0xa0(%rsp), %rcx
xorl %eax, %eax
subq 0x10(%rcx), %rax
movq %rax, 0x78(%rsp)
movq 0x90(%rsp), %rdi
movq 0x88(%rsp), %rsi
movq 0x78(%rsp), %rdx
movq 0x80(%rsp), %rcx
callq 0x1d0fb0
movq %rax, 0x98(%rsp)
movq 0xa0(%rsp), %rax
testb $0x1, 0x28(%rax)
jne 0x1d16ba
movq 0x98(%rsp), %rdi
callq 0x1d10b0
jmp 0x1d1882
movq 0xa0(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x10f630
movl %eax, 0x4c(%rsp)
movq 0xa0(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x10f150
movq %rax, 0x40(%rsp)
movl $0x0, 0x6c(%rsp)
movl $0x0, 0x54(%rsp)
movl 0x54(%rsp), %eax
cmpl 0x4c(%rsp), %eax
jae 0x1d1763
movl $0x0, 0x50(%rsp)
movl 0x50(%rsp), %eax
cmpl 0x4c(%rsp), %eax
jae 0x1d1754
movq 0xa0(%rsp), %rax
movq 0x20(%rax), %rdi
movl 0x54(%rsp), %esi
movl 0x50(%rsp), %edx
callq 0x10f680
movl %eax, 0x3c(%rsp)
movl 0x3c(%rsp), %eax
cmpl 0x6c(%rsp), %eax
jle 0x1d1745
movl 0x3c(%rsp), %eax
movl %eax, 0x6c(%rsp)
jmp 0x1d1747
movl 0x50(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x50(%rsp)
jmp 0x1d170c
jmp 0x1d1756
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0x1d16fa
movl 0x6c(%rsp), %eax
addl $0x1, %eax
sarl %eax
cltq
movq 0xa0(%rsp), %rcx
movq 0x18(%rcx), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jle 0x1d1794
movl 0x6c(%rsp), %eax
addl $0x1, %eax
sarl %eax
cltq
movq %rax, (%rsp)
jmp 0x1d17a8
movq 0xa0(%rsp), %rax
movq 0x18(%rax), %rax
addq $0x1, %rax
movq %rax, (%rsp)
movq (%rsp), %rax
movl %eax, 0x6c(%rsp)
movl $0x0, 0x54(%rsp)
movl 0x54(%rsp), %eax
cmpl 0x4c(%rsp), %eax
jae 0x1d1829
movl $0x0, 0x50(%rsp)
movl 0x50(%rsp), %eax
cmpl 0x4c(%rsp), %eax
jae 0x1d181a
movq 0xa0(%rsp), %rax
movq 0x20(%rax), %rdi
movl 0x54(%rsp), %esi
movl 0x50(%rsp), %edx
callq 0x10f680
movl %eax, 0x38(%rsp)
movq 0x40(%rsp), %rdi
movl 0x54(%rsp), %esi
movl 0x50(%rsp), %edx
movl 0x6c(%rsp), %ecx
shll %ecx
subl 0x38(%rsp), %ecx
callq 0x10f7a0
movl 0x50(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x50(%rsp)
jmp 0x1d17ca
jmp 0x1d181c
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0x1d17b8
movslq 0x6c(%rsp), %rax
movq 0xa0(%rsp), %rcx
subq 0x18(%rcx), %rax
movq %rax, 0x60(%rsp)
movq 0xa0(%rsp), %rcx
xorl %eax, %eax
subq 0x10(%rcx), %rax
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rdx
movq 0x60(%rsp), %rcx
xorl %eax, %eax
movl %eax, %esi
movq %rsi, %rdi
callq 0x1d0fb0
movq %rax, 0x98(%rsp)
movq 0x98(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x1d1040
movq 0x98(%rsp), %rax
addq $0xa8, %rsp
retq
nopw %cs:(%rax,%rax)