// File: /workspace/github_c_makefile_star2_O3/fukunagatsu[P]RIblast/raccess.cpp
// Function: Raccess::CalcAccessibility(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
void Raccess::CalcAccessibility(string &sequence){
  double prob = 0.0;
  float accessibility = 0.0;
  vector<float> accessibility_array; accessibility_array.resize(_seq_length, 0.0);

  vector<double> biloop_probability; biloop_probability.resize(_seq_length, 0.0);
  vector<double> conditional_biloop_probability; conditional_biloop_probability.resize(_seq_length, 0.0);
  vector<double> hairpin_probability; hairpin_probability.resize(_seq_length, 0.0);
  vector<double> conditional_hairpin_probability; conditional_hairpin_probability.resize(_seq_length, 0.0);

  double pf = _Alpha_outer[_seq_length];
  if(pf >= -690 && pf <= 690){
    CalcBulgeAndInternalProbability(biloop_probability, conditional_biloop_probability);
  }else{
    CalcLogSumBulgeAndInternalProbability(biloop_probability, conditional_biloop_probability);
  }
  
  CalcHairpinProbability(hairpin_probability, conditional_hairpin_probability);
  
  ofstream of(_db_name.c_str(), ios::out | ios::binary | ios::app);
  int count = _seq_length - _min_accessible_length + 1;
  of.write(reinterpret_cast<const char*>(&count), sizeof(int));
  for(int i = 1; i <=count;i++){
    prob += CalcExteriorProbability(i,_min_accessible_length);
    prob += hairpin_probability[i-1];
    prob += biloop_probability[i-1];
    prob += CalcMultiProbability(i,_min_accessible_length);
    accessibility = (-fmath::log((float)prob)*kT)/1000;
    accessibility_array[i-1] = accessibility;
    of.write(reinterpret_cast<const char*>(&accessibility), sizeof(float));
    prob = 0.0;
  }
 
  count = _seq_length;
  of.write(reinterpret_cast<const char*>(&count), sizeof(int));
  float conditional_accessibility = 0.0;
  for(int i = 0; i < _min_accessible_length; i++){
    of.write(reinterpret_cast<const char*>(&conditional_accessibility), sizeof(float));
  }
  
  for(int i = 1; i+_min_accessible_length <=_seq_length;i++){
    prob += CalcExteriorProbability(i,_min_accessible_length+1);
    prob += conditional_hairpin_probability[i-1];
    prob += conditional_biloop_probability[i-1];
    prob += CalcMultiProbability(i,_min_accessible_length+1);
    conditional_accessibility = (-fmath::log((float)prob)*kT)/1000 - accessibility_array[i-1];
    of.write(reinterpret_cast<const char*>(&conditional_accessibility), sizeof(float));
    prob = 0.0;
  }
  of.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2b8, %rsp            # imm = 0x2B8
movq %rdi, %rbx
xorl %eax, %eax
movl %eax, 0x14(%rsp)
xorpd %xmm0, %xmm0
leaq 0xa0(%rsp), %rdi
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movslq 0x62110(%rbx), %rsi
leaq 0xb8(%rsp), %rdx
movl %eax, (%rdx)
callq 0xdbee
xorl %eax, %eax
leaq 0x40(%rsp), %rdi
movq %rax, 0x10(%rdi)
xorpd %xmm0, %xmm0
movapd %xmm0, (%rdi)
movslq 0x62110(%rbx), %rsi
leaq 0xb8(%rsp), %rdx
movq %rax, (%rdx)
callq 0xda56
xorl %eax, %eax
leaq 0x20(%rsp), %rdi
movq %rax, 0x10(%rdi)
xorpd %xmm0, %xmm0
movapd %xmm0, (%rdi)
movslq 0x62110(%rbx), %rsi
leaq 0xb8(%rsp), %rdx
movq %rax, (%rdx)
callq 0xda56
xorl %eax, %eax
leaq 0x80(%rsp), %rdi
movq %rax, 0x10(%rdi)
xorpd %xmm0, %xmm0
movapd %xmm0, (%rdi)
movslq 0x62110(%rbx), %rsi
leaq 0xb8(%rsp), %rdx
movq %rax, (%rdx)
callq 0xda56
xorl %eax, %eax
leaq 0x60(%rsp), %rdi
movq %rax, 0x10(%rdi)
xorpd %xmm0, %xmm0
movapd %xmm0, (%rdi)
movslq 0x62110(%rbx), %rsi
leaq 0xb8(%rsp), %rdx
movq %rax, (%rdx)
callq 0xda56
movslq 0x62110(%rbx), %rax
movq 0x62140(%rbx), %rcx
movsd (%rcx,%rax,8), %xmm0
andpd 0x42d5e(%rip), %xmm0    # 0x4da90
movsd 0x42cde(%rip), %xmm1    # 0x4da18
ucomisd %xmm0, %xmm1
jae 0xad54
leaq 0x40(%rsp), %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0xc800
jmp 0xad66
leaq 0x40(%rsp), %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0xbf22
leaq 0x80(%rsp), %rsi
leaq 0x60(%rsp), %rdx
movq %rbx, %rdi
callq 0xd242
movq 0x62120(%rbx), %rsi
leaq 0xb8(%rsp), %rdi
movl $0x15, %edx
callq 0x3250
movl 0x62110(%rbx), %eax
subl 0x62118(%rbx), %eax
incl %eax
leaq 0x10(%rsp), %rsi
movl %eax, (%rsi)
leaq 0xb8(%rsp), %rdi
movl $0x4, %edx
callq 0x32f0
cmpl $0x0, 0x10(%rsp)
jle 0xaec9
xorl %r13d, %r13d
leaq 0xe1630(%rip), %r14     # 0xec400
leaq 0x14(%rsp), %r15
movl 0x62118(%rbx), %ebp
leal 0x1(%r13), %r12d
movq %rbx, %rdi
movl %r12d, %esi
movl %ebp, %edx
callq 0xd6c8
movq 0x80(%rsp), %rax
movq 0x40(%rsp), %rcx
addsd 0x42c27(%rip), %xmm0    # 0x4da28
addsd (%rax,%r13,8), %xmm0
addsd (%rcx,%r13,8), %xmm0
movsd %xmm0, 0x18(%rsp)
movq %rbx, %rdi
movl %r12d, %esi
movl %ebp, %edx
callq 0xd7b0
addsd 0x18(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movd %xmm0, %eax
movl %eax, %ecx
andl $0x7f800000, %ecx       # imm = 0x7F800000
movl %eax, %edx
addl $0xc0800000, %ecx       # imm = 0xC0800000
xorps %xmm0, %xmm0
cvtsi2ss %ecx, %xmm0
andl $0xfff, %edx            # imm = 0xFFF
shrl $0x9, %eax
mulss 0xe55fa(%rip), %xmm0    # 0xf0450
andl $0x3ff8, %eax           # imm = 0x3FF8
xorps %xmm1, %xmm1
cvtsi2ss %edx, %xmm1
addss 0x50(%rax,%r14), %xmm0
mulss 0x54(%rax,%r14), %xmm1
addss %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
mulsd 0xdc3e5(%rip), %xmm0    # 0xe7268
divsd 0x42b95(%rip), %xmm0    # 0x4da20
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x14(%rsp)
movq 0xa0(%rsp), %rax
movss %xmm0, (%rax,%r13,4)
movl $0x4, %edx
leaq 0xb8(%rsp), %rdi
movq %r15, %rsi
callq 0x32f0
movslq 0x10(%rsp), %rax
incq %r13
cmpq %rax, %r13
jl 0xadd5
movl 0x62110(%rbx), %eax
leaq 0x10(%rsp), %rsi
movl %eax, (%rsi)
leaq 0xb8(%rsp), %rdi
movl $0x4, %edx
callq 0x32f0
movl $0x0, 0xc(%rsp)
movl 0x62118(%rbx), %r13d
testl %r13d, %r13d
jle 0xaf29
xorl %ebp, %ebp
leaq 0xb8(%rsp), %r14
leaq 0xc(%rsp), %r15
movl $0x4, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x32f0
incl %ebp
movl 0x62118(%rbx), %r13d
cmpl %r13d, %ebp
jl 0xaf0b
cmpl 0x62110(%rbx), %r13d
jge 0xb04e
movl $0x1, %r14d
xorl %ebp, %ebp
leaq 0xe14bb(%rip), %r15     # 0xec400
leaq 0xc(%rsp), %r12
incl %r13d
movq %rbx, %rdi
movl %r14d, %esi
movl %r13d, %edx
callq 0xd6c8
movq 0x60(%rsp), %rax
movq 0x20(%rsp), %rcx
addsd 0x42abb(%rip), %xmm0    # 0x4da28
addsd (%rax,%rbp,2), %xmm0
addsd (%rcx,%rbp,2), %xmm0
movsd %xmm0, 0x18(%rsp)
movq %rbx, %rdi
movl %r14d, %esi
movl %r13d, %edx
callq 0xd7b0
addsd 0x18(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movd %xmm0, %eax
movl %eax, %ecx
andl $0x7f800000, %ecx       # imm = 0x7F800000
movl %eax, %edx
addl $0xc0800000, %ecx       # imm = 0xC0800000
xorps %xmm0, %xmm0
cvtsi2ss %ecx, %xmm0
andl $0xfff, %edx            # imm = 0xFFF
shrl $0x9, %eax
mulss 0xe548f(%rip), %xmm0    # 0xf0450
andl $0x3ff8, %eax           # imm = 0x3FF8
xorps %xmm1, %xmm1
cvtsi2ss %edx, %xmm1
addss 0x50(%rax,%r15), %xmm0
mulss 0x54(%rax,%r15), %xmm1
addss %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
mulsd 0xdc27a(%rip), %xmm0    # 0xe7268
divsd 0x42a2a(%rip), %xmm0    # 0x4da20
movq 0xa0(%rsp), %rax
xorps %xmm1, %xmm1
cvtss2sd (%rax,%rbp), %xmm1
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xc(%rsp)
movl $0x4, %edx
leaq 0xb8(%rsp), %rdi
movq %r12, %rsi
callq 0x32f0
movl 0x62118(%rbx), %r13d
addq $0x4, %rbp
leal (%r14,%r13), %eax
incl %eax
movl %r14d, %ecx
incl %ecx
movl %ecx, %r14d
cmpl 0x62110(%rbx), %eax
jle 0xaf4a
leaq 0xb8(%rsp), %rdi
callq 0x3320
movq 0xdbf5e(%rip), %rax     # 0xe6fc0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0xc0(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0xb8(%rsp,%rcx)
callq 0x31d0
leaq 0x1b0(%rsp), %rdi
callq 0x30d0
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0xb0aa
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0xb0c7
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xb0de
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0xb0f5
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0xb112
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xb149
jmp 0xb12a
jmp 0xb12a
movq %rax, %rbx
jmp 0xb159
movq %rax, %rbx
jmp 0xb170
movq %rax, %rbx
jmp 0xb18d
movq %rax, %rbx
jmp 0xb1a4
movq %rax, %rbx
jmp 0xb1bb
jmp 0xb149
jmp 0xb149
jmp 0xb149
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x3340
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0xb170
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0xb18d
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xb1a4
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0xb1bb
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0xb1d8
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq %rbx, %rdi
callq 0x33e0