// File: /workspace/github_c_makefile_star2_O3/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 0xd80b
xorpd %xmm0, %xmm0
movl $0x0, 0x8(%rsp)
jmp 0xd8be
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 0x401ad(%rip), %xmm3    # 0x4da10
movq %r10, 0x30(%rsp)
movsd 0x8(%rbx,%r15,8), %xmm1
ucomisd %xmm3, %xmm1
jne 0xd877
jnp 0xd8b6
movq (%r13), %rax
addq %r14, %rax
movsd 0x8(%rax,%r15,8), %xmm2
ucomisd %xmm3, %xmm2
jne 0xd88d
jnp 0xd8b6
addsd %xmm2, %xmm1
testb $0x1, 0x8(%rsp)
movb $0x1, %al
movl %eax, 0x8(%rsp)
jne 0xd8a4
movapd %xmm1, %xmm0
jmp 0xd8b6
callq 0xbc7e
movsd 0x4015f(%rip), %xmm3    # 0x4da10
movq 0x30(%rsp), %r10
incq %r15
cmpq %r10, %r15
jl 0xd868
movl 0xc(%rsp), %eax
subl 0x20(%rsp), %eax
testl %eax, %eax
cmovgl %eax, %ebp
movq 0x28(%rsp), %rcx
cmpl %ecx, %ebp
jge 0xd967
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 0x40102(%rip), %xmm3    # 0x4da10
movq (%rbx,%r15), %rax
movsd (%rax,%r12,8), %xmm1
ucomisd %xmm3, %xmm1
jne 0xd920
jnp 0xd959
movslq %ebp, %rax
movq (%r13,%r15), %rcx
movsd (%rcx,%rax,8), %xmm2
ucomisd %xmm3, %xmm2
jne 0xd935
jnp 0xd959
addsd %xmm2, %xmm1
testb $0x1, 0x8(%rsp)
movb $0x1, %al
movl %eax, 0x8(%rsp)
jne 0xd94c
movapd %xmm1, %xmm0
jmp 0xd959
callq 0xbc7e
movsd 0x400b7(%rip), %xmm3    # 0x4da10
decq %r12
decl %ebp
addq $0x18, %r15
decq %r14
jne 0xd90e
xorpd %xmm1, %xmm1
testb $0x1, 0x8(%rsp)
je 0xda43
movq 0x10(%rsp), %rax
movq 0x62140(%rax), %rax
movq 0x18(%rsp), %rcx
subsd (%rax,%rcx,8), %xmm0
movsd 0x400ac(%rip), %xmm2    # 0x4da40
ucomisd %xmm0, %xmm2
jae 0xda43
ucomisd 0x400a2(%rip), %xmm0    # 0x4da48
jae 0xda3b
leaq 0xda9ed(%rip), %rax     # 0xe83a0
movsd 0xdea15(%rip), %xmm1    # 0xec3d0
mulsd %xmm0, %xmm1
addsd 0x40089(%rip), %xmm1    # 0x4da50
movq %xmm1, %rdx
movl %edx, %ecx
addsd 0x40082(%rip), %xmm1    # 0x4da58
mulsd 0xde9fa(%rip), %xmm1    # 0xec3d8
andl $0x7ff, %ecx            # imm = 0x7FF
subsd %xmm0, %xmm1
andl $0x7ff800, %edx         # imm = 0x7FF800
shlq $0x29, %rdx
movabsq $0x3ff0000000000000, %rsi # imm = 0x3FF0000000000000
movsd 0xda9bc(%rip), %xmm0    # 0xe83c0
subsd %xmm1, %xmm0
movapd %xmm1, %xmm2
mulsd %xmm1, %xmm2
mulsd %xmm0, %xmm2
mulsd 0xda994(%rip), %xmm2    # 0xe83b0
addq %rdx, %rsi
subsd %xmm1, %xmm2
addsd 0xda975(%rip), %xmm2    # 0xe83a0
orq 0x30(%rax,%rcx,8), %rsi
movq %rsi, %xmm1
mulsd %xmm2, %xmm1
jmp 0xda43
movsd 0x40025(%rip), %xmm1    # 0x4da68
movapd %xmm1, %xmm0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq