// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x370, %rsp            # imm = 0x370
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x300(%rbp)
movq $0x0, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
leaq -0x38(%rbp), %rdi
movq %rdi, -0x2f8(%rbp)
callq 0x155c0
movq -0x300(%rbp), %rax
movq -0x2f8(%rbp), %rdi
movslq 0x62110(%rax), %rsi
movl $0x0, -0x3c(%rbp)
leaq -0x3c(%rbp), %rdx
callq 0x155e0
jmp 0x113e4
leaq -0x68(%rbp), %rdi
movq %rdi, -0x308(%rbp)
callq 0xbef0
movq -0x300(%rbp), %rax
movq -0x308(%rbp), %rdi
movslq 0x62110(%rax), %rsi
movq $0x0, -0x70(%rbp)
leaq -0x70(%rbp), %rdx
callq 0x14e80
jmp 0x1141c
leaq -0x88(%rbp), %rdi
movq %rdi, -0x310(%rbp)
callq 0xbef0
movq -0x300(%rbp), %rax
movq -0x310(%rbp), %rdi
movslq 0x62110(%rax), %rsi
movq $0x0, -0x90(%rbp)
leaq -0x90(%rbp), %rdx
callq 0x14e80
jmp 0x1145d
leaq -0xa8(%rbp), %rdi
movq %rdi, -0x318(%rbp)
callq 0xbef0
movq -0x300(%rbp), %rax
movq -0x318(%rbp), %rdi
movslq 0x62110(%rax), %rsi
movq $0x0, -0xb0(%rbp)
leaq -0xb0(%rbp), %rdx
callq 0x14e80
jmp 0x1149e
leaq -0xc8(%rbp), %rdi
movq %rdi, -0x320(%rbp)
callq 0xbef0
movq -0x300(%rbp), %rax
movq -0x320(%rbp), %rdi
movslq 0x62110(%rax), %rsi
movq $0x0, -0xd0(%rbp)
leaq -0xd0(%rbp), %rdx
callq 0x14e80
jmp 0x114df
movq -0x300(%rbp), %rax
movq %rax, %rdi
addq $0x62140, %rdi          # imm = 0x62140
movslq 0x62110(%rax), %rsi
callq 0x150c0
movsd (%rax), %xmm0
movsd %xmm0, -0xd8(%rbp)
movsd -0xd8(%rbp), %xmm0
movsd 0x27410(%rip), %xmm1    # 0x38928
ucomisd %xmm1, %xmm0
jb 0x115a4
movsd 0x27406(%rip), %xmm0    # 0x38930
ucomisd -0xd8(%rbp), %xmm0
jb 0x115a4
movq -0x300(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x88(%rbp), %rdx
callq 0x12d60
jmp 0x1154d
jmp 0x115bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x11aba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x11ab1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x11aa5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x11a99
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x11a8d
movq -0x300(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x88(%rbp), %rdx
callq 0x136b0
jmp 0x115bd
jmp 0x115bf
movq -0x300(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
leaq -0xc8(%rbp), %rdx
callq 0x14590
jmp 0x115db
movq -0x300(%rbp), %rdi
addq $0x62120, %rdi          # imm = 0x62120
callq 0x3110
movq %rax, -0x330(%rbp)
movl $0x10, %edi
movl $0x4, %esi
callq 0xbcf0
movl %eax, -0x324(%rbp)
jmp 0x1160c
movl -0x324(%rbp), %edi
movl $0x1, %esi
callq 0xbcf0
movl %eax, -0x334(%rbp)
jmp 0x11624
movl -0x334(%rbp), %edx
movq -0x330(%rbp), %rsi
leaq -0x2d8(%rbp), %rdi
callq 0x32e0
jmp 0x1163f
movq -0x300(%rbp), %rcx
movl 0x62110(%rcx), %eax
movl 0x62118(%rcx), %ecx
subl %ecx, %eax
incl %eax
movl %eax, -0x2dc(%rbp)
leaq -0x2d8(%rbp), %rdi
leaq -0x2dc(%rbp), %rsi
movl $0x4, %edx
callq 0x33a0
jmp 0x11676
movl $0x1, -0x2e0(%rbp)
movl -0x2e0(%rbp), %eax
cmpl -0x2dc(%rbp), %eax
jg 0x11813
movq -0x300(%rbp), %rdi
movl -0x2e0(%rbp), %esi
movl 0x62118(%rdi), %edx
callq 0x14960
movsd %xmm0, -0x340(%rbp)
jmp 0x116b4
movsd -0x340(%rbp), %xmm1
movsd -0x18(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movl -0x2e0(%rbp), %eax
decl %eax
movslq %eax, %rsi
leaq -0xa8(%rbp), %rdi
callq 0x150c0
movsd (%rax), %xmm1
movsd -0x18(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movl -0x2e0(%rbp), %eax
decl %eax
movslq %eax, %rsi
leaq -0x68(%rbp), %rdi
callq 0x150c0
movq -0x300(%rbp), %rdi
movsd (%rax), %xmm1
movsd -0x18(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movl -0x2e0(%rbp), %esi
movl 0x62118(%rdi), %edx
callq 0x14a00
movsd %xmm0, -0x348(%rbp)
jmp 0x1173b
movsd -0x348(%rbp), %xmm1
movsd -0x18(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movsd -0x18(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x150e0
movss %xmm0, -0x34c(%rbp)
jmp 0x11769
movss -0x34c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0xfe78b(%rip), %xmm1    # 0x10ff08
mulsd %xmm1, %xmm0
movsd 0x271af(%rip), %xmm1    # 0x38938
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x1c(%rbp)
movss -0x1c(%rbp), %xmm0
movss %xmm0, -0x350(%rbp)
movl -0x2e0(%rbp), %eax
decl %eax
movslq %eax, %rsi
leaq -0x38(%rbp), %rdi
callq 0x15690
movss -0x350(%rbp), %xmm0
movss %xmm0, (%rax)
leaq -0x2d8(%rbp), %rdi
leaq -0x1c(%rbp), %rsi
movl $0x4, %edx
callq 0x33a0
jmp 0x117da
xorps %xmm0, %xmm0
movsd %xmm0, -0x18(%rbp)
movl -0x2e0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2e0(%rbp)
jmp 0x11680
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x2d8(%rbp), %rdi
callq 0x3410
jmp 0x11a8d
movq -0x300(%rbp), %rax
movl 0x62110(%rax), %eax
movl %eax, -0x2dc(%rbp)
leaq -0x2d8(%rbp), %rdi
leaq -0x2dc(%rbp), %rsi
movl $0x4, %edx
callq 0x33a0
jmp 0x11840
xorps %xmm0, %xmm0
movss %xmm0, -0x2e4(%rbp)
movl $0x0, -0x2e8(%rbp)
movq -0x300(%rbp), %rcx
movl -0x2e8(%rbp), %eax
cmpl 0x62118(%rcx), %eax
jge 0x11897
leaq -0x2d8(%rbp), %rdi
leaq -0x2e4(%rbp), %rsi
movl $0x4, %edx
callq 0x33a0
jmp 0x11884
jmp 0x11886
movl -0x2e8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2e8(%rbp)
jmp 0x11855
movl $0x1, -0x2ec(%rbp)
movq -0x300(%rbp), %rcx
movl -0x2ec(%rbp), %eax
addl 0x62118(%rcx), %eax
cmpl 0x62110(%rcx), %eax
jg 0x11a34
movq -0x300(%rbp), %rdi
movl -0x2ec(%rbp), %esi
movl 0x62118(%rdi), %edx
incl %edx
callq 0x14960
movsd %xmm0, -0x358(%rbp)
jmp 0x118e4
movsd -0x358(%rbp), %xmm1
movsd -0x18(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movl -0x2ec(%rbp), %eax
decl %eax
movslq %eax, %rsi
leaq -0xc8(%rbp), %rdi
callq 0x150c0
movsd (%rax), %xmm1
movsd -0x18(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movl -0x2ec(%rbp), %eax
decl %eax
movslq %eax, %rsi
leaq -0x88(%rbp), %rdi
callq 0x150c0
movq -0x300(%rbp), %rdi
movsd (%rax), %xmm1
movsd -0x18(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movl -0x2ec(%rbp), %esi
movl 0x62118(%rdi), %edx
incl %edx
callq 0x14a00
movsd %xmm0, -0x360(%rbp)
jmp 0x11970
movsd -0x360(%rbp), %xmm1
movsd -0x18(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movsd -0x18(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x150e0
movss %xmm0, -0x364(%rbp)
jmp 0x1199e
movss -0x364(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0xfe556(%rip), %xmm1    # 0x10ff08
mulsd %xmm1, %xmm0
movsd 0x26f7a(%rip), %xmm1    # 0x38938
divsd %xmm1, %xmm0
movsd %xmm0, -0x370(%rbp)
movl -0x2ec(%rbp), %eax
decl %eax
movslq %eax, %rsi
leaq -0x38(%rbp), %rdi
callq 0x15690
movsd -0x370(%rbp), %xmm0
movss (%rax), %xmm1
cvtss2sd %xmm1, %xmm1
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x2e4(%rbp)
leaq -0x2d8(%rbp), %rdi
leaq -0x2e4(%rbp), %rsi
movl $0x4, %edx
callq 0x33a0
jmp 0x11a18
xorps %xmm0, %xmm0
movsd %xmm0, -0x18(%rbp)
movl -0x2ec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2ec(%rbp)
jmp 0x118a1
leaq -0x2d8(%rbp), %rdi
callq 0x33f0
jmp 0x11a42
leaq -0x2d8(%rbp), %rdi
callq 0x3410
leaq -0xc8(%rbp), %rdi
callq 0xc690
leaq -0xa8(%rbp), %rdi
callq 0xc690
leaq -0x88(%rbp), %rdi
callq 0xc690
leaq -0x68(%rbp), %rdi
callq 0xc690
leaq -0x38(%rbp), %rdi
callq 0x7a50
addq $0x370, %rsp            # imm = 0x370
popq %rbp
retq
leaq -0xc8(%rbp), %rdi
callq 0xc690
leaq -0xa8(%rbp), %rdi
callq 0xc690
leaq -0x88(%rbp), %rdi
callq 0xc690
leaq -0x68(%rbp), %rdi
callq 0xc690
leaq -0x38(%rbp), %rdi
callq 0x7a50
movq -0x48(%rbp), %rdi
callq 0x34d0
nopl (%rax)