// File: /workspace/github_c_makefile_star2_O2/fukunagatsu[P]RIblast/ungapped_extension.cpp
// Function: UngappedExtension::LoopEnergy(int, int, int, int, int, int, std::vector<unsigned char, std::allocator<unsigned char>>&, std::vector<unsigned char, std::allocator<unsigned char>>&)
double UngappedExtension::LoopEnergy(int type, int type2,int i,int j,int p,int q, vector<unsigned char> &query_seq, vector<unsigned char> &db_seq){
  double z = 0;
  int u1 = p-i-1;
  int u2 = q-j-1;
  
  if ((u1==0) && (u2==0)){
    z = stack37[type][type2];
  }else{
    int a = query_seq[i+1] <=5 ? query_seq[i+1]-1 : query_seq[i+1]-5;
    int b = db_seq[j+1] <=5 ? db_seq[j+1]-1 : db_seq[j+1]-5;
    int c = query_seq[p-1] <=5 ? query_seq[p-1]-1 : query_seq[p-1]-5;
    int d = db_seq[q-1] <=5 ? db_seq[q-1]-1 : db_seq[q-1]-5;
    if (u1+u2==2) {
      z = int11_37[type][type2][a][b];
    }else if ((u1==1) && (u2==2)){
      z = int21_37[type][type2][a][d][b];
    }else if ((u1==2) && (u2==1)){
      z = int21_37[type2][type][d][a][c];
    }else if ((u1==2) && (u2==2)){
    z = int22_37[type][type2][a][c][d][b];
    }else{
      z = internal_loop37[u1+u2]+mismatchI37[type][a][b]+mismatchI37[type2][d][c];
    }
  }
  return double(z)/100;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
movl 0x28(%rsp), %ebx
movl %ecx, %edi
notl %edi
addl %r9d, %edi
movl %r8d, %r10d
notl %r10d
addl %ebx, %r10d
movl %r10d, %eax
orl %edi, %eax
je 0x1045c
movq 0x38(%rsp), %r11
movq 0x30(%rsp), %rax
movq (%rax), %r14
movslq %ecx, %rax
movzbl 0x1(%r14,%rax), %ebp
xorl %eax, %eax
cmpl $0x6, %ebp
movl $0x0, %ecx
sbbl %ecx, %ecx
orl $-0x5, %ecx
addl %ebp, %ecx
movq (%r11), %r15
movslq %r8d, %r8
movzbl 0x1(%r15,%r8), %r8d
cmpl $0x6, %r8d
movl $0x0, %r11d
sbbl %r11d, %r11d
orl $-0x5, %r11d
addl %r8d, %r11d
movslq %r9d, %r8
movzbl -0x1(%r14,%r8), %r9d
cmpl $0x6, %r9d
movl $0x0, %r8d
sbbl %r8d, %r8d
movslq %ebx, %rbx
movzbl -0x1(%r15,%rbx), %ebp
cmpl $0x6, %ebp
sbbl %eax, %eax
leal (%r10,%rdi), %ebx
cmpl $0x2, %ebx
jne 0x10478
movslq %esi, %rax
movslq %edx, %rdx
movslq %ecx, %rcx
movslq %r11d, %rsi
imulq $0x320, %rax, %rax      # imm = 0x320
leaq 0x68b1d(%rip), %rdi     # 0x78f60
addq %rax, %rdi
imulq $0x64, %rdx, %rax
addq %rdi, %rax
imulq $0x14, %rcx, %rcx
addq %rax, %rcx
movl (%rcx,%rsi,4), %ecx
jmp 0x105b4
movslq %esi, %rax
movslq %edx, %rcx
imulq $0x1c, %rax, %rax
leaq 0x68a23(%rip), %rdx     # 0x78e90
addq %rax, %rdx
movl (%rdx,%rcx,4), %ecx
jmp 0x105b4
orl $-0x5, %eax
addl %ebp, %eax
movl %edi, %r14d
xorl $0x1, %r14d
movl %r10d, %ebp
xorl $0x2, %ebp
orl %ebp, %r14d
jne 0x104ce
movslq %esi, %rsi
movslq %edx, %rdx
movslq %ecx, %rcx
cltq
movslq %r11d, %rdi
imulq $0xfa0, %rsi, %rsi      # imm = 0xFA0
leaq 0x6a3b5(%rip), %r8      # 0x7a860
addq %rsi, %r8
imulq $0x1f4, %rdx, %rdx      # imm = 0x1F4
addq %r8, %rdx
imulq $0x64, %rcx, %rcx
addq %rdx, %rcx
imulq $0x14, %rax, %rax
addq %rcx, %rax
movl (%rax,%rdi,4), %ecx
jmp 0x105b4
orl $-0x5, %r8d
addl %r9d, %r8d
xorl $0x2, %edi
xorl $0x1, %r10d
orl %edi, %r10d
jne 0x10520
movslq %edx, %rdx
movslq %esi, %rsi
cltq
movslq %ecx, %rcx
movslq %r8d, %rdi
imulq $0xfa0, %rdx, %rdx      # imm = 0xFA0
leaq 0x6a363(%rip), %r8      # 0x7a860
addq %rdx, %r8
imulq $0x1f4, %rsi, %rdx      # imm = 0x1F4
addq %r8, %rdx
imulq $0x64, %rax, %rax
addq %rdx, %rax
imulq $0x14, %rcx, %rcx
addq %rax, %rcx
movl (%rcx,%rdi,4), %ecx
jmp 0x105b4
movslq %r11d, %r9
orl %ebp, %edi
jne 0x1056e
movslq %esi, %rsi
movslq %edx, %rdx
movslq %ecx, %rcx
movslq %r8d, %rdi
cltq
imulq $0x4e20, %rsi, %rsi     # imm = 0x4E20
leaq 0x7201d(%rip), %r8      # 0x82560
addq %rsi, %r8
imulq $0x9c4, %rdx, %rdx      # imm = 0x9C4
addq %r8, %rdx
imulq $0x1f4, %rcx, %rcx      # imm = 0x1F4
addq %rdx, %rcx
imulq $0x64, %rdi, %rdx
imulq $0x14, %rax, %rax
addq %rdx, %rax
addq %rcx, %rax
movl (%rax,%r9,4), %ecx
jmp 0x105b4
movslq %ebx, %rdi
leaq 0x990e8(%rip), %r10     # 0xa9660
movslq %esi, %rsi
movslq %ecx, %rcx
imulq $0x64, %rsi, %rsi
leaq 0x99157(%rip), %r11     # 0xa96e0
addq %r11, %rsi
imulq $0x14, %rcx, %rcx
addq %rsi, %rcx
movl (%rcx,%r9,4), %ecx
addl (%r10,%rdi,4), %ecx
movslq %edx, %rdx
cltq
movslq %r8d, %rsi
imulq $0x64, %rdx, %rdx
addq %r11, %rdx
imulq $0x14, %rax, %rax
addq %rdx, %rax
addl (%rax,%rsi,4), %ecx
cvtsi2sd %ecx, %xmm0
divsd 0x68830(%rip), %xmm0    # 0x78df0
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop