// File: /workspace/github_c_makefile_star2_O1/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 0x13f89
movq 0x38(%rsp), %r11
movq 0x30(%rsp), %rax
movq (%rax), %r14
movslq %ecx, %rax
movzbl 0x1(%r14,%rax), %ecx
xorl %ebp, %ebp
cmpl $0x6, %ecx
movl $0x0, %eax
sbbl %eax, %eax
orl $-0x5, %eax
addl %ecx, %eax
movq (%r11), %r15
movslq %r8d, %rcx
movzbl 0x1(%r15,%rcx), %ecx
cmpl $0x6, %ecx
movl $0x0, %r11d
sbbl %r11d, %r11d
orl $-0x5, %r11d
addl %ecx, %r11d
movslq %r9d, %rcx
movzbl -0x1(%r14,%rcx), %ecx
cmpl $0x6, %ecx
movl $0x0, %r9d
sbbl %r9d, %r9d
movslq %ebx, %r8
movzbl -0x1(%r15,%r8), %r8d
cmpl $0x6, %r8d
sbbl %ebp, %ebp
leal (%r10,%rdi), %ebx
cmpl $0x2, %ebx
jne 0x13fac
movslq %esi, %rcx
movslq %edx, %rdx
cltq
movslq %r11d, %rsi
imulq $0x320, %rcx, %rcx      # imm = 0x320
leaq 0x69fe1(%rip), %rdi     # 0x7df50
addq %rcx, %rdi
imulq $0x64, %rdx, %rcx
addq %rdi, %rcx
leaq (%rax,%rax,4), %rax
leaq (%rcx,%rax,4), %rax
movl (%rax,%rsi,4), %eax
jmp 0x140ee
movslq %esi, %rax
movslq %edx, %rcx
leaq (%rax,%rax,8), %rdx
leaq (%rdx,%rdx,2), %rdx
leaq 0x69ee2(%rip), %rsi     # 0x7de80
addq %rax, %rsi
addq %rdx, %rsi
movl (%rsi,%rcx,4), %eax
jmp 0x140ee
orl $-0x5, %ebp
addl %ebp, %r8d
movl %edi, %r14d
xorl $0x1, %r14d
movl %r10d, %ebp
xorl $0x2, %ebp
orl %ebp, %r14d
jne 0x14004
movslq %esi, %rcx
movslq %edx, %rdx
cltq
movslq %r8d, %rsi
movslq %r11d, %rdi
imulq $0xfa0, %rcx, %rcx      # imm = 0xFA0
leaq 0x6b870(%rip), %r8      # 0x7f850
addq %rcx, %r8
imulq $0x1f4, %rdx, %rcx      # imm = 0x1F4
addq %r8, %rcx
imulq $0x64, %rax, %rax
addq %rcx, %rax
leaq (%rsi,%rsi,4), %rcx
leaq (%rax,%rcx,4), %rax
movl (%rax,%rdi,4), %eax
jmp 0x140ee
orl $-0x5, %r9d
addl %r9d, %ecx
xorl $0x2, %edi
xorl $0x1, %r10d
orl %edi, %r10d
jne 0x14057
movslq %edx, %rdx
movslq %esi, %rsi
movslq %r8d, %rdi
cltq
movslq %ecx, %rcx
imulq $0xfa0, %rdx, %rdx      # imm = 0xFA0
leaq 0x6b81d(%rip), %r8      # 0x7f850
addq %rdx, %r8
imulq $0x1f4, %rsi, %rdx      # imm = 0x1F4
addq %r8, %rdx
imulq $0x64, %rdi, %rsi
addq %rdx, %rsi
leaq (%rax,%rax,4), %rax
leaq (%rsi,%rax,4), %rax
movl (%rax,%rcx,4), %eax
jmp 0x140ee
movslq %r11d, %r9
orl %ebp, %edi
jne 0x140a6
movslq %esi, %rsi
movslq %edx, %rdx
cltq
movslq %ecx, %rcx
movslq %r8d, %rdi
imulq $0x4e20, %rsi, %rsi     # imm = 0x4E20
leaq 0x734d6(%rip), %r8      # 0x87550
addq %rsi, %r8
imulq $0x9c4, %rdx, %rdx      # imm = 0x9C4
addq %r8, %rdx
imulq $0x1f4, %rax, %rax      # imm = 0x1F4
addq %rdx, %rax
imulq $0x64, %rcx, %rcx
addq %rax, %rcx
leaq (%rdi,%rdi,4), %rax
leaq (%rcx,%rax,4), %rax
movl (%rax,%r9,4), %eax
jmp 0x140ee
movslq %ebx, %rdi
leaq 0x9a5a0(%rip), %r10     # 0xae650
movslq %esi, %rsi
cltq
imulq $0x64, %rsi, %rsi
leaq 0x9a610(%rip), %r11     # 0xae6d0
addq %r11, %rsi
leaq (%rax,%rax,4), %rax
leaq (%rsi,%rax,4), %rax
movl (%rax,%r9,4), %eax
addl (%r10,%rdi,4), %eax
movslq %edx, %rdx
movslq %r8d, %rsi
movslq %ecx, %rcx
imulq $0x64, %rdx, %rdx
addq %r11, %rdx
leaq (%rsi,%rsi,4), %rsi
leaq (%rdx,%rsi,4), %rdx
addl (%rdx,%rcx,4), %eax
cvtsi2sd %eax, %xmm0
divsd 0x69ce6(%rip), %xmm0    # 0x7dde0
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)