// File: /workspace/github_c_makefile_star2_O1/fukunagatsu[P]RIblast/rna_interaction_search.cpp
// Function: RnaInteractionSearch::Output(RnaInteractionSearchParameters, std::vector<Hit, std::allocator<Hit>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, int*, int)
void RnaInteractionSearch::Output(const RnaInteractionSearchParameters parameters, vector<Hit> &hit_result, string q_name, int flag,int *count,int q_length){
  ofstream ofs;
  if(flag==0){
    ofs.open(parameters.GetOutputFilename().c_str(),ios::out);
    ofs << "RIblast ris result"<< endl;
    ofs << "input:" <<parameters.GetInputFilename() <<",database:" <<parameters.GetDbFilename()<<",RepeatFlag:" <<parameters.GetRepeatFlag()<<",MaximalSpan:" << parameters.GetMaximalSpan() <<",MinAccessibleLength:" << parameters.GetMinAccessibleLength() << ",MaxSeedLength:"<< parameters.GetMaxSeedLength() << ",InteractionEnergyThreshold:" << parameters.GetInteractionEnergyThreshold() << ",HybridEnergyThreshold:" << parameters.GetHybridEnergyThreshold() << ",FinalThreshold:" << parameters.GetFinalThreshold() << ",DropOutLengthWoGap:" << parameters.GetDropOutLengthWoGap() << ",DropOutLengthWGap:" << parameters.GetDropOutLengthWGap() << endl;
  }else{
    ofs.open(parameters.GetOutputFilename().c_str(),ios::app);
  }
  if (!ofs){
    cout << "Error: can't open output_file:"+parameters.GetOutputFilename()+"." <<endl;
    exit(1);
  }
  if(flag==0){
    ofs << "Id,Query name, Query Length, Target name, Target Length, Accessibility Energy, Hybridization Energy, Interaction Energy, BasePair"<< endl;
  }
  int output_style = parameters.GetOutputStyle();
  
  for(int i = 0; i< hit_result.size(); i++){
    ofs << *count << ",";
    *count += 1;
    int id = hit_result[i].GetDbSeqId();
    int db_length = _db_seq_length_without_repeat[id];
    int seq_start_position = _db_seq_start_position[id];
    ofs << q_name << ",";
    ofs << q_length << ",";
    ofs << _db_seq_name[id] << ",";
    ofs << db_length << ",";
    ofs << hit_result[i].GetAccessibilityEnergy() << ",";
    ofs << hit_result[i].GetHybridizationEnergy() << ",";
    ofs << hit_result[i].GetEnergy() << ",";
    db_length = _db_seq_length[id];
    int basepair_length = hit_result[i].GetBasePairLength();
    if(output_style==1){
      for(int j = 0; j<basepair_length;j++){
	int dbpos = (db_length-1) - ( hit_result[i].GetBasePairSecond(j)- seq_start_position);
	ofs << "(" << hit_result[i].GetBasePairFirst(j) << ":" << dbpos << ") " ;
      }
    }else{
      ofs << "(" << hit_result[i].GetBasePairFirst(0) << "-" << hit_result[i].GetBasePairFirst(basepair_length-1) << ":" ;
      int dbpos1 = (db_length-1) - ( hit_result[i].GetBasePairSecond(0)- seq_start_position);
      int dbpos2 = (db_length-1) - ( hit_result[i].GetBasePairSecond(basepair_length-1)- seq_start_position);
      ofs << dbpos1 << "-" << dbpos2 << ") " ;
    }
    ofs << endl;
  }
  ofs.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movq %r9, %r15
movl %r8d, %ebp
movq %rcx, 0x68(%rsp)
movq %rdx, 0x8(%rsp)
movq %rsi, %r13
movq %rdi, 0x60(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x33c0
leaq 0x20(%rsp), %r14
leaq 0x10(%rsp), %rdi
testl %ebp, %ebp
je 0xff1b
movq %r14, (%rdi)
movq 0x40(%r13), %rsi
movq 0x48(%r13), %rdx
addq %rsi, %rdx
callq 0x46f2
movq 0x10(%rsp), %rsi
leaq 0x98(%rsp), %rdi
movl $0x1, %edx
callq 0x3040
jmp 0x101c7
movq %r14, (%rdi)
movq 0x40(%r13), %rsi
movq 0x48(%r13), %rdx
addq %rsi, %rdx
callq 0x46f2
movq 0x10(%rsp), %rsi
leaq 0x98(%rsp), %rdi
movl $0x10, %edx
callq 0x3040
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0xff5c
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3230
leaq 0x3cba5(%rip), %rsi     # 0x4cb08
leaq 0x98(%rsp), %rbx
movl $0x12, %edx
movq %rbx, %rdi
callq 0x3280
movq 0x98(%rsp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x3200
movsbl %al, %esi
leaq 0x98(%rsp), %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3180
leaq 0x3cb6b(%rip), %rsi     # 0x4cb1b
leaq 0x98(%rsp), %rdi
movl $0x6, %edx
callq 0x3280
leaq 0x10(%rsp), %rdi
movq %r14, (%rdi)
movq 0x20(%r13), %rsi
movq 0x28(%r13), %rdx
addq %rsi, %rdx
callq 0x46f2
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
leaq 0x98(%rsp), %rdi
callq 0x3280
movq %rax, %rbx
leaq 0x3cb27(%rip), %rsi     # 0x4cb22
movl $0xa, %edx
movq %rax, %rdi
callq 0x3280
leaq 0x48(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%r13), %rsi
movq 0x8(%r13), %rdx
addq %rsi, %rdx
leaq 0x38(%rsp), %rdi
callq 0x46f2
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq %rbx, %rdi
callq 0x3280
movq %rax, %rbx
leaq 0x3caea(%rip), %rsi     # 0x4cb2d
movl $0xc, %edx
movq %rax, %rdi
callq 0x3280
movl 0x68(%r13), %esi
movq %rbx, %rdi
callq 0x33d0
movq %rax, %rbx
leaq 0x3cad4(%rip), %rsi     # 0x4cb3a
movl $0xd, %edx
movq %rax, %rdi
callq 0x3280
movl 0x6c(%r13), %esi
movq %rbx, %rdi
callq 0x33d0
movq %rax, %rbx
leaq 0x3cabf(%rip), %rsi     # 0x4cb48
movl $0x15, %edx
movq %rax, %rdi
callq 0x3280
movl 0x70(%r13), %esi
movq %rbx, %rdi
callq 0x33d0
movq %rax, %rbx
leaq 0x3cab2(%rip), %rsi     # 0x4cb5e
movl $0xf, %edx
movq %rax, %rdi
callq 0x3280
movl 0x74(%r13), %esi
movq %rbx, %rdi
callq 0x33d0
movq %rax, %rbx
leaq 0x3ca9f(%rip), %rsi     # 0x4cb6e
movl $0x1c, %edx
movq %rax, %rdi
callq 0x3280
movsd 0x78(%r13), %xmm0
movq %rbx, %rdi
callq 0x3390
movq %rax, %rbx
leaq 0x3ca97(%rip), %rsi     # 0x4cb8b
movl $0x17, %edx
movq %rax, %rdi
callq 0x3280
movsd 0x80(%r13), %xmm0
movq %rbx, %rdi
callq 0x3390
movq %rax, %rbx
leaq 0x3ca87(%rip), %rsi     # 0x4cba3
movl $0x10, %edx
movq %rax, %rdi
callq 0x3280
movsd 0x88(%r13), %xmm0
movq %rbx, %rdi
callq 0x3390
movq %rax, %rbx
leaq 0x3ca70(%rip), %rsi     # 0x4cbb4
movl $0x14, %edx
movq %rax, %rdi
callq 0x3280
movl 0x90(%r13), %esi
movq %rbx, %rdi
callq 0x33d0
movq %rax, %rbx
leaq 0x3ca5f(%rip), %rsi     # 0x4cbc9
movl $0x13, %edx
movq %rax, %rdi
callq 0x3280
movl 0x94(%r13), %esi
movq %rbx, %rdi
callq 0x33d0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3200
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3180
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x101c7
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x3230
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x101de
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3230
movq 0x98(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0xb8(%rsp,%rax)
jne 0x10677
testl %ebp, %ebp
jne 0x10249
leaq 0x3c9f9(%rip), %rsi     # 0x4cbfc
leaq 0x98(%rsp), %rbx
movl $0x81, %edx
movq %rbx, %rdi
callq 0x3280
movq 0x98(%rsp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x3200
movsbl %al, %esi
leaq 0x98(%rsp), %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3180
movq 0x8(%rsp), %rcx
movq 0x8(%rcx), %rax
cmpq (%rcx), %rax
je 0x10620
movl 0x60(%r13), %eax
movl %eax, 0x34(%rsp)
xorl %ebx, %ebx
movq %r15, 0x58(%rsp)
movl (%r15), %esi
leaq 0x98(%rsp), %rdi
callq 0x33d0
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3c9f5(%rip), %rsi     # 0x4cc7e
callq 0x3280
incl (%r15)
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq %rbx, 0x70(%rsp)
leaq (%rbx,%rbx,4), %r12
shlq $0x4, %r12
movslq (%rax,%r12), %rbx
movq 0x60(%rsp), %r14
movq 0xa8(%r14), %rax
movq 0xd8(%r14), %rcx
movl (%rcx,%rbx,4), %ebp
movl (%rax,%rbx,4), %r13d
movq 0x68(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
leaq 0x98(%rsp), %rdi
callq 0x3280
leaq 0x3c99a(%rip), %r15     # 0x4cc7e
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x3280
leaq 0x98(%rsp), %rdi
movl 0x2d0(%rsp), %esi
callq 0x33d0
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x3280
movq 0x30(%r14), %rax
movq %rbx, %rcx
shlq $0x5, %rcx
movq (%rax,%rcx), %rsi
movq 0x8(%rax,%rcx), %rdx
leaq 0x98(%rsp), %rdi
callq 0x3280
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x3280
leaq 0x98(%rsp), %rdi
movl %ebp, %esi
callq 0x33d0
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x3280
movq 0x8(%rsp), %rax
movq (%rax), %rax
movsd 0x18(%rax,%r12), %xmm0
leaq 0x98(%rsp), %rdi
callq 0x3390
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x3280
movq 0x8(%rsp), %rax
movq (%rax), %rax
movsd 0x20(%rax,%r12), %xmm0
leaq 0x98(%rsp), %rdi
callq 0x3390
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x3280
movq 0x8(%rsp), %rax
movq (%rax), %rax
movsd 0x28(%rax,%r12), %xmm0
leaq 0x98(%rsp), %rdi
callq 0x3390
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x3280
movq %r13, %r15
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x40(%rax,%r12), %r13
subq 0x38(%rax,%r12), %r13
movq 0xc0(%r14), %rax
movl (%rax,%rbx,4), %ebx
cmpl $0x1, 0x34(%rsp)
jne 0x104c6
shrq $0x3, %r13
testl %r13d, %r13d
jle 0x105b3
leal (%r15,%rbx), %r14d
decl %r14d
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
xorl %r15d, %r15d
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x38(%rax,%r12), %rax
movl %r14d, %ebp
subl 0x4(%rax,%r15,8), %ebp
movl $0x1, %edx
leaq 0x98(%rsp), %rdi
leaq 0x3c823(%rip), %rsi     # 0x4cc80
callq 0x3280
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x38(%rax,%r12), %rax
movl (%rax,%r15,8), %esi
leaq 0x98(%rsp), %rdi
callq 0x33d0
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3c720(%rip), %rsi     # 0x4cbb2
callq 0x3280
movq %rbx, %rdi
movl %ebp, %esi
callq 0x33d0
movl $0x2, %edx
movq %rax, %rdi
leaq 0x3c7d2(%rip), %rsi     # 0x4cc82
callq 0x3280
incq %r15
cmpq %r15, %r13
jne 0x10434
jmp 0x105b3
movl $0x1, %edx
leaq 0x98(%rsp), %rdi
leaq 0x3c7a6(%rip), %rsi     # 0x4cc80
callq 0x3280
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x38(%rax,%r12), %rax
movl (%rax), %esi
leaq 0x98(%rsp), %rdi
callq 0x33d0
movq %rax, %rbp
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3c778(%rip), %rsi     # 0x4cc85
callq 0x3280
movq 0x8(%rsp), %rax
movq (%rax), %rax
shlq $0x1d, %r13
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
addq %rcx, %r13
sarq $0x20, %r13
movq 0x38(%rax,%r12), %rax
movl (%rax,%r13,8), %esi
movq %rbp, %rdi
callq 0x33d0
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3c663(%rip), %rsi     # 0x4cbb2
callq 0x3280
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x38(%rax,%r12), %rax
leal (%rbx,%r15), %ebp
decl %ebp
movl %ebp, %esi
subl 0x4(%rax), %esi
subl 0x4(%rax,%r13,8), %ebp
leaq 0x98(%rsp), %rdi
callq 0x33d0
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3c6f5(%rip), %rsi     # 0x4cc85
callq 0x3280
movq %rbx, %rdi
movl %ebp, %esi
callq 0x33d0
movl $0x2, %edx
movq %rax, %rdi
leaq 0x3c6d4(%rip), %rsi     # 0x4cc82
callq 0x3280
movq 0x98(%rsp), %rax
movq -0x18(%rax), %rdi
leaq 0x98(%rsp), %rax
addq %rax, %rdi
movl $0xa, %esi
callq 0x3200
movsbl %al, %esi
leaq 0x98(%rsp), %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3180
movq 0x8(%rsp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
movq 0x70(%rsp), %rbx
incq %rbx
sarq $0x4, %rax
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rcx, %rax
cmpq %rbx, %rax
movq 0x58(%rsp), %r15
ja 0x1026a
leaq 0x98(%rsp), %rdi
callq 0x3320
movq 0xd598c(%rip), %rax     # 0xe5fc0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0xa0(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x98(%rsp,%rcx)
callq 0x31d0
leaq 0x190(%rsp), %rdi
callq 0x30d0
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x88(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x40(%r13), %rsi
movq 0x48(%r13), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %rdi
callq 0x46f2
leaq 0x3c53e(%rip), %rsi     # 0x4cbdd
leaq 0x38(%rsp), %rdi
leaq 0x78(%rsp), %rdx
callq 0x1131a
leaq 0xb0bc(%rip), %rsi      # 0x1b771
leaq 0x38(%rsp), %rdi
callq 0x3420
movq %r14, 0x10(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x106dc
movups (%rcx), %xmm0
movups %xmm0, (%r14)
jmp 0x106e9
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
movq 0x8(%rax), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0xd58be(%rip), %rdi     # 0xe5fd0
callq 0x3280
movq %rax, %rdi
callq 0x3120
leaq 0x10(%rsp), %rdi
callq 0x3110
leaq 0x38(%rsp), %rdi
callq 0x3110
leaq 0x78(%rsp), %rdi
callq 0x3110
movl $0x1, %edi
callq 0x32a0
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x10766
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3230
jmp 0x10766
movq %rax, %rbx
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x10786
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x3230
jmp 0x10786
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x107ef
movq 0x88(%rsp), %rsi
jmp 0x107da
jmp 0x107a8
jmp 0x107ec
jmp 0x107a8
jmp 0x107ec
jmp 0x107ec
jmp 0x107a8
jmp 0x107ec
movq %rax, %rbx
jmp 0x107cb
jmp 0x107ec
jmp 0x107ec
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x107cb
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x3230
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x107ef
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3230
jmp 0x107ef
jmp 0x107ec
jmp 0x107ec
jmp 0x107ec
jmp 0x107ec
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x3340
movq %rbx, %rdi
callq 0x33e0