// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movl 0x62118(%rax), %eax
movl %eax, -0x1c(%rbp)
movl $0x1, -0x20(%rbp)
movq -0x60(%rbp), %rcx
movl -0x20(%rbp), %eax
addl -0x1c(%rbp), %eax
subl $0x1, %eax
cmpl 0x62110(%rcx), %eax
jg 0x1494b
movq -0x60(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movb $0x0, -0x35(%rbp)
movb $0x0, -0x36(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
movl $0x1, -0x48(%rbp)
movl -0x20(%rbp), %eax
subl 0x62114(%rcx), %eax
movl %eax, -0x4c(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x4c(%rbp), %rsi
callq 0x15060
movl (%rax), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x1480b
movl -0x20(%rbp), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x50(%rbp)
movq -0x60(%rbp), %rsi
movl -0x50(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x44(%rbp), %eax
addl 0x62114(%rsi), %eax
movl %eax, -0x54(%rbp)
addq $0x62110, %rsi          # imm = 0x62110
leaq -0x54(%rbp), %rdi
callq 0xc850
movq %rax, %rcx
movl -0x64(%rbp), %eax
cmpl (%rcx), %eax
jg 0x147fb
movq -0x60(%rbp), %rdi
addq $0x620f8, %rdi          # imm = 0x620F8
movslq -0x44(%rbp), %rsi
callq 0xbac0
movq -0x60(%rbp), %rdi
movslq (%rax), %rcx
leaq 0x68c7d(%rip), %rax     # 0x7d310
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
addq $0x620f8, %rdi          # imm = 0x620F8
movslq -0x50(%rbp), %rsi
callq 0xbac0
movq -0x60(%rbp), %rdi
movq %rax, %rcx
movq -0x70(%rbp), %rax
movslq (%rcx), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x34(%rbp)
addq $0x62218, %rdi          # imm = 0x62218
movslq -0x44(%rbp), %rsi
callq 0x150a0
movq %rax, %rdi
movl -0x50(%rbp), %eax
subl -0x44(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x150c0
movsd (%rax), %xmm0
movsd 0x2422e(%rip), %xmm1    # 0x38920
ucomisd %xmm1, %xmm0
jne 0x146ff
jp 0x146ff
jmp 0x147eb
movq -0x60(%rbp), %rdi
addq $0x62218, %rdi          # imm = 0x62218
movslq -0x44(%rbp), %rsi
callq 0x150a0
movq %rax, %rdi
movl -0x50(%rbp), %eax
subl -0x44(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x150c0
movq -0x60(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x78(%rbp)
movl -0x34(%rbp), %esi
movl -0x44(%rbp), %edx
movl -0x50(%rbp), %ecx
callq 0x12bf0
movaps %xmm0, %xmm1
movsd -0x78(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movl -0x50(%rbp), %eax
movl -0x20(%rbp), %ecx
addl -0x1c(%rbp), %ecx
cmpl %ecx, %eax
jne 0x147a1
movb -0x35(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x14787
movq -0x60(%rbp), %rdi
movsd -0x28(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
callq 0x12a20
movsd %xmm0, -0x80(%rbp)
jmp 0x14791
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movb $0x1, -0x35(%rbp)
jmp 0x147e9
movb -0x36(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x147cb
movq -0x60(%rbp), %rdi
movsd -0x30(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
callq 0x12a20
movsd %xmm0, -0x88(%rbp)
jmp 0x147d8
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0x88(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movb $0x1, -0x36(%rbp)
jmp 0x147eb
jmp 0x147ed
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x1463d
jmp 0x147fd
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x14628
movb -0x35(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x1483d
movb -0x36(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x1483d
movq -0x60(%rbp), %rdi
movsd -0x28(%rbp), %xmm0
movsd -0x30(%rbp), %xmm1
callq 0x12a20
movsd %xmm0, -0x28(%rbp)
movb -0x35(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x14865
movb -0x36(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x14865
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movb $0x1, -0x35(%rbp)
movb -0x35(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x148d0
movq -0x60(%rbp), %rax
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
movq %rax, %rdi
addq $0x62140, %rdi          # imm = 0x62140
movslq 0x62110(%rax), %rsi
callq 0x150c0
movsd -0x98(%rbp), %xmm0
subsd (%rax), %xmm0
callq 0x151d0
movsd %xmm0, -0x90(%rbp)
movq -0x10(%rbp), %rdi
movl -0x20(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x150c0
movsd -0x90(%rbp), %xmm0
movsd %xmm0, (%rax)
movb -0x36(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x1493b
movq -0x60(%rbp), %rax
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
movq %rax, %rdi
addq $0x62140, %rdi          # imm = 0x62140
movslq 0x62110(%rax), %rsi
callq 0x150c0
movsd -0xa8(%rbp), %xmm0
subsd (%rax), %xmm0
callq 0x151d0
movsd %xmm0, -0xa0(%rbp)
movq -0x18(%rbp), %rdi
movl -0x20(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x150c0
movsd -0xa0(%rbp), %xmm0
movsd %xmm0, (%rax)
jmp 0x1493d
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x145bf
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)