// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/match/karlin_altschul_stat.c
// Function: gt_karlin_altschul_stat_scoring_frequency
static ScoringFrequency *gt_karlin_altschul_stat_scoring_frequency(
                                             unsigned int numofchars,
                                             const GtScoreHandler *scorehandler)
{
  unsigned int idx, jdx;
  GtWord score, obs_min = 0, obs_max = 0, range;
  double score_avg, score_sum;
  ScoringFrequency *sf;
  static double nt_prob[] = {
    0.25,
    0.25,
    0.25,
    0.25
  };

  gt_assert(scorehandler != NULL);
  for (idx = 0; idx < numofchars; idx++)
  {
    for (jdx = 0; jdx < numofchars; jdx++)
    {
      score = gt_scorehandler_get_replacement(scorehandler, idx, jdx);
      obs_min = GT_MIN(obs_min, score);
      obs_max = GT_MAX(obs_max, score);
    }
  }

  /* for theoretically valid scoring systems */
  gt_assert(obs_min <= 0 && obs_max >= 0);
  sf = gt_malloc(sizeof (*sf));
  gt_assert(sf);
  sf->low_align_score = obs_min;
  sf->high_align_score = obs_max;

  range = obs_max - obs_min + 1;
  sf->sprob = gt_calloc(range, sizeof (*sf->sprob));

  for (idx = 0; idx < numofchars; idx++)
  {
    for (jdx = 0; jdx < numofchars; jdx++)
    {
      score = gt_scorehandler_get_replacement(scorehandler, idx, jdx);
      gt_assert(score >= obs_min);
      if (score >= obs_min)
      {
        sf->sprob[score - obs_min] += nt_prob[idx] * nt_prob[jdx];
      }
    }
  }

  score_sum = 0.0;
  for (score = obs_min; score <= obs_max; score++)
  {
    if (sf->sprob[score - obs_min] > 0)
    {
      score_sum += sf->sprob[score - obs_min];
    }
  }

  score_avg = 0.0;
  for (score = obs_min; score <= obs_max; score++)
  {
    sf->sprob[score - obs_min] /= score_sum;
    score_avg += score * sf->sprob[score - obs_min];
  }
  sf->score_avg = score_avg;
  return sf;
}

// Assembly:
subq $0x68, %rsp
movl %edi, 0x64(%rsp)
movq %rsi, 0x58(%rsp)
movq $0x0, 0x40(%rsp)
movq $0x0, 0x38(%rsp)
cmpq $0x0, 0x58(%rsp)
jne 0x25e08f
movq 0x3ddf42(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2b7fab(%rip), %rsi    # 0x516013
leaq 0x306817(%rip), %rdx    # 0x564886
leaq 0x31dc0b(%rip), %rcx    # 0x57bc81
leaq 0x31d813(%rip), %r8     # 0x57b890
movl $0xb3, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x25e091
movl $0x0, 0x54(%rsp)
movl 0x54(%rsp), %eax
cmpl 0x64(%rsp), %eax
jae 0x25e156
movl $0x0, 0x50(%rsp)
movl 0x50(%rsp), %eax
cmpl 0x64(%rsp), %eax
jae 0x25e144
movq 0x58(%rsp), %rdi
movl 0x54(%rsp), %eax
movb %al, %cl
movl 0x50(%rsp), %eax
movzbl %cl, %esi
movzbl %al, %edx
callq 0x1d12c0
movq %rax, 0x48(%rsp)
movq 0x40(%rsp), %rax
cmpq 0x48(%rsp), %rax
jge 0x25e0f4
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
jmp 0x25e0fe
movq 0x48(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x38(%rsp), %rax
cmpq 0x48(%rsp), %rax
jle 0x25e120
movq 0x38(%rsp), %rax
movq %rax, 0x8(%rsp)
jmp 0x25e12a
movq 0x48(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq %rax, 0x38(%rsp)
movl 0x50(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x50(%rsp)
jmp 0x25e0af
jmp 0x25e146
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0x25e099
jmp 0x25e158
cmpq $0x0, 0x40(%rsp)
jg 0x25e168
cmpq $0x0, 0x38(%rsp)
jge 0x25e1a0
movq 0x3dde31(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2b7e9a(%rip), %rsi    # 0x516013
leaq 0x31db2b(%rip), %rdx    # 0x57bcab
leaq 0x31dafa(%rip), %rcx    # 0x57bc81
leaq 0x31d702(%rip), %r8     # 0x57b890
movl $0xbf, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x25e1a2
movl $0x20, %edi
leaq 0x31d6e2(%rip), %rsi    # 0x57b890
movl $0xc0, %edx
callq 0xe80f0
movq %rax, 0x18(%rsp)
cmpq $0x0, 0x18(%rsp)
jne 0x25e1fd
movq 0x3dddd4(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2b7e3d(%rip), %rsi    # 0x516013
leaq 0x2fba7f(%rip), %rdx    # 0x559c5c
leaq 0x31da9d(%rip), %rcx    # 0x57bc81
leaq 0x31d6a5(%rip), %r8     # 0x57b890
movl $0xc1, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x25e1ff
movq 0x40(%rsp), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x38(%rsp), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x38(%rsp), %rax
subq 0x40(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rdi
movl $0x8, %esi
leaq 0x31d651(%rip), %rdx    # 0x57b890
movl $0xc6, %ecx
callq 0xe83c0
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq %rcx, (%rax)
movl $0x0, 0x54(%rsp)
movl 0x54(%rsp), %eax
cmpl 0x64(%rsp), %eax
jae 0x25e35d
movl $0x0, 0x50(%rsp)
movl 0x50(%rsp), %eax
cmpl 0x64(%rsp), %eax
jae 0x25e34b
movq 0x58(%rsp), %rdi
movl 0x54(%rsp), %eax
movb %al, %cl
movl 0x50(%rsp), %eax
movzbl %cl, %esi
movzbl %al, %edx
callq 0x1d12c0
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
cmpq 0x40(%rsp), %rax
jge 0x25e2e3
movq 0x3ddcee(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2b7d57(%rip), %rsi    # 0x516013
leaq 0x31da05(%rip), %rdx    # 0x57bcc8
leaq 0x31d9b7(%rip), %rcx    # 0x57bc81
leaq 0x31d5bf(%rip), %r8     # 0x57b890
movl $0xcd, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x25e2e5
movq 0x48(%rsp), %rax
cmpq 0x40(%rsp), %rax
jl 0x25e339
movl 0x54(%rsp), %eax
movl %eax, %ecx
leaq 0x3dfff2(%rip), %rax    # 0x63e2f0
movsd (%rax,%rcx,8), %xmm0
movl 0x50(%rsp), %eax
movl %eax, %ecx
leaq 0x3dffe0(%rip), %rax    # 0x63e2f0
movsd (%rax,%rcx,8), %xmm2
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq 0x48(%rsp), %rcx
subq 0x40(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x25e33b
movl 0x50(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x50(%rsp)
jmp 0x25e272
jmp 0x25e34d
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0x25e25c
xorps %xmm0, %xmm0
movsd %xmm0, 0x20(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
cmpq 0x38(%rsp), %rax
jg 0x25e3d1
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq 0x48(%rsp), %rcx
subq 0x40(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x25e3bf
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq 0x48(%rsp), %rcx
subq 0x40(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
addsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
jmp 0x25e3c1
movq 0x48(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x48(%rsp)
jmp 0x25e370
xorps %xmm0, %xmm0
movsd %xmm0, 0x28(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
cmpq 0x38(%rsp), %rax
jg 0x25e458
movsd 0x20(%rsp), %xmm1
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq 0x48(%rsp), %rcx
subq 0x40(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
cvtsi2sdq 0x48(%rsp), %xmm0
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq 0x48(%rsp), %rcx
subq 0x40(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd 0x28(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
movq 0x48(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x48(%rsp)
jmp 0x25e3e4
movsd 0x28(%rsp), %xmm0
movq 0x18(%rsp), %rax
movsd %xmm0, 0x8(%rax)
movq 0x18(%rsp), %rax
addq $0x68, %rsp
retq
nopw %cs:(%rax,%rax)