// File: /workspace/github_c_makefile_star2_O1/fukunagatsu[P]RIblast/raccess.cpp
// Function: Raccess::CalcHairpinProbability(std::vector<double, std::allocator<double>>&, std::vector<double, std::allocator<double>>&)
void Raccess::CalcHairpinProbability(vector<double> &hairpin_probability, vector<double> &conditional_hairpin_probability){
  int w = _min_accessible_length;
  for(int x = 1; x+w-1 <=_seq_length;x++){
    double temp = 0.0;
    double c_temp = 0.0;
    int type = 0;
    bool flag = 0;
    bool c_flag = 0;
    double h_energy = 0.0;
    
    for(int i = max(1,x-_maximal_span);i<x ;i++){
      for(int j = x+w; j<=min(i+_maximal_span,_seq_length);j++){
	type = BP_pair[_int_sequence[i]][_int_sequence[j]];
	if(_Beta_stemend[i][j-i-1] != -INF){
	  h_energy = _Beta_stemend[i][j-i-1] + HairpinEnergy(type, i,j);
	  if(j == x+w){
	    temp = flag == 1 ? logsumexp(temp, h_energy) : h_energy;
	    flag = 1;
	  }else{
	    c_temp = c_flag == 1 ? logsumexp(c_temp, h_energy) :  h_energy;
	    c_flag = 1;
	  }
	}
      }
    }

    if(flag == 1 && c_flag == 1){
      temp = logsumexp(temp, c_temp);
    }
    if(flag == 0 && c_flag == 1){
      temp = c_temp;
      flag = 1;
    }
    if(flag == 1){
      hairpin_probability[x-1] = fmath::expd(temp-_Alpha_outer[_seq_length]);
    }
    if(c_flag == 1){
      conditional_hairpin_probability[x-1] = fmath::expd(c_temp-_Alpha_outer[_seq_length]);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdx, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movl 0x62118(%rdi), %ebx
cmpl 0x62110(%rdi), %ebx
jg 0xc69f
leal 0x1(%rbx), %eax
movl %eax, 0x14(%rsp)
movl $0x1, %r14d
movl %ebx, 0x2c(%rsp)
movq %rdi, 0x18(%rsp)
movq %rbx, 0x30(%rsp)
incl 0x2c(%rsp)
movl 0x62114(%rdi), %eax
movl %r14d, %r15d
subl %eax, %r15d
cmpl $0x2, %r15d
movl $0x1, %ecx
cmovgel %r15d, %ecx
cmpq %rcx, %r14
jbe 0xc44b
movl 0x14(%rsp), %ecx
movslq %ecx, %rdx
decq %rdx
movq %rdx, 0x48(%rsp)
movl %r14d, %r12d
subl %eax, %r12d
cmpl $0x2, %r12d
movl $0x1, %eax
cmovll %eax, %r12d
cmpl $0x2, %r15d
cmovll %eax, %r15d
notl %r15d
addl %ecx, %r15d
shlq $0x20, %r15
xorpd %xmm3, %xmm3
movl $0x0, 0x4(%rsp)
xorl %edx, %edx
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movq %r14, 0x50(%rsp)
movl 0x62114(%rdi), %eax
addl %r12d, %eax
movl 0x62110(%rdi), %ecx
cmpl %eax, %ecx
cmovll %ecx, %eax
cmpl %eax, 0x2c(%rsp)
movq %r15, 0x58(%rsp)
jg 0xc41d
movl 0x14(%rsp), %ebp
movq 0x48(%rsp), %r13
xorl %ebx, %ebx
movl %edx, %r14d
movq 0x62218(%rdi), %rax
leaq (%r12,%r12,2), %rcx
movq (%rax,%rcx,8), %rax
movq %r15, %rcx
sarq $0x1d, %rcx
movsd (%rax,%rcx), %xmm0
ucomisd 0x405f4(%rip), %xmm0    # 0x4c930
jne 0xc340
jnp 0xc39f
movsd %xmm3, 0x20(%rsp)
movq 0x620f8(%rdi), %rax
movslq (%rax,%r12,4), %rcx
movslq 0x4(%rax,%r13,4), %rax
leaq (%rcx,%rcx,4), %rcx
leaq 0x4066f(%rip), %rdx     # 0x4c9d0
leaq (%rdx,%rcx,4), %rcx
movl (%rcx,%rax,4), %esi
movl %r12d, %edx
movl %ebp, %ecx
movsd %xmm0, 0x60(%rsp)
callq 0xadb2
movsd 0x60(%rsp), %xmm1
addsd %xmm0, %xmm1
testq %rbx, %rbx
je 0xc3a4
testb $0x1, 0x4(%rsp)
movsd 0x20(%rsp), %xmm0
je 0xc3c1
callq 0xabc8
movapd %xmm0, %xmm3
jmp 0xc3c5
movl %r14d, %edx
jmp 0xc3e6
movb $0x1, %dl
testb $0x1, %r14b
je 0xc3d5
movsd 0x8(%rsp), %xmm0
callq 0xabc8
movb $0x1, %dl
movsd %xmm0, 0x8(%rsp)
jmp 0xc3db
movapd %xmm1, %xmm3
movl %r14d, %edx
movb $0x1, %al
movl %eax, 0x4(%rsp)
movq 0x18(%rsp), %rdi
jmp 0xc3e6
movsd %xmm1, 0x8(%rsp)
movq 0x18(%rsp), %rdi
movsd 0x20(%rsp), %xmm3
movl 0x62114(%rdi), %eax
addl %r12d, %eax
movl 0x62110(%rdi), %ecx
cmpl %eax, %ecx
cmovll %ecx, %eax
cltq
movabsq $0x100000000, %rcx      # imm = 0x100000000
addq %rcx, %r15
decq %rbx
incq %r13
incl %ebp
movl %edx, %r14d
cmpq %rax, %r13
jl 0xc319
incq %r12
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
movq 0x58(%rsp), %r15
addq %rax, %r15
movq 0x50(%rsp), %r14
cmpq %r14, %r12
jb 0xc2e8
movq 0x30(%rsp), %rbx
movl 0x4(%rsp), %ebp
jmp 0xc45d
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
xorl %edx, %edx
xorpd %xmm3, %xmm3
xorl %ebp, %ebp
movl %edx, %eax
andb %bpl, %al
testb $0x1, %al
je 0xc492
movsd 0x8(%rsp), %xmm0
movapd %xmm3, %xmm1
movsd %xmm3, 0x20(%rsp)
movl %edx, %r15d
callq 0xabc8
movl %r15d, %edx
movsd 0x20(%rsp), %xmm3
movq 0x18(%rsp), %rdi
movsd %xmm0, 0x8(%rsp)
testb $0x1, %dl
sete %al
andb %bpl, %al
orb %al, %dl
testb $0x1, %dl
je 0xc596
movapd %xmm3, %xmm0
testb %al, %al
jne 0xc4b4
movsd 0x8(%rsp), %xmm0
movslq 0x62110(%rdi), %rax
movq 0x62140(%rdi), %rcx
subsd (%rcx,%rax,8), %xmm0
xorpd %xmm1, %xmm1
movsd 0x4048d(%rip), %xmm2    # 0x4c960
ucomisd %xmm0, %xmm2
jae 0xc587
ucomisd 0x40483(%rip), %xmm0    # 0x4c968
movsd 0x4049b(%rip), %xmm1    # 0x4c988
jae 0xc587
movsd 0xdeed5(%rip), %xmm1    # 0xeb3d0
mulsd %xmm0, %xmm1
addsd 0x40469(%rip), %xmm1    # 0x4c970
movq %xmm1, %rax
movl %eax, %ecx
andl $0x7ff, %ecx            # imm = 0x7FF
addsd 0x4045c(%rip), %xmm1    # 0x4c978
mulsd 0xdeeb4(%rip), %xmm1    # 0xeb3d8
subsd %xmm0, %xmm1
shlq $0x29, %rax
movabsq $-0x10000000000000, %rdx # imm = 0xFFF0000000000000
andq %rdx, %rax
movsd 0xdae7f(%rip), %xmm0    # 0xe73c0
subsd %xmm1, %xmm0
movapd %xmm1, %xmm2
mulsd %xmm1, %xmm2
mulsd %xmm0, %xmm2
mulsd 0xdae57(%rip), %xmm2    # 0xe73b0
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
addq %rdx, %rax
subsd %xmm1, %xmm2
addsd 0xdae2e(%rip), %xmm2    # 0xe73a0
leaq 0xdae27(%rip), %rdx     # 0xe73a0
orq 0x30(%rdx,%rcx,8), %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm1
movq 0x38(%rsp), %rax
movq (%rax), %rax
movsd %xmm1, -0x8(%rax,%r14,8)
testb $0x1, %bpl
je 0xc682
movslq 0x62110(%rdi), %rax
movq 0x62140(%rdi), %rcx
subsd (%rcx,%rax,8), %xmm3
xorpd %xmm0, %xmm0
movsd 0x403a1(%rip), %xmm1    # 0x4c960
ucomisd %xmm3, %xmm1
jae 0xc673
ucomisd 0x40397(%rip), %xmm3    # 0x4c968
movsd 0x403af(%rip), %xmm0    # 0x4c988
jae 0xc673
movsd 0xdede9(%rip), %xmm0    # 0xeb3d0
mulsd %xmm3, %xmm0
addsd 0x4037d(%rip), %xmm0    # 0x4c970
movq %xmm0, %rax
movl %eax, %ecx
andl $0x7ff, %ecx            # imm = 0x7FF
addsd 0x40370(%rip), %xmm0    # 0x4c978
mulsd 0xdedc8(%rip), %xmm0    # 0xeb3d8
subsd %xmm3, %xmm0
shlq $0x29, %rax
movabsq $-0x10000000000000, %rdx # imm = 0xFFF0000000000000
andq %rdx, %rax
movsd 0xdad93(%rip), %xmm1    # 0xe73c0
subsd %xmm0, %xmm1
movapd %xmm0, %xmm2
mulsd %xmm0, %xmm2
mulsd %xmm1, %xmm2
mulsd 0xdad6b(%rip), %xmm2    # 0xe73b0
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
addq %rdx, %rax
subsd %xmm0, %xmm2
addsd 0xdad42(%rip), %xmm2    # 0xe73a0
leaq 0xdad3b(%rip), %rdx     # 0xe73a0
orq 0x30(%rdx,%rcx,8), %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
movq 0x40(%rsp), %rax
movq (%rax), %rax
movsd %xmm0, -0x8(%rax,%r14,8)
leal (%rbx,%r14), %eax
movq %r14, %rcx
incq %rcx
incl 0x14(%rsp)
movq %rcx, %r14
cmpl 0x62110(%rdi), %eax
jle 0xc271
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq