// File: /workspace/github_c_makefile_star2_O0/thegenemyers[P]DASCRUBBER/align.c
// Function: New_Align_Spec
Align_Spec *New_Align_Spec(double ave_corr, int trace_space, float *freq, int reach)
{ _Align_Spec *spec;
  Table_Bits   parms;
  double       match;
  int          bias;

  spec = (_Align_Spec *) Malloc(sizeof(_Align_Spec),"Allocating alignment specification");
  if (spec == NULL)
    EXIT(NULL);

  spec->ave_corr    = ave_corr;
  spec->trace_space = trace_space;
  spec->reach       = reach;
  spec->freq[0]     = freq[0];
  spec->freq[1]     = freq[1];
  spec->freq[2]     = freq[2];
  spec->freq[3]     = freq[3];

  match = freq[0] + freq[3];
  if ((match <= 0.) == (match > 0.))   //  frequencies accidentally undefined?
    match = .5;
  if (match > .5)
    match = 1.-match;
  bias = (int) ((match+.025)*20.-1.);
  if (match < .2)
    { fprintf(stderr,"Warning: Base bias worse than 80/20%% ! (New_Align_Spec)\n");
      fprintf(stderr,"         Capping bias at this ratio.\n");
      bias = 3; 
    }

  spec->ave_path = (int) (PATH_LEN * (1. - Bias_Factor[bias] * (1. - ave_corr)));
  parms.mscore   = (int) (FRACTION * Bias_Factor[bias] * (1. - ave_corr));
  parms.dscore   = FRACTION - parms.mscore;

  parms.score = (int16 *) Malloc(sizeof(int16)*(TRIM_MASK+1)*2,"Allocating trim table");
  if (parms.score == NULL)
    { free(spec);
      EXIT(NULL);
    }
  parms.table = parms.score + (TRIM_MASK+1);

  set_table(0,0,0,0,&parms);

  spec->table = parms.table;
  spec->score = parms.score;

  return ((Align_Spec *) spec);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movsd %xmm0, -0x8(%rbp)
movl %edi, -0xc(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl $0x38, %edi
leaq 0x21f00(%rip), %rsi     # 0x26453
callq 0x1aa00
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x456d
movl $0x1, %edi
callq 0x2290
movsd -0x8(%rbp), %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, (%rax)
movl -0xc(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0x1c(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x18(%rbp), %rax
movss (%rax), %xmm0
movq -0x28(%rbp), %rax
movss %xmm0, 0x10(%rax)
movq -0x18(%rbp), %rax
movss 0x4(%rax), %xmm0
movq -0x28(%rbp), %rax
movss %xmm0, 0x14(%rax)
movq -0x18(%rbp), %rax
movss 0x8(%rax), %xmm0
movq -0x28(%rbp), %rax
movss %xmm0, 0x18(%rax)
movq -0x18(%rbp), %rax
movss 0xc(%rax), %xmm0
movq -0x28(%rbp), %rax
movss %xmm0, 0x1c(%rax)
movq -0x18(%rbp), %rax
movss (%rax), %xmm0
movq -0x18(%rbp), %rax
addss 0xc(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x48(%rbp), %xmm0
setae %al
andb $0x1, %al
movzbl %al, %eax
movsd -0x48(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
seta %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0x4625
movsd 0x21dc8(%rip), %xmm0    # 0x263e8
movsd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
movsd 0x21db6(%rip), %xmm1    # 0x263e8
ucomisd %xmm1, %xmm0
jbe 0x464a
movsd 0x21db0(%rip), %xmm0    # 0x263f0
subsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd 0x21dbe(%rip), %xmm0    # 0x26410
addsd -0x48(%rbp), %xmm0
movsd 0x21da1(%rip), %xmm1    # 0x26400
mulsd %xmm1, %xmm0
movsd 0x21d9d(%rip), %xmm1    # 0x26408
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x4c(%rbp)
movsd 0x21d7a(%rip), %xmm0    # 0x263f8
ucomisd -0x48(%rbp), %xmm0
jbe 0x46bc
movq 0x2696c(%rip), %rax     # 0x2aff8
movq (%rax), %rdi
leaq 0x21de0(%rip), %rsi     # 0x26476
movb $0x0, %al
callq 0x2190
movq 0x26954(%rip), %rax     # 0x2aff8
movq (%rax), %rdi
leaq 0x21e02(%rip), %rsi     # 0x264b0
movb $0x0, %al
callq 0x2190
movl $0x3, -0x4c(%rbp)
movslq -0x4c(%rbp), %rcx
leaq 0x26ad9(%rip), %rax     # 0x2b1a0
movsd (%rax,%rcx,8), %xmm1
movsd 0x21d1c(%rip), %xmm0    # 0x263f0
subsd -0x8(%rbp), %xmm0
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm0, %xmm1
movsd 0x21cf4(%rip), %xmm0    # 0x263f0
addsd %xmm0, %xmm1
movsd 0x21d18(%rip), %xmm0    # 0x26420
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x20(%rax)
movslq -0x4c(%rbp), %rcx
movsd 0x21cf5(%rip), %xmm0    # 0x26418
leaq 0x26a76(%rip), %rax     # 0x2b1a0
mulsd (%rax,%rcx,8), %xmm0
movsd 0x21cb9(%rip), %xmm1    # 0x263f0
subsd -0x8(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x40(%rbp)
movl $0x3e8, %eax            # imm = 0x3E8
subl -0x40(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl $0x20000, %edi          # imm = 0x20000
leaq 0x21d78(%rip), %rsi     # 0x264d6
callq 0x1aa00
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x4781
movq -0x28(%rbp), %rdi
callq 0x2030
movl $0x1, %edi
callq 0x2290
movq -0x30(%rbp), %rax
addq $0x10000, %rax          # imm = 0x10000
movq %rax, -0x38(%rbp)
xorl %ecx, %ecx
leaq -0x40(%rbp), %r8
movl %ecx, %edi
movl %ecx, %esi
movl %ecx, %edx
callq 0x47d0
movq -0x38(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x28(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)