// File: /workspace/github_c_makefile_star2_O1/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 0xcb34
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 0xca3c
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 0xca3c
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 0xca3c
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 0xca3c
movslq 0x62110(%rbx), %rax
movq 0x62140(%rbx), %rcx
movsd (%rcx,%rax,8), %xmm0
andpd 0x42d56(%rip), %xmm0    # 0x4c9b0
movsd 0x42cd6(%rip), %xmm1    # 0x4c938
ucomisd %xmm0, %xmm1
jae 0x9c7c
leaq 0x40(%rsp), %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0xb80a
jmp 0x9c8e
leaq 0x40(%rsp), %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0xae7e
leaq 0x80(%rsp), %rsi
leaq 0x60(%rsp), %rdx
movq %rbx, %rdi
callq 0xc22c
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 0x9df1
xorl %r13d, %r13d
leaq 0xe1708(%rip), %r14     # 0xeb400
leaq 0x14(%rsp), %r15
movl 0x62118(%rbx), %ebp
leal 0x1(%r13), %r12d
movq %rbx, %rdi
movl %r12d, %esi
movl %ebp, %edx
callq 0xc6ae
movq 0x80(%rsp), %rax
movq 0x40(%rsp), %rcx
addsd 0x42c1f(%rip), %xmm0    # 0x4c948
addsd (%rax,%r13,8), %xmm0
addsd (%rcx,%r13,8), %xmm0
movsd %xmm0, 0x18(%rsp)
movq %rbx, %rdi
movl %r12d, %esi
movl %ebp, %edx
callq 0xc796
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 0xe56d2(%rip), %xmm0    # 0xef450
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 0xdc4bd(%rip), %xmm0    # 0xe6268
divsd 0x42b8d(%rip), %xmm0    # 0x4c940
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 0x9cfd
movl 0x62110(%rbx), %eax
leaq 0x10(%rsp), %rsi
movl %eax, (%rsi)
leaq 0xb8(%rsp), %rdi
movl $0x4, %edx
callq 0x32f0
movl $0x0, 0xc(%rsp)
cmpl $0x0, 0x62118(%rbx)
jle 0x9e4a
xorl %ebp, %ebp
leaq 0xb8(%rsp), %r14
leaq 0xc(%rsp), %r15
movl $0x4, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x32f0
incl %ebp
cmpl 0x62118(%rbx), %ebp
jl 0x9e30
movl 0x62118(%rbx), %r13d
cmpl 0x62110(%rbx), %r13d
jge 0x9f76
movl $0x1, %r14d
xorl %ebp, %ebp
leaq 0xe1593(%rip), %r15     # 0xeb400
leaq 0xc(%rsp), %r12
incl %r13d
movq %rbx, %rdi
movl %r14d, %esi
movl %r13d, %edx
callq 0xc6ae
movq 0x60(%rsp), %rax
movq 0x20(%rsp), %rcx
addsd 0x42ab3(%rip), %xmm0    # 0x4c948
addsd (%rax,%rbp,2), %xmm0
addsd (%rcx,%rbp,2), %xmm0
movsd %xmm0, 0x18(%rsp)
movq %rbx, %rdi
movl %r14d, %esi
movl %r13d, %edx
callq 0xc796
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 0xe5567(%rip), %xmm0    # 0xef450
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 0xdc352(%rip), %xmm0    # 0xe6268
divsd 0x42a22(%rip), %xmm0    # 0x4c940
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 0x9e72
leaq 0xb8(%rsp), %rdi
callq 0x3320
movq 0xdc036(%rip), %rax     # 0xe5fc0
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 0x9fd2
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x9fef
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xa006
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0xa01d
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0xa03a
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 0xa071
jmp 0xa052
jmp 0xa052
movq %rax, %rbx
jmp 0xa081
movq %rax, %rbx
jmp 0xa098
movq %rax, %rbx
jmp 0xa0b5
movq %rax, %rbx
jmp 0xa0cc
movq %rax, %rbx
jmp 0xa0e3
jmp 0xa071
jmp 0xa071
jmp 0xa071
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x3340
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0xa098
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0xa0b5
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xa0cc
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0xa0e3
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0xa100
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq %rbx, %rdi
callq 0x33e0