// File: /workspace/github_c_makefile_star2_O3/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, %ebx
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
testl %ebx, %ebx
je 0x11643
movq %r14, -0x10(%r14)
movq 0x40(%r13), %rsi
movq 0x48(%r13), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %rdi
callq 0x479e
movq 0x10(%rsp), %rsi
leaq 0x98(%rsp), %rdi
movl $0x1, %edx
callq 0x3040
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x11624
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3230
movq 0x98(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0xb8(%rsp,%rax)
je 0x11973
jmp 0x11da1
movq %r14, -0x10(%r14)
movq 0x40(%r13), %rsi
movq 0x48(%r13), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %rdi
callq 0x479e
movq 0x10(%rsp), %rsi
leaq 0x98(%rsp), %rdi
movl $0x10, %edx
callq 0x3040
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x1168a
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3230
leaq 0x3c647(%rip), %rsi     # 0x4dcd8
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 0x3c60d(%rip), %rsi     # 0x4dceb
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 0x479e
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
leaq 0x98(%rsp), %rdi
callq 0x3280
movq %rax, %rbx
leaq 0x3c5c9(%rip), %rsi     # 0x4dcf2
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 0x479e
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq %rbx, %rdi
callq 0x3280
movq %rax, %rbx
leaq 0x3c58c(%rip), %rsi     # 0x4dcfd
movl $0xc, %edx
movq %rax, %rdi
callq 0x3280
movl 0x68(%r13), %esi
movq %rbx, %rdi
callq 0x33d0
movq %rax, %rbx
leaq 0x3c576(%rip), %rsi     # 0x4dd0a
movl $0xd, %edx
movq %rax, %rdi
callq 0x3280
movl 0x6c(%r13), %esi
movq %rbx, %rdi
callq 0x33d0
movq %rax, %rbx
leaq 0x3c561(%rip), %rsi     # 0x4dd18
movl $0x15, %edx
movq %rax, %rdi
callq 0x3280
movl 0x70(%r13), %esi
movq %rbx, %rdi
callq 0x33d0
movq %rax, %rbx
leaq 0x3c554(%rip), %rsi     # 0x4dd2e
movl $0xf, %edx
movq %rax, %rdi
callq 0x3280
movl 0x74(%r13), %esi
movq %rbx, %rdi
callq 0x33d0
movq %rax, %rbx
leaq 0x3c541(%rip), %rsi     # 0x4dd3e
movl $0x1c, %edx
movq %rax, %rdi
callq 0x3280
movsd 0x78(%r13), %xmm0
movq %rbx, %rdi
callq 0x3390
movq %rax, %rbx
leaq 0x3c539(%rip), %rsi     # 0x4dd5b
movl $0x17, %edx
movq %rax, %rdi
callq 0x3280
movsd 0x80(%r13), %xmm0
movq %rbx, %rdi
callq 0x3390
movq %rax, %rbx
leaq 0x3c529(%rip), %rsi     # 0x4dd73
movl $0x10, %edx
movq %rax, %rdi
callq 0x3280
movsd 0x88(%r13), %xmm0
movq %rbx, %rdi
callq 0x3390
movq %rax, %rbx
leaq 0x3c512(%rip), %rsi     # 0x4dd84
movl $0x14, %edx
movq %rax, %rdi
callq 0x3280
movl 0x90(%r13), %esi
movq %rbx, %rdi
callq 0x33d0
movq %rax, %rbx
leaq 0x3c501(%rip), %rsi     # 0x4dd99
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 0x118f5
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x3230
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x1190c
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3230
movq 0x98(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0xb8(%rsp,%rax)
jne 0x11da1
leaq 0x3c49f(%rip), %rsi     # 0x4ddcc
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 0x11d4a
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 0x3c49b(%rip), %rsi     # 0x4de4e
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 0x3c440(%rip), %r15     # 0x4de4e
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 0x11bf0
shrq $0x3, %r13
testl %r13d, %r13d
jle 0x11cdd
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 0x3c2c9(%rip), %rsi     # 0x4de50
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 0x3c1c6(%rip), %rsi     # 0x4dd82
callq 0x3280
movq %rbx, %rdi
movl %ebp, %esi
callq 0x33d0
movl $0x2, %edx
movq %rax, %rdi
leaq 0x3c278(%rip), %rsi     # 0x4de52
callq 0x3280
incq %r15
cmpq %r15, %r13
jne 0x11b5e
jmp 0x11cdd
movl $0x1, %edx
leaq 0x98(%rsp), %rdi
leaq 0x3c24c(%rip), %rsi     # 0x4de50
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 0x3c21e(%rip), %rsi     # 0x4de55
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 0x3c109(%rip), %rsi     # 0x4dd82
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 0x3c19b(%rip), %rsi     # 0x4de55
callq 0x3280
movq %rbx, %rdi
movl %ebp, %esi
callq 0x33d0
movl $0x2, %edx
movq %rax, %rdi
leaq 0x3c17a(%rip), %rsi     # 0x4de52
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 0x11994
leaq 0x98(%rsp), %rdi
callq 0x3320
movq 0xd5262(%rip), %rax     # 0xe6fc0
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), %r14
movq %r14, -0x10(%r14)
movq 0x40(%r13), %rsi
movq 0x48(%r13), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %rdi
callq 0x479e
leaq 0x3bfe4(%rip), %rsi     # 0x4ddad
leaq 0x38(%rsp), %rdi
leaq 0x78(%rsp), %rdx
callq 0x12a74
leaq 0xa9cc(%rip), %rsi      # 0x1c7ab
leaq 0x38(%rsp), %rdi
callq 0x3420
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rsi
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rsi
jne 0x11e0d
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq %r15, %rsi
jmp 0x11e1a
movq %rsi, 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 0xd5197(%rip), %rdi     # 0xe6fd0
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 %r15, %rdi
je 0x11e8d
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3230
jmp 0x11e8d
movq %rax, %rbx
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x11ead
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x3230
jmp 0x11ead
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r14, %rdi
je 0x11f16
movq 0x88(%rsp), %rsi
jmp 0x11f01
jmp 0x11ecf
jmp 0x11f13
jmp 0x11ecf
jmp 0x11f13
jmp 0x11f13
jmp 0x11ecf
jmp 0x11f13
movq %rax, %rbx
jmp 0x11ef2
jmp 0x11f13
jmp 0x11f13
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x11ef2
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x3230
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x11f16
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3230
jmp 0x11f16
jmp 0x11f13
jmp 0x11f13
jmp 0x11f13
jmp 0x11f13
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x3340
movq %rbx, %rdi
callq 0x33e0
nop