// File: /workspace/github_c_makefile_star2_O3/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 0x16956(%rip), %rsi     # 0x1a49b
movl $0x38, %edi
callq 0x124b1
testq %rax, %rax
je 0x3ccb
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), %xmm2
movss %xmm2, 0x1c(%rax)
addss (%r14), %xmm2
ucomiss %xmm2, %xmm2
movsd 0x16841(%rip), %xmm0    # 0x1a3e8
movaps %xmm0, %xmm1
jp 0x3bb3
xorps %xmm1, %xmm1
cvtss2sd %xmm2, %xmm1
movsd 0x16835(%rip), %xmm4    # 0x1a3f0
movapd %xmm4, %xmm2
subsd %xmm1, %xmm2
cmpltsd %xmm1, %xmm0
andpd %xmm0, %xmm2
andnpd %xmm1, %xmm0
orpd %xmm2, %xmm0
movsd 0x16834(%rip), %xmm1    # 0x1a410
ucomisd %xmm0, %xmm1
ja 0x3ca6
addsd 0x1680a(%rip), %xmm0    # 0x1a3f8
mulsd 0x1680a(%rip), %xmm0    # 0x1a400
addsd 0x1680a(%rip), %xmm0    # 0x1a408
cvttsd2si %xmm0, %eax
cltq
leaq 0x16bb5(%rip), %rcx     # 0x1a7c0
movsd (%rcx,%rax,8), %xmm0
movapd %xmm4, %xmm1
subsd %xmm3, %xmm1
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm2, %xmm4
mulsd 0x167ec(%rip), %xmm4    # 0x1a418
cvttsd2si %xmm4, %eax
mulsd 0x167e8(%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 0x168c5(%rip), %rsi     # 0x1a51e
movl $0x20000, %edi          # imm = 0x20000
callq 0x124b1
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x3cc3
movq %rax, %r14
movq %rax, %r15
addq $0x10000, %r15          # imm = 0x10000
leaq 0x10(%rsp), %r8
movq %r15, 0x8(%r8)
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x3cd5
movq %r15, 0x30(%rbx)
movq %r14, 0x28(%rbx)
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0x12d0
movsd 0x1673d(%rip), %xmm4    # 0x1a3f0
movsd 0x8(%rsp), %xmm3
movl $0x3, %eax
jmp 0x3c02
movq %rbx, %rdi
callq 0x1030
movl $0x1, %edi
callq 0x1280