// File: /workspace/github_c_makefile_star2_O1/fukunagatsu[P]RIblast/raccess.cpp
// Function: Raccess::CalcMultiProbability(int, int)
double Raccess::CalcMultiProbability(int x, int w){
  double probability = 0.0;
  double temp = 0.0;
  bool flag = 0;
  
  for(int i = x+w-1; i<=min(x+_maximal_span,_seq_length);i++){
    if(_Beta_multi[x-1][i-x+1] != -INF && _Alpha_multi[x+w-1][i-x-w+1] != -INF){
      temp = flag == 0 ? _Beta_multi[x-1][i-x+1] + _Alpha_multi[x+w-1][i-x-w+1] : logsumexp(temp,_Beta_multi[x-1][i-x+1] + _Alpha_multi[x+w-1][i-x-w+1]);
      flag = 1;
    }
  }
  
  for(int i = max(0,x+w-1-_maximal_span); i<x;i++){
    if(_Beta_multi2[i][x+w-1-i] != -INF && _Alpha_multi2[i][x-i-1] != -INF){
      temp = flag == 0 ? _Beta_multi2[i][x+w-1-i] + _Alpha_multi2[i][x-i-1] : logsumexp(temp,_Beta_multi2[i][x+w-1-i] + _Alpha_multi2[i][x-i-1]);
      flag = 1;
    }
  }
  if(flag == 1){ probability = fmath::expd(temp-_Alpha_outer[_seq_length]); }
  return(probability);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl 0x62114(%rdi), %eax
movq %rax, 0x20(%rsp)
addl %esi, %eax
movslq 0x62110(%rdi), %r8
cmpl %eax, %r8d
movq %r8, 0x18(%rsp)
cmovll %r8d, %eax
leal (%rsi,%rdx), %ecx
decl %ecx
xorl %ebp, %ebp
movslq %ecx, %r12
movl %ecx, 0xc(%rsp)
cmpl %eax, %ecx
movq %rdi, 0x10(%rsp)
movq %rsi, 0x28(%rsp)
jle 0xc7f1
xorpd %xmm0, %xmm0
movl $0x0, 0x8(%rsp)
jmp 0xc8a4
movq 0x62230(%rdi), %rcx
movslq %esi, %rsi
leaq (%rsi,%rsi,2), %r8
leaq (%r12,%r12,2), %r13
shlq $0x3, %r13
addq 0x62188(%rdi), %r13
movslq %edx, %rdx
movslq %eax, %r10
leaq -0x1(%r12), %r15
shlq $0x3, %rsi
movl $0x8, %r14d
subq %rsi, %r14
movq -0x18(%rcx,%r8,8), %rbx
addq %r14, %rbx
shlq $0x3, %rdx
subq %rdx, %r14
xorpd %xmm0, %xmm0
movl $0x0, 0x8(%rsp)
movsd 0x400e7(%rip), %xmm3    # 0x4c930
movq %r10, 0x30(%rsp)
movsd 0x8(%rbx,%r15,8), %xmm1
ucomisd %xmm3, %xmm1
jne 0xc85d
jnp 0xc89c
movq (%r13), %rax
addq %r14, %rax
movsd 0x8(%rax,%r15,8), %xmm2
ucomisd %xmm3, %xmm2
jne 0xc873
jnp 0xc89c
addsd %xmm2, %xmm1
testb $0x1, 0x8(%rsp)
movb $0x1, %al
movl %eax, 0x8(%rsp)
jne 0xc88a
movapd %xmm1, %xmm0
jmp 0xc89c
callq 0xabc8
movsd 0x40099(%rip), %xmm3    # 0x4c930
movq 0x30(%rsp), %r10
incq %r15
cmpq %r10, %r15
jl 0xc84e
movl 0xc(%rsp), %eax
subl 0x20(%rsp), %eax
testl %eax, %eax
cmovgl %eax, %ebp
movq 0x28(%rsp), %rcx
cmpl %ecx, %ebp
jge 0xc94d
movq 0x10(%rsp), %rax
movq 0x621d0(%rax), %r13
movq 0x62278(%rax), %rbx
movl %ebp, %eax
movl %ecx, %r14d
subq %rax, %r12
notl %ebp
addl %ecx, %ebp
leaq (,%rax,8), %rcx
leaq (%rcx,%rcx,2), %r15
subq %rax, %r14
movsd 0x4003c(%rip), %xmm3    # 0x4c930
movq (%rbx,%r15), %rax
movsd (%rax,%r12,8), %xmm1
ucomisd %xmm3, %xmm1
jne 0xc906
jnp 0xc93f
movslq %ebp, %rax
movq (%r13,%r15), %rcx
movsd (%rcx,%rax,8), %xmm2
ucomisd %xmm3, %xmm2
jne 0xc91b
jnp 0xc93f
addsd %xmm2, %xmm1
testb $0x1, 0x8(%rsp)
movb $0x1, %al
movl %eax, 0x8(%rsp)
jne 0xc932
movapd %xmm1, %xmm0
jmp 0xc93f
callq 0xabc8
movsd 0x3fff1(%rip), %xmm3    # 0x4c930
decq %r12
decl %ebp
addq $0x18, %r15
decq %r14
jne 0xc8f4
xorpd %xmm1, %xmm1
testb $0x1, 0x8(%rsp)
je 0xca29
movq 0x10(%rsp), %rax
movq 0x62140(%rax), %rax
movq 0x18(%rsp), %rcx
subsd (%rax,%rcx,8), %xmm0
movsd 0x3ffe6(%rip), %xmm2    # 0x4c960
ucomisd %xmm0, %xmm2
jae 0xca29
ucomisd 0x3ffdc(%rip), %xmm0    # 0x4c968
jae 0xca21
leaq 0xdaa07(%rip), %rax     # 0xe73a0
movsd 0xdea2f(%rip), %xmm1    # 0xeb3d0
mulsd %xmm0, %xmm1
addsd 0x3ffc3(%rip), %xmm1    # 0x4c970
movq %xmm1, %rdx
movl %edx, %ecx
addsd 0x3ffbc(%rip), %xmm1    # 0x4c978
mulsd 0xdea14(%rip), %xmm1    # 0xeb3d8
andl $0x7ff, %ecx            # imm = 0x7FF
subsd %xmm0, %xmm1
andl $0x7ff800, %edx         # imm = 0x7FF800
shlq $0x29, %rdx
movabsq $0x3ff0000000000000, %rsi # imm = 0x3FF0000000000000
movsd 0xda9d6(%rip), %xmm0    # 0xe73c0
subsd %xmm1, %xmm0
movapd %xmm1, %xmm2
mulsd %xmm1, %xmm2
mulsd %xmm0, %xmm2
mulsd 0xda9ae(%rip), %xmm2    # 0xe73b0
addq %rdx, %rsi
subsd %xmm1, %xmm2
addsd 0xda98f(%rip), %xmm2    # 0xe73a0
orq 0x30(%rax,%rcx,8), %rsi
movq %rsi, %xmm1
mulsd %xmm2, %xmm1
jmp 0xca29
movsd 0x3ff5f(%rip), %xmm1    # 0x4c988
movapd %xmm1, %xmm0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq