// File: /workspace/github_c_makefile_star2_O3/fukunagatsu[P]RIblast/raccess.cpp
// Function: Raccess::CalcLogSumBulgeAndInternalProbability(std::vector<double, std::allocator<double>>&, std::vector<double, std::allocator<double>>&)
void Raccess::CalcLogSumBulgeAndInternalProbability(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 = _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] = b_flag_array[k-1] == 1 ? logsumexp(biloop_probability[k-1], temp) : temp;
		    b_flag_array[k-1] = 1;		   
		  }else{
		    conditional_biloop_probability[k-1] = c_flag_array[k-1] == 1 ? logsumexp(conditional_biloop_probability[k-1], temp) : temp;
		    c_flag_array[k-1] = 1;		  
		  }
		}
		
		for(int k = q+1; k <= j-w;k++){
		  if(k == j-w){
		    biloop_probability[k-1] = b_flag_array[k-1] == 1 ? logsumexp(biloop_probability[k-1], temp) : temp;
		    b_flag_array[k-1] = 1;
		  }else{
		    conditional_biloop_probability[k-1] = c_flag_array[k-1] == 1 ? logsumexp(conditional_biloop_probability[k-1], temp) : temp;
		    c_flag_array[k-1] = 1;
		  }
		}
	      } 
	    }
	  }
	}
      }
    }
  }
  
  for(int i=0;i<_seq_length;i++){
    if(b_flag_array[i]==1 && c_flag_array[i]==1){
      biloop_probability[i] = logsumexp(biloop_probability[i], conditional_biloop_probability[i]);
    }
    if(b_flag_array[i]==0 && c_flag_array[i]==1){
      biloop_probability[i] = conditional_biloop_probability[i];
    }
    if(b_flag_array[i]==1){
      biloop_probability[i] = fmath::expd(biloop_probability[i]-_Alpha_outer[_seq_length]);
    }
    if(c_flag_array[i]==1){
      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 $0x188, %rsp            # imm = 0x188
movq %rdx, 0x68(%rsp)
movq %rsi, 0x60(%rsp)
movq %rdi, %rbp
xorl %ebx, %ebx
leaq 0x160(%rsp), %rdi
movq %rbx, (%rdi)
movl %ebx, 0x8(%rdi)
movq %rbx, 0x10(%rdi)
movl %ebx, 0x18(%rdi)
movq %rbx, 0x20(%rdi)
movslq 0x62110(%rbp), %rsi
xorl %edx, %edx
callq 0xdc22
leaq 0x158(%rsp), %r14
movq %rbx, -0x20(%r14)
movl %ebx, -0x18(%r14)
movq %rbx, -0x10(%r14)
movl %ebx, -0x8(%r14)
movq %rbx, (%r14)
movslq 0x62110(%rbp), %rsi
leaq 0x138(%rsp), %rdi
xorl %edx, %edx
callq 0xdc22
movl 0x62110(%rbp), %eax
cmpl $0x7, %eax
jl 0xcf37
movslq 0x62118(%rbp), %rdx
movl $0x3, %ecx
subl %edx, %ecx
movl %ecx, 0x34(%rsp)
movl 0x62114(%rbp), %ecx
movl $0x2, %esi
subl %edx, %esi
movl %esi, 0x30(%rsp)
movl $0x7, %esi
movq %rdx, 0xc0(%rsp)
subl %edx, %esi
movl %esi, 0x28(%rsp)
movl $0x2, %edx
movq %rdx, 0xb8(%rsp)
movl $0x6, 0x2c(%rsp)
movl $0xffffffe8, 0x24(%rsp) # imm = 0xFFFFFFE8
movl $0x7, %edx
movq %rdx, 0xb0(%rsp)
movl $0x1, %r8d
leal (%rcx,%r8), %edx
cmpl %edx, %eax
cmovll %eax, %edx
leaq 0x6(%r8), %rsi
movslq %edx, %rdx
leaq 0x1(%r8), %rdi
movq %rdi, 0xc8(%rsp)
cmpq %rdx, %rsi
jg 0xcef9
movq %r8, %rdx
notq %rdx
movq %rdx, 0x110(%rsp)
leal 0x1f(%r8), %edx
movl %edx, 0xa0(%rsp)
movl 0x28(%rsp), %r9d
movq 0xb0(%rsp), %r11
movl 0x24(%rsp), %r10d
movq %r8, 0x48(%rsp)
movq 0x620f8(%rbp), %rdx
movslq (%rdx,%r8,4), %rsi
movslq (%rdx,%r11,4), %rdx
leaq (%rsi,%rsi,4), %rsi
leaq 0x41244(%rip), %rdi     # 0x4dba0
leaq (%rdi,%rsi,4), %rsi
movl (%rsi,%rdx,4), %edx
movl %edx, 0xac(%rsp)
testl %edx, %edx
je 0xced7
leaq -0x5(%r11), %rdx
cmpq %r8, %rdx
jbe 0xced7
movl %r9d, 0xa8(%rsp)
movl %r9d, %eax
decq %rax
movq %rax, 0x128(%rsp)
movl 0xa0(%rsp), %eax
cmpl %eax, %edx
cmovgel %eax, %edx
movl %r11d, %eax
subl %r8d, %eax
leaq -0x1(%r11), %rcx
movq %rcx, 0x118(%rsp)
movq %r11, %rcx
subq 0xc0(%rsp), %rcx
movq %rcx, 0x58(%rsp)
movslq %edx, %rcx
movq %rcx, 0xe8(%rsp)
addl $-0x20, %eax
movq %rax, 0xf0(%rsp)
movl 0x30(%rsp), %eax
movl %eax, 0x44(%rsp)
movq 0xb8(%rsp), %rdi
movl %r10d, 0xa4(%rsp)
movl %r10d, 0x40(%rsp)
movl 0x2c(%rsp), %eax
movl %eax, 0x3c(%rsp)
movl 0x34(%rsp), %eax
movl %eax, 0x38(%rsp)
movq %r11, 0x90(%rsp)
movq 0xf0(%rsp), %rax
addl %edi, %eax
leal 0x4(%rdi), %ecx
cmpl %eax, %ecx
cmovgl %ecx, %eax
cmpq %rax, %r11
jbe 0xce91
movl 0x44(%rsp), %eax
movl $0x2, %ecx
subq %rax, %rcx
movq %rcx, 0x98(%rsp)
movl 0x38(%rsp), %eax
movl $0x2, %ecx
subq %rax, %rcx
movq %rcx, 0x130(%rsp)
movl 0x40(%rsp), %eax
movl 0x3c(%rsp), %ecx
cmpl %eax, %ecx
movl %eax, %r8d
cmovgl %ecx, %r8d
movq %rdi, %rax
subq 0xc0(%rsp), %rax
movq %rax, 0x100(%rsp)
movl %eax, %eax
movq %rax, 0xd0(%rsp)
leaq -0x1(%rax), %rcx
movq %rcx, %rax
movl %ecx, %r9d
shrl $0x6, %r9d
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
leaq 0x3f(%rsi), %rdx
movq %rdx, 0x120(%rsp)
andq %rdx, %rax
xorl %edx, %edx
cmpq %rsi, %rax
setbe %dl
leaq -0x1(%rdi), %rax
movq %rax, 0x108(%rsp)
leaq -0x8(,%rdx,8), %rax
movq %rax, 0xe0(%rsp)
movl $0x1, %eax
shlq %cl, %rax
movq %rax, 0xd8(%rsp)
shll $0x3, %r9d
movq %r9, 0xf8(%rsp)
movq %rdi, 0x70(%rsp)
movq %rdi, %rcx
xorq 0xc8(%rsp), %rcx
movq 0x620f8(%rbp), %rax
movslq (%rax,%rdi,4), %rdx
movslq (%rax,%r8,4), %rax
leaq (%rdx,%rdx,4), %rdx
leaq 0x41090(%rip), %rsi     # 0x4dba0
leaq (%rsi,%rdx,4), %rdx
movslq (%rdx,%rax,4), %rax
movq %r8, 0x18(%rsp)
movq %r8, %rdx
xorq 0x118(%rsp), %rdx
orq %rcx, %rdx
sete %cl
testq %rax, %rax
je 0xce73
testb %cl, %cl
jne 0xce73
movq 0x62218(%rbp), %rcx
movq 0x48(%rsp), %rdx
leaq (%rdx,%rdx,2), %rdx
movq 0x90(%rsp), %rsi
leaq (,%rsi,8), %rsi
addq (%rcx,%rdx,8), %rsi
movq 0x110(%rsp), %rcx
movsd (%rsi,%rcx,8), %xmm1
ucomisd 0x40e98(%rip), %xmm1    # 0x4da10
jne 0xcb80
jnp 0xce73
movq 0x62158(%rbp), %rcx
movq 0x108(%rsp), %rdx
leaq (%rdx,%rdx,2), %rbx
movq 0x18(%rsp), %r14
subl 0x70(%rsp), %r14d
shlq $0x20, %r14
movabsq $0x100000000, %rdx      # imm = 0x100000000
addq %rdx, %r14
movq (%rcx,%rbx,8), %rcx
movq %r14, %rdx
sarq $0x1d, %rdx
movsd (%rcx,%rdx), %xmm0
ucomisd 0x40e4a(%rip), %xmm0    # 0x4da10
jne 0xcbce
jnp 0xce73
leaq 0x4103b(%rip), %rcx     # 0x4dc10
movl (%rcx,%rax,4), %edx
sarq $0x20, %r14
movq 0x18(%rsp), %rax
movl %eax, (%rsp)
movq %rbp, %rdi
movl 0xac(%rsp), %esi
movq 0x48(%rsp), %r15
movl %r15d, %ecx
movq 0x90(%rsp), %r8
movq 0x70(%rsp), %r9
movsd %xmm1, 0x10(%rsp)
callq 0xb970
movsd 0x10(%rsp), %xmm1
addsd %xmm0, %xmm1
movq 0x62158(%rbp), %rax
movq (%rax,%rbx,8), %rax
addsd (%rax,%r14,8), %xmm1
cmpq 0x100(%rsp), %r15
movq 0xd0(%rsp), %r14
movsd %xmm1, 0x10(%rsp)
jge 0xcda7
movq 0x138(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rsi
movq 0x60(%rsp), %rax
movq (%rax), %r15
movq 0x160(%rsp), %r13
addq 0xf8(%rsp), %r13
movq 0x48(%rsp), %r12
movq %rsi, 0x50(%rsp)
movq %r15, 0x80(%rsp)
movq %r13, 0x78(%rsp)
movq 0x98(%rsp), %rax
addq %r12, %rax
cmpq $0x1, %rax
jne 0xccf6
movq 0xe0(%rsp), %rax
movq (%r13,%rax), %rbx
movapd %xmm1, %xmm0
testq %rbx, 0xd8(%rsp)
je 0xccd5
movsd -0x8(%r15,%r14,8), %xmm0
movsd 0x10(%rsp), %xmm1
callq 0xbc7e
movq 0x50(%rsp), %rsi
movsd 0x10(%rsp), %xmm1
movsd %xmm0, -0x8(%r15,%r14,8)
orq 0xd8(%rsp), %rbx
movq 0xe0(%rsp), %rax
movq %rbx, (%r13,%rax)
jmp 0xcd8c
movq %rbp, %r13
movl %r12d, %eax
shrl $0x6, %eax
movq %r12, %rcx
andq 0x120(%rsp), %rcx
xorl %ebx, %ebx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
cmpq %rdx, %rcx
setbe %bl
movl $0x1, %r15d
movl %r12d, %ecx
shlq %cl, %r15
movq 0x88(%rsp), %rcx
leaq (%rcx,%rax,8), %r14
movq -0x8(%r14,%rbx,8), %rbp
btq %r12, %rbp
movapd %xmm1, %xmm0
jae 0xcd5f
movsd (%rsi,%r12,8), %xmm0
movsd 0x10(%rsp), %xmm1
callq 0xbc7e
movq 0x50(%rsp), %rsi
movsd 0x10(%rsp), %xmm1
leaq -0x8(,%rbx,8), %rax
movsd %xmm0, (%rsi,%r12,8)
orq %r15, %rbp
movq %rbp, (%r14,%rax)
movq %r13, %rbp
movq 0xd0(%rsp), %r14
movq 0x80(%rsp), %r15
movq 0x78(%rsp), %r13
movq 0x130(%rsp), %rax
addq %r12, %rax
incq %rax
incq %r12
cmpq $0x1, %rax
jne 0xcc8c
movq 0x18(%rsp), %rax
cmpq 0x58(%rsp), %rax
jge 0xce73
movq 0x138(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x88(%rsp)
movq 0x160(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x60(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x78(%rsp)
movq 0x18(%rsp), %r12
movl %r12d, %eax
shrl $0x6, %eax
movl $0x1, %ebx
movl %r12d, %ecx
shlq %cl, %rbx
cmpq %r12, 0x128(%rsp)
jne 0xce27
movq 0x80(%rsp), %rcx
leaq (%rcx,%rax,8), %r15
movq (%r15), %r14
movq 0x78(%rsp), %r13
jmp 0xce3b
movq 0x50(%rsp), %rcx
leaq (%rcx,%rax,8), %r15
movq (%r15), %r14
movq 0x88(%rsp), %r13
movapd %xmm1, %xmm0
testq %rbx, %r14
je 0xce5c
movsd (%r13,%r12,8), %xmm0
movsd 0x10(%rsp), %xmm1
callq 0xbc7e
movsd 0x10(%rsp), %xmm1
movsd %xmm0, (%r13,%r12,8)
incq %r12
orq %rbx, %r14
movq %r14, (%r15)
cmpq 0x58(%rsp), %r12
jl 0xcdf6
movq 0x18(%rsp), %r8
incq %r8
movq 0x90(%rsp), %r11
cmpq %r11, %r8
movq 0x70(%rsp), %rdi
jb 0xcaeb
leaq 0x1(%rdi), %rax
incl 0x38(%rsp)
incl 0x3c(%rsp)
incl 0x40(%rsp)
incl 0x44(%rsp)
cmpq 0xe8(%rsp), %rdi
movq %rax, %rdi
jl 0xca0e
movl 0x62110(%rbp), %eax
movl 0x62114(%rbp), %ecx
movq 0x48(%rsp), %r8
movl 0xa8(%rsp), %r9d
movl 0xa4(%rsp), %r10d
leaq 0x1(%r11), %rdx
leal (%rcx,%r8), %esi
cmpl %esi, %eax
cmovll %eax, %esi
movslq %esi, %rsi
incl %r10d
incl %r9d
cmpq %rsi, %r11
movq %rdx, %r11
jl 0xc942
leal -0x5(%rax), %edx
movslq %edx, %rdx
incq 0xb8(%rsp)
incl 0x34(%rsp)
incl 0x2c(%rsp)
incl 0x24(%rsp)
incq 0xb0(%rsp)
incl 0x30(%rsp)
incl 0x28(%rsp)
movq 0xc8(%rsp), %rsi
movq %rsi, %r8
cmpq %rdx, %rsi
jl 0xc8ed
movq 0x138(%rsp), %rdi
testl %eax, %eax
jle 0xd1a4
movq 0x160(%rsp), %rcx
movq %rcx, 0x10(%rsp)
movq 0x60(%rsp), %rdx
movq (%rdx), %r15
movq 0x68(%rsp), %rdx
movq (%rdx), %r8
movl %eax, %r10d
movq 0x62140(%rbp), %r12
xorl %ebx, %ebx
movsd 0x40ac8(%rip), %xmm3    # 0x4da40
movq %r8, 0x58(%rsp)
movq %rdi, 0x98(%rsp)
movl %ebx, %eax
movl $0x1, %r14d
movl %ebx, %ecx
shlq %cl, %r14
shrl $0x6, %eax
movq 0x10(%rsp), %rcx
movq (%rcx,%rax,8), %rcx
btq %rbx, %rcx
movq (%rdi,%rax,8), %r13
jae 0xd0b1
movsd (%r15,%rbx,8), %xmm0
testq %r14, %r13
je 0xcfd6
movsd (%r8,%rbx,8), %xmm1
movq %r10, %rbp
callq 0xbc7e
movsd 0x40a73(%rip), %xmm3    # 0x4da40
movq %rbp, %r10
movsd %xmm0, (%r15,%rbx,8)
subsd (%r12,%r10,8), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm3
jae 0xd094
ucomisd 0x40a56(%rip), %xmm0    # 0x4da48
movsd 0x40a6e(%rip), %xmm1    # 0x4da68
jae 0xd094
movsd 0xdf3c8(%rip), %xmm1    # 0xec3d0
mulsd %xmm0, %xmm1
addsd 0x40a3c(%rip), %xmm1    # 0x4da50
movq %xmm1, %rax
movl %eax, %ecx
andl $0x7ff, %ecx            # imm = 0x7FF
addsd 0x40a2f(%rip), %xmm1    # 0x4da58
mulsd 0xdf3a7(%rip), %xmm1    # 0xec3d8
subsd %xmm0, %xmm1
shlq $0x29, %rax
movabsq $-0x10000000000000, %rdx # imm = 0xFFF0000000000000
andq %rdx, %rax
movsd 0xdb372(%rip), %xmm0    # 0xe83c0
subsd %xmm1, %xmm0
movapd %xmm1, %xmm2
mulsd %xmm1, %xmm2
mulsd %xmm0, %xmm2
mulsd 0xdb34a(%rip), %xmm2    # 0xe83b0
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
addq %rdx, %rax
subsd %xmm1, %xmm2
addsd 0xdb321(%rip), %xmm2    # 0xe83a0
leaq 0xdb31a(%rip), %rdx     # 0xe83a0
orq 0x30(%rdx,%rcx,8), %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm1
movsd %xmm1, (%r15,%rbx,8)
testq %r14, %r13
movq 0x98(%rsp), %rdi
movq 0x58(%rsp), %r8
jne 0xd0c6
jmp 0xd190
testq %r14, %r13
je 0xd190
movsd (%r8,%rbx,8), %xmm0
movsd %xmm0, (%r15,%rbx,8)
movsd (%r8,%rbx,8), %xmm1
subsd (%r12,%r10,8), %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm3
jae 0xd18a
ucomisd 0x40960(%rip), %xmm1    # 0x4da48
movsd 0x40978(%rip), %xmm0    # 0x4da68
jae 0xd18a
movsd 0xdf2d2(%rip), %xmm0    # 0xec3d0
mulsd %xmm1, %xmm0
addsd 0x40946(%rip), %xmm0    # 0x4da50
movq %xmm0, %rax
movl %eax, %ecx
andl $0x7ff, %ecx            # imm = 0x7FF
addsd 0x40939(%rip), %xmm0    # 0x4da58
mulsd 0xdf2b1(%rip), %xmm0    # 0xec3d8
subsd %xmm1, %xmm0
shlq $0x29, %rax
movabsq $-0x10000000000000, %rdx # imm = 0xFFF0000000000000
andq %rdx, %rax
movsd 0xdb27c(%rip), %xmm1    # 0xe83c0
subsd %xmm0, %xmm1
movapd %xmm0, %xmm2
mulsd %xmm0, %xmm2
mulsd %xmm1, %xmm2
mulsd 0xdb254(%rip), %xmm2    # 0xe83b0
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
addq %rdx, %rax
subsd %xmm0, %xmm2
addsd 0xdb22b(%rip), %xmm2    # 0xe83a0
leaq 0xdb224(%rip), %rdx     # 0xe83a0
orq 0x30(%rdx,%rcx,8), %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
movsd %xmm0, (%r8,%rbx,8)
incq %rbx
cmpq %rbx, %r10
jne 0xcf85
movq 0x138(%rsp), %rdi
testq %rdi, %rdi
je 0xd1d0
movq 0x158(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq $0x0, 0x138(%rsp)
movl $0x0, 0x140(%rsp)
movq 0x160(%rsp), %rdi
testq %rdi, %rdi
je 0xd1ed
movq 0x180(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x138(%rsp), %rsi
testq %rsi, %rsi
je 0xd21c
movq %r14, %rdi
callq 0x3562
jmp 0xd21c
movq %rax, %rbx
movq 0x160(%rsp), %rdi
testq %rdi, %rdi
je 0xd239
movq 0x180(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq %rbx, %rdi
callq 0x33e0
nop