// File: /workspace/github_c_makefile_star2_O3/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 0x62110(%rdi), %r8d
movl 0x62118(%rdi), %esi
cmpl %r8d, %esi
jg 0xd6b8
movl 0x62114(%rdi), %r9d
leal 0x1(%rsi), %eax
movl %eax, 0x14(%rsp)
movl $0x1, %ebx
movl %esi, 0x2c(%rsp)
movq %rdi, 0x20(%rsp)
movq %rsi, 0x30(%rsp)
incl 0x2c(%rsp)
movl %ebx, %edx
subl %r9d, %edx
cmpl $0x2, %edx
movl $0x1, %r12d
cmovgel %edx, %r12d
cmpq %r12, %rbx
jbe 0xd69f
movl 0x14(%rsp), %eax
movslq %eax, %rcx
decq %rcx
movq %rcx, 0x48(%rsp)
cmpl $0x2, %edx
movl $0x1, %ecx
cmovll %ecx, %edx
notl %edx
addl %eax, %edx
shlq $0x20, %rdx
xorpd %xmm1, %xmm1
movl $0x0, 0x4(%rsp)
xorl %r10d, %r10d
xorpd %xmm0, %xmm0
movsd %xmm0, 0x18(%rsp)
movq %rbx, 0x50(%rsp)
leal (%r9,%r12), %eax
cmpl %eax, %r8d
cmovll %r8d, %eax
cmpl %eax, 0x2c(%rsp)
movq %rdx, 0x58(%rsp)
jg 0xd421
movl 0x14(%rsp), %ebp
movq 0x48(%rsp), %r15
xorl %r13d, %r13d
movq %rdx, %rbx
movl %r10d, %r14d
movq 0x62218(%rdi), %rax
leaq (%r12,%r12,2), %rcx
movq (%rax,%rcx,8), %rax
movq %rbx, %rcx
sarq $0x1d, %rcx
movsd (%rax,%rcx), %xmm0
ucomisd 0x406d1(%rip), %xmm0    # 0x4da10
jne 0xd343
jnp 0xd3b0
movsd %xmm1, 0x8(%rsp)
movq 0x620f8(%rdi), %rax
movslq (%rax,%r12,4), %rcx
movslq 0x4(%rax,%r15,4), %rax
leaq (%rcx,%rcx,4), %rcx
leaq 0x4083c(%rip), %rdx     # 0x4dba0
leaq (%rdx,%rcx,4), %rcx
movl (%rcx,%rax,4), %esi
movl %r12d, %edx
movl %ebp, %ecx
movsd %xmm0, 0x60(%rsp)
callq 0xbe68
movsd 0x60(%rsp), %xmm1
addsd %xmm0, %xmm1
testq %r13, %r13
je 0xd3b5
testb $0x1, 0x4(%rsp)
movsd 0x8(%rsp), %xmm0
je 0xd3a0
callq 0xbc7e
movapd %xmm0, %xmm1
movl %r14d, %r10d
movb $0x1, %al
movl %eax, 0x4(%rsp)
movq 0x20(%rsp), %rdi
jmp 0xd3e5
movl %r14d, %r10d
jmp 0xd3e5
movb $0x1, %r10b
testb $0x1, %r14b
je 0xd3d4
movsd 0x18(%rsp), %xmm0
callq 0xbc7e
movb $0x1, %r10b
movsd %xmm0, 0x18(%rsp)
jmp 0xd3da
movsd %xmm1, 0x18(%rsp)
movq 0x20(%rsp), %rdi
movsd 0x8(%rsp), %xmm1
movl 0x62110(%rdi), %r8d
movl 0x62114(%rdi), %r9d
leal (%r9,%r12), %eax
cmpl %eax, %r8d
cmovll %r8d, %eax
cltq
movabsq $0x100000000, %rcx      # imm = 0x100000000
addq %rcx, %rbx
decq %r13
incq %r15
incl %ebp
movl %r10d, %r14d
cmpq %rax, %r15
jl 0xd31c
incq %r12
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
movq 0x58(%rsp), %rdx
addq %rax, %rdx
movq 0x50(%rsp), %rbx
cmpq %rbx, %r12
jb 0xd2f0
movl %r10d, %eax
movl 0x4(%rsp), %ecx
andb %cl, %al
testb $0x1, %al
je 0xd485
movsd 0x18(%rsp), %xmm0
movsd %xmm1, 0x8(%rsp)
movq %r9, %r14
movl %r8d, %ebp
movl %r10d, %r15d
callq 0xbc7e
movl %r15d, %r10d
movl %ebp, %r8d
movq %r14, %r9
movq 0x20(%rsp), %rdi
movsd %xmm0, 0x18(%rsp)
movb $0x1, %cl
movb $0x1, %al
jmp 0xd495
movsd %xmm1, 0x8(%rsp)
movl %r10d, %eax
xorb $0x1, %al
andb %cl, %al
movl %r10d, %ecx
movq 0x30(%rsp), %rsi
testb $0x1, %r10b
sete %dl
andb %al, %dl
orb %dl, %cl
testb $0x1, %cl
je 0xd5af
movsd 0x8(%rsp), %xmm3
movapd %xmm3, %xmm0
testb %dl, %dl
jne 0xd4c2
movsd 0x18(%rsp), %xmm0
movslq %r8d, %rcx
movq 0x62140(%rdi), %rdx
subsd (%rdx,%rcx,8), %xmm0
xorpd %xmm1, %xmm1
movsd 0x40563(%rip), %xmm2    # 0x4da40
ucomisd %xmm0, %xmm2
jae 0xd591
ucomisd 0x40559(%rip), %xmm0    # 0x4da48
movsd 0x40571(%rip), %xmm1    # 0x4da68
jae 0xd591
movsd 0xdeecb(%rip), %xmm1    # 0xec3d0
mulsd %xmm0, %xmm1
addsd 0x4053f(%rip), %xmm1    # 0x4da50
movq %xmm1, %rcx
movl %ecx, %edx
andl $0x7ff, %edx            # imm = 0x7FF
addsd 0x40532(%rip), %xmm1    # 0x4da58
mulsd 0xdeeaa(%rip), %xmm1    # 0xec3d8
subsd %xmm0, %xmm1
shlq $0x29, %rcx
movabsq $-0x10000000000000, %r8 # imm = 0xFFF0000000000000
andq %r8, %rcx
movsd 0xdae75(%rip), %xmm0    # 0xe83c0
subsd %xmm1, %xmm0
movapd %xmm1, %xmm2
mulsd %xmm1, %xmm2
mulsd %xmm0, %xmm2
mulsd 0xdae4d(%rip), %xmm2    # 0xe83b0
movabsq $0x3ff0000000000000, %r8 # imm = 0x3FF0000000000000
addq %r8, %rcx
subsd %xmm1, %xmm2
addsd 0xdae24(%rip), %xmm2    # 0xe83a0
leaq 0xdae1d(%rip), %r8      # 0xe83a0
orq 0x30(%r8,%rdx,8), %rcx
movq %rcx, %xmm1
mulsd %xmm2, %xmm1
movq 0x38(%rsp), %rcx
movq (%rcx), %rcx
movsd %xmm1, -0x8(%rcx,%rbx,8)
movl 0x62110(%rdi), %r8d
testb $0x1, %al
jne 0xd5c2
jmp 0xd69f
andb %al, %r10b
testb $0x1, %r10b
movsd 0x8(%rsp), %xmm3
je 0xd69f
movslq %r8d, %rax
movq 0x62140(%rdi), %rcx
subsd (%rcx,%rax,8), %xmm3
xorpd %xmm0, %xmm0
movsd 0x40463(%rip), %xmm1    # 0x4da40
ucomisd %xmm3, %xmm1
jae 0xd691
ucomisd 0x40459(%rip), %xmm3    # 0x4da48
movsd 0x40471(%rip), %xmm0    # 0x4da68
jae 0xd691
movsd 0xdedcb(%rip), %xmm0    # 0xec3d0
mulsd %xmm3, %xmm0
addsd 0x4043f(%rip), %xmm0    # 0x4da50
movq %xmm0, %rax
movl %eax, %ecx
andl $0x7ff, %ecx            # imm = 0x7FF
addsd 0x40432(%rip), %xmm0    # 0x4da58
mulsd 0xdedaa(%rip), %xmm0    # 0xec3d8
subsd %xmm3, %xmm0
shlq $0x29, %rax
movabsq $-0x10000000000000, %rdx # imm = 0xFFF0000000000000
andq %rdx, %rax
movsd 0xdad75(%rip), %xmm1    # 0xe83c0
subsd %xmm0, %xmm1
movapd %xmm0, %xmm2
mulsd %xmm0, %xmm2
mulsd %xmm1, %xmm2
mulsd 0xdad4d(%rip), %xmm2    # 0xe83b0
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
addq %rdx, %rax
subsd %xmm0, %xmm2
addsd 0xdad24(%rip), %xmm2    # 0xe83a0
leaq 0xdad1d(%rip), %rdx     # 0xe83a0
orq 0x30(%rdx,%rcx,8), %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
movq 0x40(%rsp), %rax
movq (%rax), %rax
movsd %xmm0, -0x8(%rax,%rbx,8)
leal (%rsi,%rbx), %eax
movq %rbx, %rcx
incq %rcx
incl 0x14(%rsp)
movq %rcx, %rbx
cmpl %r8d, %eax
jle 0xd291
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop