// File: /workspace/github_c_makefile_star2_O1/fukunagatsu[P]RIblast/raccess.cpp
// Function: Raccess::CalcBulgeAndInternalProbability(std::vector<double, std::allocator<double>>&, std::vector<double, std::allocator<double>>&)
void Raccess::CalcBulgeAndInternalProbability(vector<double> &biloop_probability, vector<double> &conditional_biloop_probability){
  double probability = 0;
  double temp = 0;
  int type = 0;
  int type2 = 0;
  vector<bool> b_flag_array; b_flag_array.resize(_seq_length,0);
  vector<bool> c_flag_array; c_flag_array.resize(_seq_length,0);
  int w = _min_accessible_length;
  
  for(int i = 1; i<_seq_length-TURN-2;i++){
    for(int j = i+TURN+3; j<=min(i+_maximal_span,_seq_length);j++){
      type = BP_pair[_int_sequence[i]][_int_sequence[j]];
      if (type!=0) {
	for (int p =i+1; p <= min(i+MAXLOOP+1,j-TURN-2); p++) {
	  int u1 = p-i-1;
	  for (int q=max(p+TURN+1,j-MAXLOOP+u1-1); q<j; q++) {
	    type2 = BP_pair[_int_sequence[p]][_int_sequence[q]];
	    if (type2 != 0 && !(p == i+1 && q == j-1)) {
	      type2 = rtype[type2];
	      if(_Beta_stemend[i][j-i-1] != -INF && _Alpha_stem[p-1][q-p+1] != -INF){
		temp = fmath::expd(_Beta_stemend[i][j-i-1] + LoopEnergy(type, type2,i,j,p,q)+_Alpha_stem[p-1][q-p+1]);
		
		for(int k = i+1; k <= p-w;k++){
		  if(k == p-w){
		    biloop_probability[k-1] += temp;		   
		  }else{
		    conditional_biloop_probability[k-1] += temp;		  
		  }
		}
		
		for(int k = q+1; k <= j-w;k++){
		  if(k == j-w){
		    biloop_probability[k-1] += temp;
		  }else{
		    conditional_biloop_probability[k-1] += temp;
		  }
		}
	      } 
	    }
	  }
	}
      }
    }
  }
  
  for(int i=0;i<_seq_length;i++){
    if(biloop_probability[i] != 0){
      biloop_probability[i] = fmath::log((float)(biloop_probability[i] + conditional_biloop_probability[i]));
      biloop_probability[i] = fmath::expd(biloop_probability[i]-_Alpha_outer[_seq_length]);
    }
    if(conditional_biloop_probability[i] != 0){
      conditional_biloop_probability[i] = fmath::log((float)(conditional_biloop_probability[i]));
      conditional_biloop_probability[i] = fmath::expd(conditional_biloop_probability[i]-_Alpha_outer[_seq_length]);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rdx, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdi, %r13
xorl %ebx, %ebx
leaq 0xb0(%rsp), %rdi
movq %rbx, (%rdi)
movl %ebx, 0x8(%rdi)
movq %rbx, 0x10(%rdi)
movl %ebx, 0x18(%rdi)
movq %rbx, 0x20(%rdi)
movslq 0x62110(%r13), %rsi
xorl %edx, %edx
callq 0xcb68
leaq 0x88(%rsp), %rdi
movq %rbx, (%rdi)
movl %ebx, 0x8(%rdi)
movq %rbx, 0x10(%rdi)
movl %ebx, 0x18(%rdi)
movq %rbx, 0x20(%rdi)
movslq 0x62110(%r13), %rsi
xorl %edx, %edx
callq 0xcb68
movl 0x62110(%r13), %edx
cmpl $0x7, %edx
jl 0xb407
movslq 0x62118(%r13), %rax
movl $0x3, %ecx
subl %eax, %ecx
movl %ecx, 0x24(%rsp)
movl $0x2, %ecx
subl %eax, %ecx
movl %ecx, 0x20(%rsp)
movl $0x7, %ecx
movq %rax, 0x70(%rsp)
subl %eax, %ecx
movl %ecx, 0x18(%rsp)
movl $0x2, %eax
movq %rax, 0x68(%rsp)
movl $0x6, 0x1c(%rsp)
movl $0xffffffe8, 0x14(%rsp) # imm = 0xFFFFFFE8
movl $0x7, %eax
movq %rax, 0x60(%rsp)
movl $0x1, %r10d
movq $0x0, 0x78(%rsp)
leaq 0x41a6d(%rip), %rdi     # 0x4c9d0
movsd 0x419c5(%rip), %xmm2    # 0x4c930
leaq 0x6(%r10), %rax
movl 0x62114(%r13), %ecx
addl %r10d, %ecx
movl 0x62110(%r13), %edx
cmpl %ecx, %edx
cmovll %edx, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jg 0xb3cd
leaq 0x1(%r10), %rax
movq %rax, 0xd8(%rsp)
movq %r10, %r9
notq %r9
leal 0x1f(%r10), %eax
movl %eax, 0x58(%rsp)
movl 0x18(%rsp), %eax
movl %eax, 0x2c(%rsp)
movq 0x60(%rsp), %r8
movl 0x14(%rsp), %eax
movl %eax, 0x28(%rsp)
movq %r10, 0xf8(%rsp)
movq %r9, 0xf0(%rsp)
movq 0x620f8(%r13), %rax
movslq (%rax,%r10,4), %rcx
movslq (%rax,%r8,4), %rax
leaq (%rcx,%rcx,4), %rcx
leaq (%rdi,%rcx,4), %rcx
movl (%rcx,%rax,4), %eax
movl %eax, 0x5c(%rsp)
testl %eax, %eax
je 0xb39c
leaq -0x5(%r8), %rax
cmpq %r10, %rax
jbe 0xb39c
movl 0x2c(%rsp), %r11d
decq %r11
movl 0x58(%rsp), %ecx
cmpl %ecx, %eax
cmovgel %ecx, %eax
movl %r8d, %ecx
subl %r10d, %ecx
leaq -0x1(%r8), %rdx
movq %rdx, 0x128(%rsp)
movq %r8, %rdx
subq 0x70(%rsp), %rdx
movq %rdx, 0x80(%rsp)
cltq
movq %rax, 0xe0(%rsp)
addl $-0x20, %ecx
movq %rcx, 0xe8(%rsp)
movl 0x20(%rsp), %eax
movl %eax, 0x3c(%rsp)
movq 0x68(%rsp), %rdx
movl 0x28(%rsp), %eax
movl %eax, 0x38(%rsp)
movl 0x1c(%rsp), %eax
movl %eax, 0x34(%rsp)
movl 0x24(%rsp), %eax
movl %eax, 0x30(%rsp)
movq %r8, 0x108(%rsp)
movq %r11, 0x100(%rsp)
movq 0xe8(%rsp), %rax
addl %edx, %eax
leal 0x4(%rdx), %ecx
cmpl %eax, %ecx
cmovgl %ecx, %eax
cmpq %rax, %r8
jbe 0xb377
movl 0x3c(%rsp), %ebp
addq $-0x2, %rbp
movl 0x30(%rsp), %ebx
addq $-0x2, %rbx
movl 0x38(%rsp), %eax
movl 0x34(%rsp), %ecx
cmpl %eax, %ecx
movl %eax, %r15d
cmovgl %ecx, %r15d
leaq -0x1(%rdx), %rax
movq %rax, 0x118(%rsp)
movq %rdx, %rax
subq 0x70(%rsp), %rax
movq %rax, 0x110(%rsp)
movq %rdx, %rax
xorq 0xd8(%rsp), %rax
movq %rax, 0x130(%rsp)
movq %rdx, 0x50(%rsp)
movq 0x620f8(%r13), %rax
movslq (%rax,%rdx,4), %rcx
movslq (%rax,%r15,4), %rax
leaq (%rcx,%rcx,4), %rcx
leaq (%rdi,%rcx,4), %rcx
movslq (%rcx,%rax,4), %rax
movq %r15, %rcx
xorq 0x128(%rsp), %rcx
orq 0x130(%rsp), %rcx
sete %cl
testq %rax, %rax
je 0xb366
testb %cl, %cl
jne 0xb366
movq 0x62218(%r13), %rcx
leaq (%r10,%r10,2), %rdx
leaq (,%r8,8), %rsi
addq (%rcx,%rdx,8), %rsi
movsd (%rsi,%r9,8), %xmm1
ucomisd %xmm2, %xmm1
jne 0xb15b
jnp 0xb366
movq 0x62158(%r13), %rcx
movq 0x118(%rsp), %rdx
leaq (%rdx,%rdx,2), %r14
movl %r15d, %r12d
subl 0x50(%rsp), %r12d
shlq $0x20, %r12
movabsq $0x100000000, %rdx      # imm = 0x100000000
addq %rdx, %r12
movq (%rcx,%r14,8), %rcx
movq %r12, %rdx
sarq $0x1d, %rdx
movsd (%rcx,%rdx), %xmm0
ucomisd %xmm2, %xmm0
jne 0xb1a3
jnp 0xb366
leaq 0x41896(%rip), %rcx     # 0x4ca40
movl (%rcx,%rax,4), %edx
sarq $0x20, %r12
movl %r15d, (%rsp)
movq %r13, %rdi
movl 0x5c(%rsp), %esi
movl %r10d, %ecx
movq 0x50(%rsp), %r9
movsd %xmm1, 0x120(%rsp)
callq 0xa8b6
movsd 0x120(%rsp), %xmm2
addsd %xmm0, %xmm2
movq 0x62158(%r13), %rax
movq (%rax,%r14,8), %rax
addsd (%rax,%r12,8), %xmm2
xorpd %xmm0, %xmm0
movsd 0x41764(%rip), %xmm1    # 0x4c960
ucomisd %xmm2, %xmm1
jae 0xb2b0
ucomisd 0x4175a(%rip), %xmm2    # 0x4c968
movsd 0x41772(%rip), %xmm0    # 0x4c988
jae 0xb2b0
movsd 0xe01ac(%rip), %xmm0    # 0xeb3d0
mulsd %xmm2, %xmm0
addsd 0x41740(%rip), %xmm0    # 0x4c970
movq %xmm0, %rax
movl %eax, %ecx
andl $0x7ff, %ecx            # imm = 0x7FF
addsd 0x41733(%rip), %xmm0    # 0x4c978
mulsd 0xe018b(%rip), %xmm0    # 0xeb3d8
subsd %xmm2, %xmm0
shlq $0x29, %rax
movabsq $-0x10000000000000, %rdx # imm = 0xFFF0000000000000
andq %rdx, %rax
movsd 0xdc156(%rip), %xmm1    # 0xe73c0
subsd %xmm0, %xmm1
movapd %xmm0, %xmm2
mulsd %xmm0, %xmm2
mulsd %xmm1, %xmm2
mulsd 0xdc12e(%rip), %xmm2    # 0xe73b0
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
addq %rdx, %rax
subsd %xmm0, %xmm2
addsd 0xdc105(%rip), %xmm2    # 0xe73a0
leaq 0xdc0fe(%rip), %rdx     # 0xe73a0
orq 0x30(%rdx,%rcx,8), %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
movq 0xf8(%rsp), %r10
cmpq 0x110(%rsp), %r10
jge 0xb2f9
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x40(%rsp), %rcx
movq (%rcx), %rcx
movq 0x78(%rsp), %rdx
cmpq %rdx, %rbp
movq %rax, %rsi
cmoveq %rcx, %rsi
movsd 0x8(%rsi,%rdx,8), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsi,%rdx,8)
incq %rdx
cmpq %rdx, %rbx
jne 0xb2d7
cmpq 0x80(%rsp), %r15
leaq 0x416c8(%rip), %rdi     # 0x4c9d0
movsd 0x41620(%rip), %xmm2    # 0x4c930
movq 0xf0(%rsp), %r9
movq 0x108(%rsp), %r8
movq 0x100(%rsp), %r11
jge 0xb366
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x40(%rsp), %rcx
movq (%rcx), %rcx
movq %r15, %rdx
cmpq %rdx, %r11
movq %rax, %rsi
cmoveq %rcx, %rsi
movsd (%rsi,%rdx,8), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsi,%rdx,8)
leaq 0x1(%rdx), %rsi
movq %rsi, %rdx
cmpq 0x80(%rsp), %rsi
jl 0xb33d
incq %r15
cmpq %r8, %r15
movq 0x50(%rsp), %rdx
jb 0xb0f0
leaq 0x1(%rdx), %rax
incl 0x30(%rsp)
incl 0x34(%rsp)
incl 0x38(%rsp)
incl 0x3c(%rsp)
cmpq 0xe0(%rsp), %rdx
movq %rax, %rdx
jl 0xb080
leaq 0x1(%r8), %rax
movl 0x62114(%r13), %ecx
addl %r10d, %ecx
movl 0x62110(%r13), %edx
cmpl %ecx, %edx
cmovll %edx, %ecx
movslq %ecx, %rcx
incl 0x28(%rsp)
incl 0x2c(%rsp)
cmpq %rcx, %r8
movq %rax, %r8
jl 0xafd0
incq %r10
movslq 0x62110(%r13), %rdx
leaq -0x5(%rdx), %rax
incq 0x68(%rsp)
incl 0x24(%rsp)
incl 0x1c(%rsp)
incl 0x14(%rsp)
incq 0x60(%rsp)
incq 0x78(%rsp)
incl 0x20(%rsp)
incl 0x18(%rsp)
cmpq %rax, %r10
jl 0xaf6b
testl %edx, %edx
jle 0xb6d3
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq 0x48(%rsp), %rcx
movq (%rcx), %rcx
movss 0xe4029(%rip), %xmm0    # 0xef450
movl %edx, %edx
movq 0x62140(%r13), %rsi
xorl %edi, %edi
xorpd %xmm1, %xmm1
leaq 0xdffc3(%rip), %r8      # 0xeb400
movsd 0x4151b(%rip), %xmm2    # 0x4c960
movsd 0x4153b(%rip), %xmm3    # 0x4c988
movsd 0x41513(%rip), %xmm4    # 0x4c968
leaq 0xdbf44(%rip), %r9      # 0xe73a0
movsd 0x4150c(%rip), %xmm5    # 0x4c970
movsd 0x4150c(%rip), %xmm6    # 0x4c978
movsd (%rax,%rdi,8), %xmm7
ucomisd %xmm1, %xmm7
jne 0xb47d
jnp 0xb59c
addsd (%rcx,%rdi,8), %xmm7
cvtsd2ss %xmm7, %xmm7
movd %xmm7, %r10d
movl %r10d, %r11d
andl $0x7f800000, %r11d      # imm = 0x7F800000
movl %r10d, %ebx
addl $0xc0800000, %r11d      # imm = 0xC0800000
xorps %xmm7, %xmm7
cvtsi2ss %r11d, %xmm7
shrl $0x9, %r10d
andl $0x3ff8, %r10d          # imm = 0x3FF8
mulss %xmm0, %xmm7
addss 0x50(%r10,%r8), %xmm7
andl $0xfff, %ebx            # imm = 0xFFF
xorps %xmm8, %xmm8
cvtsi2ss %ebx, %xmm8
mulss 0x54(%r10,%r8), %xmm8
addss %xmm7, %xmm8
cvtss2sd %xmm8, %xmm8
movsd %xmm8, (%rax,%rdi,8)
subsd (%rsi,%rdx,8), %xmm8
xorps %xmm7, %xmm7
ucomisd %xmm8, %xmm2
jae 0xb597
ucomisd %xmm4, %xmm8
movaps %xmm3, %xmm7
jae 0xb597
movsd 0xdfec3(%rip), %xmm7    # 0xeb3d0
mulsd %xmm8, %xmm7
addsd %xmm5, %xmm7
movq %xmm7, %r10
movl %r10d, %r11d
andl $0x7ff, %r11d           # imm = 0x7FF
addsd %xmm6, %xmm7
mulsd 0xdfea7(%rip), %xmm7    # 0xeb3d8
subsd %xmm8, %xmm7
shlq $0x29, %r10
movabsq $-0x10000000000000, %rbx # imm = 0xFFF0000000000000
andq %rbx, %r10
movsd 0xdbe70(%rip), %xmm8    # 0xe73c0
subsd %xmm7, %xmm8
movapd %xmm7, %xmm9
mulsd %xmm7, %xmm9
mulsd %xmm8, %xmm9
mulsd 0xdbe43(%rip), %xmm9    # 0xe73b0
movabsq $0x3ff0000000000000, %rbx # imm = 0x3FF0000000000000
addq %rbx, %r10
subsd %xmm7, %xmm9
addsd 0xdbe18(%rip), %xmm9    # 0xe73a0
orq 0x30(%r9,%r11,8), %r10
movq %r10, %xmm7
mulsd %xmm9, %xmm7
movsd %xmm7, (%rax,%rdi,8)
movsd (%rcx,%rdi,8), %xmm7
ucomisd %xmm1, %xmm7
jne 0xb5ad
jnp 0xb6c7
cvtsd2ss %xmm7, %xmm7
movd %xmm7, %r10d
movl %r10d, %r11d
andl $0x7f800000, %r11d      # imm = 0x7F800000
movl %r10d, %ebx
addl $0xc0800000, %r11d      # imm = 0xC0800000
xorps %xmm7, %xmm7
cvtsi2ss %r11d, %xmm7
shrl $0x9, %r10d
andl $0x3ff8, %r10d          # imm = 0x3FF8
mulss %xmm0, %xmm7
addss 0x50(%r10,%r8), %xmm7
andl $0xfff, %ebx            # imm = 0xFFF
xorps %xmm8, %xmm8
cvtsi2ss %ebx, %xmm8
mulss 0x54(%r10,%r8), %xmm8
addss %xmm7, %xmm8
cvtss2sd %xmm8, %xmm8
movsd %xmm8, (%rcx,%rdi,8)
subsd (%rsi,%rdx,8), %xmm8
xorps %xmm7, %xmm7
ucomisd %xmm8, %xmm2
jae 0xb6c2
ucomisd %xmm4, %xmm8
movaps %xmm3, %xmm7
jae 0xb6c2
movsd 0xdfd98(%rip), %xmm7    # 0xeb3d0
mulsd %xmm8, %xmm7
addsd %xmm5, %xmm7
movq %xmm7, %r10
movl %r10d, %r11d
andl $0x7ff, %r11d           # imm = 0x7FF
addsd %xmm6, %xmm7
mulsd 0xdfd7c(%rip), %xmm7    # 0xeb3d8
subsd %xmm8, %xmm7
shlq $0x29, %r10
movabsq $-0x10000000000000, %rbx # imm = 0xFFF0000000000000
andq %rbx, %r10
movsd 0xdbd45(%rip), %xmm8    # 0xe73c0
subsd %xmm7, %xmm8
movapd %xmm7, %xmm9
mulsd %xmm7, %xmm9
mulsd %xmm8, %xmm9
mulsd 0xdbd18(%rip), %xmm9    # 0xe73b0
movabsq $0x3ff0000000000000, %rbx # imm = 0x3FF0000000000000
addq %rbx, %r10
subsd %xmm7, %xmm9
addsd 0xdbced(%rip), %xmm9    # 0xe73a0
orq 0x30(%r9,%r11,8), %r10
movq %r10, %xmm7
mulsd %xmm9, %xmm7
movsd %xmm7, (%rcx,%rdi,8)
incq %rdi
cmpq %rdi, %rdx
jne 0xb46c
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0xb718
movq 0xa8(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
xorl %eax, %eax
movq %rax, 0x88(%rsp)
movl %eax, 0x90(%rsp)
movq %rax, 0x98(%rsp)
movl %eax, 0xa0(%rsp)
movq %rax, 0xa8(%rsp)
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0xb75d
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
xorl %eax, %eax
movq %rax, 0xb0(%rsp)
movl %eax, 0xb8(%rsp)
movq %rax, 0xc0(%rsp)
movl %eax, 0xc8(%rsp)
movq %rax, 0xd0(%rsp)
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0xb7bc
movq 0xa8(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
xorl %eax, %eax
movq %rax, 0x88(%rsp)
movl %eax, 0x90(%rsp)
movq %rax, 0x98(%rsp)
movl %eax, 0xa0(%rsp)
movq %rax, 0xa8(%rsp)
jmp 0xb7bc
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0xb801
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
xorl %eax, %eax
movq %rax, 0xb0(%rsp)
movl %eax, 0xb8(%rsp)
movq %rax, 0xc0(%rsp)
movl %eax, 0xc8(%rsp)
movq %rax, 0xd0(%rsp)
movq %rbx, %rdi
callq 0x33e0
nop