// File: /workspace/github_c_makefile_star2_O3/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 $0x128, %rsp            # imm = 0x128
movq %rdx, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdi, %r13
xorl %ebx, %ebx
leaq 0x100(%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 0xdc22
leaq 0xf8(%rsp), %r14
movq %rbx, -0x20(%r14)
movl %ebx, -0x18(%r14)
movq %rbx, -0x10(%r14)
movl %ebx, -0x8(%r14)
movq %rbx, (%r14)
movslq 0x62110(%r13), %rsi
leaq 0xd8(%rsp), %rdi
xorl %edx, %edx
callq 0xdc22
movl 0x62110(%r13), %edx
cmpl $0x7, %edx
jl 0xc49a
movslq 0x62118(%r13), %rcx
movl $0x3, %eax
subl %ecx, %eax
movl %eax, 0x1c(%rsp)
movl 0x62114(%r13), %eax
movl $0x2, %esi
subl %ecx, %esi
movl %esi, 0x18(%rsp)
movl $0x7, %esi
movq %rcx, 0x60(%rsp)
subl %ecx, %esi
movl %esi, 0x10(%rsp)
movl $0x2, %ecx
movq %rcx, 0x28(%rsp)
movl $0x6, 0x14(%rsp)
movl $0xffffffe8, 0xc(%rsp)  # imm = 0xFFFFFFE8
movl $0x7, %ecx
movq %rcx, 0x58(%rsp)
movl $0x1, %r11d
movl $0x8, %ecx
movq %rcx, 0x68(%rsp)
leaq 0x41b87(%rip), %rdi     # 0x4dba0
movsd 0x419ef(%rip), %xmm2    # 0x4da10
leal (%rax,%r11), %ecx
cmpl %ecx, %edx
cmovll %edx, %ecx
leaq 0x6(%r11), %rsi
movslq %ecx, %rcx
leaq 0x1(%r11), %r9
cmpq %rcx, %rsi
jg 0xc464
movq %r11, %r10
notq %r10
leal 0x1f(%r11), %ecx
movl %ecx, 0x48(%rsp)
movl 0x10(%rsp), %ebp
movq 0x58(%rsp), %r8
movl 0xc(%rsp), %ebx
movq %r11, 0xa0(%rsp)
movq %r9, 0x98(%rsp)
movq %r10, 0x90(%rsp)
movq 0x620f8(%r13), %rcx
movslq (%rcx,%r11,4), %rsi
movslq (%rcx,%r8,4), %rcx
leaq (%rsi,%rsi,4), %rsi
leaq (%rdi,%rsi,4), %rsi
movl (%rsi,%rcx,4), %ecx
movl %ecx, 0x54(%rsp)
testl %ecx, %ecx
je 0xc444
leaq -0x5(%r8), %rcx
cmpq %r11, %rcx
jbe 0xc444
movl %ebp, 0x50(%rsp)
movl %ebp, %eax
decq %rax
movq %rax, 0xd0(%rsp)
movl 0x48(%rsp), %eax
cmpl %eax, %ecx
cmovgel %eax, %ecx
movl %r8d, %eax
subl %r11d, %eax
leaq -0x1(%r8), %rdx
movq %rdx, 0xc8(%rsp)
movq %r8, %rdx
subq 0x60(%rsp), %rdx
movq %rdx, 0x70(%rsp)
movslq %ecx, %rcx
movq %rcx, 0x78(%rsp)
addl $-0x20, %eax
movq %rax, 0x80(%rsp)
movl 0x18(%rsp), %eax
movl %eax, %ebp
movq 0x28(%rsp), %rdx
movl %ebx, 0x4c(%rsp)
movl %ebx, 0x24(%rsp)
movl 0x14(%rsp), %eax
movl %eax, 0x20(%rsp)
movl 0x1c(%rsp), %eax
movl %eax, %ebx
movq %r8, 0xa8(%rsp)
movl %ebp, %ebp
movl %ebx, %ebx
movq 0x80(%rsp), %rax
addl %edx, %eax
leal 0x4(%rdx), %ecx
cmpl %eax, %ecx
cmovgl %ecx, %eax
cmpq %rax, %r8
jbe 0xc410
movl 0x24(%rsp), %eax
movl 0x20(%rsp), %ecx
cmpl %eax, %ecx
movl %eax, %r14d
cmovgl %ecx, %r14d
leaq -0x1(%rdx), %rax
movq %rax, 0xb8(%rsp)
movq %rdx, %rax
subq 0x60(%rsp), %rax
movq %rax, 0xb0(%rsp)
movl %eax, %eax
movq %rax, 0x88(%rsp)
movq %rdx, 0x40(%rsp)
movq %rdx, %rcx
xorq %r9, %rcx
movq 0x620f8(%r13), %rax
movslq (%rax,%rdx,4), %rdx
movslq (%rax,%r14,4), %rax
leaq (%rdx,%rdx,4), %rdx
leaq (%rdi,%rdx,4), %rdx
movslq (%rdx,%rax,4), %rax
movq %r14, %rdx
xorq 0xc8(%rsp), %rdx
orq %rcx, %rdx
sete %cl
testq %rax, %rax
je 0xc3ff
testb %cl, %cl
jne 0xc3ff
movq 0x62218(%r13), %rcx
leaq (%r11,%r11,2), %rdx
leaq (,%r8,8), %rsi
addq (%rcx,%rdx,8), %rsi
movsd (%rsi,%r10,8), %xmm1
ucomisd %xmm2, %xmm1
jne 0xc1e0
jnp 0xc3ff
movq 0x62158(%r13), %rcx
movq 0xb8(%rsp), %rdx
leaq (%rdx,%rdx,2), %r15
movl %r14d, %r12d
subl 0x40(%rsp), %r12d
shlq $0x20, %r12
movabsq $0x100000000, %rdx      # imm = 0x100000000
addq %rdx, %r12
movq (%rcx,%r15,8), %rcx
movq %r12, %rdx
sarq $0x1d, %rdx
movsd (%rcx,%rdx), %xmm0
ucomisd %xmm2, %xmm0
jne 0xc228
jnp 0xc3ff
leaq 0x419e1(%rip), %rcx     # 0x4dc10
movl (%rcx,%rax,4), %edx
sarq $0x20, %r12
movl %r14d, (%rsp)
movq %r13, %rdi
movl 0x54(%rsp), %esi
movl %r11d, %ecx
movq 0x40(%rsp), %r9
movsd %xmm1, 0xc0(%rsp)
callq 0xb970
movsd 0xc0(%rsp), %xmm2
addsd %xmm0, %xmm2
movq 0x62158(%r13), %rax
movq (%rax,%r15,8), %rax
addsd (%rax,%r12,8), %xmm2
xorpd %xmm0, %xmm0
movsd 0x417bf(%rip), %xmm1    # 0x4da40
ucomisd %xmm2, %xmm1
jae 0xc335
ucomisd 0x417b5(%rip), %xmm2    # 0x4da48
movsd 0x417cd(%rip), %xmm0    # 0x4da68
jae 0xc335
movsd 0xe0127(%rip), %xmm0    # 0xec3d0
mulsd %xmm2, %xmm0
addsd 0x4179b(%rip), %xmm0    # 0x4da50
movq %xmm0, %rax
movl %eax, %ecx
andl $0x7ff, %ecx            # imm = 0x7FF
addsd 0x4178e(%rip), %xmm0    # 0x4da58
mulsd 0xe0106(%rip), %xmm0    # 0xec3d8
subsd %xmm2, %xmm0
shlq $0x29, %rax
movabsq $-0x10000000000000, %rdx # imm = 0xFFF0000000000000
andq %rdx, %rax
movsd 0xdc0d1(%rip), %xmm1    # 0xe83c0
subsd %xmm0, %xmm1
movapd %xmm0, %xmm2
mulsd %xmm0, %xmm2
mulsd %xmm1, %xmm2
mulsd 0xdc0a9(%rip), %xmm2    # 0xe83b0
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
addq %rdx, %rax
subsd %xmm0, %xmm2
addsd 0xdc080(%rip), %xmm2    # 0xe83a0
leaq 0xdc079(%rip), %rdx     # 0xe83a0
orq 0x30(%rdx,%rcx,8), %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
movq 0xa0(%rsp), %r11
cmpq 0xb0(%rsp), %r11
jge 0xc393
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq 0x88(%rsp), %rcx
leaq (%rax,%rcx,8), %rax
addq $-0x8, %rax
movq 0x38(%rsp), %rcx
movq (%rcx), %rcx
addq 0x68(%rsp), %rcx
movq 0x28(%rsp), %rdx
cmpq %rdx, %rbp
movq %rcx, %rsi
cmoveq %rax, %rsi
movsd (%rsi), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsi)
incq %rdx
addq $0x8, %rcx
cmpq %rdx, %rbx
jne 0xc371
cmpq 0x70(%rsp), %r14
leaq 0x41801(%rip), %rdi     # 0x4dba0
movsd 0x41669(%rip), %xmm2    # 0x4da10
movq 0x98(%rsp), %r9
movq 0x90(%rsp), %r10
movq 0xa8(%rsp), %r8
jge 0xc3ff
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rsp), %rcx
movq (%rcx), %rcx
movq %r14, %rdx
cmpq %rdx, 0xd0(%rsp)
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 0x70(%rsp), %rsi
jl 0xc3d4
incq %r14
cmpq %r8, %r14
movq 0x40(%rsp), %rdx
jb 0xc174
leaq 0x1(%rdx), %rax
incl %ebx
incl 0x20(%rsp)
incl 0x24(%rsp)
incl %ebp
cmpq 0x78(%rsp), %rdx
movq %rax, %rdx
jl 0xc119
movl 0x62110(%r13), %edx
movl 0x62114(%r13), %eax
movl 0x50(%rsp), %ebp
movl 0x4c(%rsp), %ebx
leaq 0x1(%r8), %rcx
leal (%rax,%r11), %esi
cmpl %esi, %edx
cmovll %edx, %esi
movslq %esi, %rsi
incl %ebx
incl %ebp
cmpq %rsi, %r8
movq %rcx, %r8
jl 0xc071
leal -0x5(%rdx), %ecx
movslq %ecx, %rcx
incq 0x28(%rsp)
incl 0x1c(%rsp)
incl 0x14(%rsp)
incl 0xc(%rsp)
incq 0x58(%rsp)
incl 0x18(%rsp)
addq $0x8, 0x68(%rsp)
incl 0x10(%rsp)
movq %r9, %r11
cmpq %rcx, %r9
jl 0xc021
testl %edx, %edx
jle 0xc766
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq 0x38(%rsp), %rcx
movq (%rcx), %rcx
movss 0xe3f96(%rip), %xmm0    # 0xf0450
movl %edx, %edx
movq 0x62140(%r13), %rsi
xorl %edi, %edi
xorpd %xmm1, %xmm1
leaq 0xdff30(%rip), %r8      # 0xec400
movsd 0x41568(%rip), %xmm2    # 0x4da40
movsd 0x41588(%rip), %xmm3    # 0x4da68
movsd 0x41560(%rip), %xmm4    # 0x4da48
leaq 0xdbeb1(%rip), %r9      # 0xe83a0
movsd 0x41559(%rip), %xmm5    # 0x4da50
movsd 0x41559(%rip), %xmm6    # 0x4da58
movsd (%rax,%rdi,8), %xmm7
ucomisd %xmm1, %xmm7
jne 0xc510
jnp 0xc62f
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 0xc62a
ucomisd %xmm4, %xmm8
movaps %xmm3, %xmm7
jae 0xc62a
movsd 0xdfe30(%rip), %xmm7    # 0xec3d0
mulsd %xmm8, %xmm7
addsd %xmm5, %xmm7
movq %xmm7, %r10
movl %r10d, %r11d
andl $0x7ff, %r11d           # imm = 0x7FF
addsd %xmm6, %xmm7
mulsd 0xdfe14(%rip), %xmm7    # 0xec3d8
subsd %xmm8, %xmm7
shlq $0x29, %r10
movabsq $-0x10000000000000, %rbx # imm = 0xFFF0000000000000
andq %rbx, %r10
movsd 0xdbddd(%rip), %xmm8    # 0xe83c0
subsd %xmm7, %xmm8
movapd %xmm7, %xmm9
mulsd %xmm7, %xmm9
mulsd %xmm8, %xmm9
mulsd 0xdbdb0(%rip), %xmm9    # 0xe83b0
movabsq $0x3ff0000000000000, %rbx # imm = 0x3FF0000000000000
addq %rbx, %r10
subsd %xmm7, %xmm9
addsd 0xdbd85(%rip), %xmm9    # 0xe83a0
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 0xc640
jnp 0xc75a
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 0xc755
ucomisd %xmm4, %xmm8
movaps %xmm3, %xmm7
jae 0xc755
movsd 0xdfd05(%rip), %xmm7    # 0xec3d0
mulsd %xmm8, %xmm7
addsd %xmm5, %xmm7
movq %xmm7, %r10
movl %r10d, %r11d
andl $0x7ff, %r11d           # imm = 0x7FF
addsd %xmm6, %xmm7
mulsd 0xdfce9(%rip), %xmm7    # 0xec3d8
subsd %xmm8, %xmm7
shlq $0x29, %r10
movabsq $-0x10000000000000, %rbx # imm = 0xFFF0000000000000
andq %rbx, %r10
movsd 0xdbcb2(%rip), %xmm8    # 0xe83c0
subsd %xmm7, %xmm8
movapd %xmm7, %xmm9
mulsd %xmm7, %xmm9
mulsd %xmm8, %xmm9
mulsd 0xdbc85(%rip), %xmm9    # 0xe83b0
movabsq $0x3ff0000000000000, %rbx # imm = 0x3FF0000000000000
addq %rbx, %r10
subsd %xmm7, %xmm9
addsd 0xdbc5a(%rip), %xmm9    # 0xe83a0
orq 0x30(%r9,%r11,8), %r10
movq %r10, %xmm7
mulsd %xmm9, %xmm7
movsd %xmm7, (%rcx,%rdi,8)
incq %rdi
cmpq %rdi, %rdx
jne 0xc4ff
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0xc78f
movq 0xf8(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq $0x0, 0xd8(%rsp)
movq 0x100(%rsp), %rdi
testq %rdi, %rdi
je 0xc7ac
movq 0x120(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0xd8(%rsp), %rsi
testq %rsi, %rsi
je 0xc7db
movq %r14, %rdi
callq 0x354b
jmp 0xc7db
movq %rax, %rbx
movq 0x100(%rsp), %rdi
testq %rdi, %rdi
je 0xc7f8
movq 0x120(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq %rbx, %rdi
callq 0x33e0