// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
movl %edx, %ebp
movq %rsi, %r14
movl %edi, %r15d
movsd %xmm0, 0x8(%rsp)
leaq 0x168fe(%rip), %rsi     # 0x1a46b
movl $0x38, %edi
callq 0x1249d
testq %rax, %rax
je 0x3cfd
movq %rax, %rbx
movsd 0x8(%rsp), %xmm3
movsd %xmm3, (%rax)
movl %r15d, 0x8(%rax)
movl %ebp, 0xc(%rax)
movss (%r14), %xmm0
movss %xmm0, 0x10(%rax)
movss 0x4(%r14), %xmm0
movss %xmm0, 0x14(%rax)
movss 0x8(%r14), %xmm0
movss %xmm0, 0x18(%rax)
movss 0xc(%r14), %xmm0
movss %xmm0, 0x1c(%rax)
movss (%r14), %xmm2
addss 0xc(%r14), %xmm2
ucomiss %xmm2, %xmm2
movsd 0x16813(%rip), %xmm0    # 0x1a3e8
movaps %xmm0, %xmm1
jp 0x3be1
xorps %xmm1, %xmm1
cvtss2sd %xmm2, %xmm1
movsd 0x16807(%rip), %xmm4    # 0x1a3f0
movapd %xmm4, %xmm2
subsd %xmm1, %xmm2
cmpltsd %xmm1, %xmm0
andpd %xmm0, %xmm2
andnpd %xmm1, %xmm0
orpd %xmm2, %xmm0
movsd 0x16806(%rip), %xmm1    # 0x1a410
ucomisd %xmm0, %xmm1
ja 0x3cd8
addsd 0x167dc(%rip), %xmm0    # 0x1a3f8
mulsd 0x167dc(%rip), %xmm0    # 0x1a400
addsd 0x167dc(%rip), %xmm0    # 0x1a408
cvttsd2si %xmm0, %eax
cltq
leaq 0x16b57(%rip), %rcx     # 0x1a790
movsd (%rcx,%rax,8), %xmm0
movapd %xmm4, %xmm1
subsd %xmm3, %xmm1
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm2, %xmm4
mulsd 0x167be(%rip), %xmm4    # 0x1a418
cvttsd2si %xmm4, %eax
mulsd 0x167ba(%rip), %xmm0    # 0x1a420
movl %eax, 0x20(%rbx)
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x10(%rsp)
movl $0x3e8, %ecx            # imm = 0x3E8
subl %eax, %ecx
movl %ecx, 0x14(%rsp)
leaq 0x16867(%rip), %rsi     # 0x1a4ee
movl $0x20000, %edi          # imm = 0x20000
callq 0x1249d
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x3cf5
addq $0x10000, %rax          # imm = 0x10000
leaq 0x10(%rsp), %r14
movq %rax, 0x8(%r14)
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r14, %r8
callq 0x3d07
movq 0x8(%r14), %rax
movq %rax, 0x30(%rbx)
movq 0x10(%r14), %rax
movq %rax, 0x28(%rbx)
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0x12d0
movsd 0x1670b(%rip), %xmm4    # 0x1a3f0
movsd 0x8(%rsp), %xmm3
movl $0x3, %eax
jmp 0x3c30
movq %rbx, %rdi
callq 0x1030
movl $0x1, %edi
callq 0x1280