// File: /workspace/github_c_makefile_star2_O2/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 0x15b27(%rip), %rsi     # 0x1846b
pushq $0x38
popq %rdi
callq 0x10d91
testq %rax, %rax
je 0x2aeb
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 0x15a44(%rip), %xmm0    # 0x183e8
movaps %xmm0, %xmm1
jp 0x29ad
cvtss2sd %xmm2, %xmm1
movsd 0x15a3b(%rip), %xmm4    # 0x183f0
movapd %xmm4, %xmm2
subsd %xmm1, %xmm2
cmpltsd %xmm1, %xmm0
andpd %xmm0, %xmm2
andnpd %xmm1, %xmm0
orpd %xmm2, %xmm0
movsd 0x15a3a(%rip), %xmm1    # 0x18410
ucomisd %xmm0, %xmm1
ja 0x2aa0
addsd 0x15a10(%rip), %xmm0    # 0x183f8
mulsd 0x15a10(%rip), %xmm0    # 0x18400
addsd 0x15a10(%rip), %xmm0    # 0x18408
cvttsd2si %xmm0, %eax
cltq
leaq 0x15d8b(%rip), %rcx     # 0x18790
movsd (%rcx,%rax,8), %xmm0
movapd %xmm4, %xmm1
subsd %xmm3, %xmm1
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm2, %xmm4
mulsd 0x159f2(%rip), %xmm4    # 0x18418
cvttsd2si %xmm4, %eax
mulsd 0x159ee(%rip), %xmm0    # 0x18420
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 0x15a9b(%rip), %rsi     # 0x184ee
movl $0x20000, %edi          # imm = 0x20000
callq 0x10d91
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x2ae3
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 0x2af3
movq %r15, 0x30(%rbx)
movq %r14, 0x28(%rbx)
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x1b551(%rip), %r14     # 0x1dff8
movq (%r14), %rdi
leaq 0x159dd(%rip), %rsi     # 0x1848e
xorl %eax, %eax
callq 0x11a0
movq (%r14), %rcx
leaq 0x15a06(%rip), %rdi     # 0x184c8
pushq $0x25
popq %rsi
pushq $0x1
popq %rdx
callq 0x1290
movsd 0x1591b(%rip), %xmm4    # 0x183f0
movsd 0x8(%rsp), %xmm3
pushq $0x3
popq %rax
jmp 0x29fc
movq %rbx, %rdi
callq 0x1030
pushq $0x1
popq %rdi
callq 0x1280