// File: /workspace/github_c_makefile_star2_O3/nh13[P]ksw/src/parasail/src/nw_scan.c
// Function: parasail_nw_rowcol_scan
parasail_result_t* ENAME(
        const char * const restrict _s1, const int _s1Len,
        const char * const restrict _s2, const int s2Len,
        const int open, const int gap, const parasail_matrix_t *matrix)
{
    /* declare local variables */
    parasail_result_t *result = NULL;
    int * restrict s1 = NULL;
    int * restrict s2 = NULL;
    int * restrict HB = NULL;
    int * restrict H  = NULL;
    int * restrict E  = NULL;
    int * restrict HtB= NULL;
    int * restrict Ht = NULL;
    int s1Len = 0;
    int i = 0;
    int j = 0;

    /* validate inputs */
    PARASAIL_CHECK_NULL(_s2);
    PARASAIL_CHECK_GT0(s2Len);
    PARASAIL_CHECK_GE0(open);
    PARASAIL_CHECK_GE0(gap);
    PARASAIL_CHECK_NULL(matrix);
    if (matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) {
        PARASAIL_CHECK_NULL(_s1);
        PARASAIL_CHECK_GT0(_s1Len);
    }

    /* initialize stack variables */
    s1Len = matrix->type == PARASAIL_MATRIX_TYPE_SQUARE ? _s1Len : matrix->length;

    /* initialize result */
#ifdef PARASAIL_TABLE
    result = parasail_result_new_table1(s1Len, s2Len);
#else
#ifdef PARASAIL_ROWCOL
    result = parasail_result_new_rowcol1(s1Len, s2Len);
#else
    result = parasail_result_new();
#endif
#endif
    if (!result) return NULL;

    /* set known flags */
    result->flag |= PARASAIL_FLAG_NW | PARASAIL_FLAG_NOVEC_SCAN
        | PARASAIL_FLAG_BITS_INT | PARASAIL_FLAG_LANES_1;
#ifdef PARASAIL_TABLE
    result->flag |= PARASAIL_FLAG_TABLE;
#endif
#ifdef PARASAIL_ROWCOL
    result->flag |= PARASAIL_FLAG_ROWCOL;
#endif

    /* initialize heap variables */
    s2 = parasail_memalign_int(16, s2Len);
    HB = parasail_memalign_int(16, s1Len+1);
    H  = HB+1;
    E  = parasail_memalign_int(16, s1Len);
    HtB= parasail_memalign_int(16, s1Len+1);
    Ht = HtB+1;

    /* validate heap variables */
    if (!s2) return NULL;
    if (!HB) return NULL;
    if (!E) return NULL;
    if (!HtB) return NULL;

    if (matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) {
        s1 = parasail_memalign_int(16, s1Len);
        if (!s1) return NULL;
        for (i=0; i<s1Len; ++i) {
            s1[i] = matrix->mapper[(unsigned char)_s1[i]];
        }
    }

    for (j=0; j<s2Len; ++j) {
        s2[j] = matrix->mapper[(unsigned char)_s2[j]];
    }

    /* initialize H */
    H[-1] = 0;
    Ht[-1] = 0;
    for (i=0; i<s1Len; ++i) {
        H[i] = -open - i*gap;
    }

    /* initialize E */
    for (i=0; i<s1Len; ++i) {
        E[i] = NEG_INF_32;
    }

    /* iterate over database */
    for (j=0; j<s2Len; ++j) {
        int Ft = NEG_INF_32;
        /* calculate E */
        for (i=0; i<s1Len; ++i) {
            E[i] = MAX(E[i]-gap, H[i]-open);
        }
        /* calculate Ht */
        for (i=0; i<s1Len; ++i) {
            int matval = matrix->type == PARASAIL_MATRIX_TYPE_SQUARE ?
                         matrix->matrix[matrix->size*s1[i]+s2[j]] :
                         matrix->matrix[matrix->size*i+s2[j]];
            Ht[i] = MAX(H[i-1]+matval, E[i]);
        }
        Ht[-1] = -open -j*gap;
        /* calculate H */
        for (i=0; i<s1Len; ++i) {
            int Ft_opn;
            int Ht_pre = Ht[i-1];
            int Ft_ext = Ft-gap;
            if (Ht_pre >= Ft_ext) {
                Ft = Ht_pre;
            }
            else {
                Ft = Ft_ext;
            }
            Ft_opn = Ft-open;
            H[i] = MAX(Ht[i], Ft_opn);
#ifdef PARASAIL_TABLE
            result->tables->score_table[i*s2Len + j] = H[i];
#endif
        }
        H[-1] = -open - j*gap;
#ifdef PARASAIL_ROWCOL
        if (j == s2Len-1) {
            for (i=0; i<s1Len; ++i) {
                result->rowcols->score_col[i] = H[i];
            }
        }
        result->rowcols->score_row[j] = H[s1Len-1];
#endif
    }

    result->score = H[s1Len-1];
    result->end_query = s1Len-1;
    result->end_ref = s2Len-1;

    parasail_free(HtB);
    parasail_free(E);
    parasail_free(HB);
    parasail_free(s2);
    if (matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) {
        parasail_free(s1);
    }

    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %rbx
testq %rdx, %rdx
je 0x2a6e89
testl %ecx, %ecx
jle 0x2a6e93
movl %r8d, %ebp
testl %r8d, %r8d
js 0x2a6e9d
movl %r9d, %r12d
testl %r9d, %r9d
js 0x2a6ea7
movq 0x90(%rsp), %rax
testq %rax, %rax
je 0x2a6eb1
movq %rdi, %r14
cmpl $0x0, 0x30(%rax)
je 0x2a699d
movl 0x34(%rax), %edx
jmp 0x2a69b0
testq %r14, %r14
je 0x2a6ebb
movl %esi, %edx
testl %esi, %esi
jle 0x2a6ec5
movl %edx, %edi
movl %ecx, %esi
movq %rcx, %r13
movq %rdx, %r15
callq 0x20ac53
testq %rax, %rax
je 0x2a6a7b
movq %r14, 0x38(%rsp)
movq %rbx, 0x48(%rsp)
orl $0x1440201, 0xc(%rax)   # imm = 0x1440201
movq %r13, 0x28(%rsp)
movl %r13d, %esi
movl $0x10, %edi
movq %rsi, (%rsp)
movq %rax, 0x10(%rsp)
callq 0x20a617
movq %rax, %r13
leal 0x1(%r15), %eax
movq %rax, 0x40(%rsp)
movslq %eax, %rbx
movl $0x10, %edi
movq %rbx, %rsi
callq 0x20a617
movq %rax, %r14
movq %r15, 0x20(%rsp)
movslq %r15d, %rsi
movl $0x10, %edi
movq %rsi, 0x30(%rsp)
callq 0x20a617
movq %rax, %r15
movl $0x10, %edi
movq %rbx, %rsi
callq 0x20a617
movq %rax, %rbx
movq %r13, %xmm0
movq %r14, %xmm1
punpcklqdq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]
movq %r15, %xmm1
movq %rax, %xmm2
punpcklqdq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0]
pxor %xmm2, %xmm2
pcmpeqd %xmm2, %xmm0
pcmpeqd %xmm2, %xmm1
movdqa %xmm0, %xmm2
shufps $0xdd, %xmm1, %xmm2     # xmm2 = xmm2[1,3],xmm1[1,3]
shufps $0x88, %xmm1, %xmm0     # xmm0 = xmm0[0,2],xmm1[0,2]
andps %xmm2, %xmm0
movmskps %xmm0, %eax
testl %eax, %eax
je 0x2a6a8c
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, %rsi
movq 0x90(%rsp), %r11
cmpl $0x0, 0x30(%r11)
movq 0x20(%rsp), %r8
movl %r8d, %r13d
movq %rsi, 0x8(%rsp)
je 0x2a6e15
movq $0x0, 0x18(%rsp)
movq 0x10(%rsp), %r9
movq (%rsp), %rdi
movq 0x10(%r11), %rax
xorl %ecx, %ecx
movq 0x48(%rsp), %r10
movzbl (%r10,%rcx), %edx
movl (%rax,%rdx,4), %edx
movl %edx, (%rsi,%rcx,4)
incq %rcx
cmpq %rcx, %rdi
jne 0x2a6acc
xorl %eax, %eax
movl %eax, (%r14)
movl %eax, (%rbx)
testl %r8d, %r8d
movq 0x28(%rsp), %r10
jle 0x2a6c90
leaq -0x1(%r13), %rax
movq %rax, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movq 0x40(%rsp), %r10
shrl %r10d
shlq $0x3, %r10
movl %r12d, %eax
negl %eax
movl %ebp, %ecx
negl %ecx
leal (%r12,%r12), %edx
movdqa 0x38236d(%rip), %xmm2   # 0x628e90
xorl %esi, %esi
movdqa 0x382373(%rip), %xmm1   # 0x628ea0
pxor %xmm1, %xmm0
pcmpeqd %xmm3, %xmm3
movdqa 0x3823b3(%rip), %xmm4   # 0x628ef0
movdqa %xmm2, %xmm5
pxor %xmm1, %xmm5
movdqa %xmm5, %xmm6
pcmpgtd %xmm0, %xmm6
pcmpeqd %xmm0, %xmm5
pshufd $0xf5, %xmm5, %xmm7     # xmm7 = xmm5[1,1,3,3]
pand %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm5     # xmm5 = xmm6[1,1,3,3]
por %xmm7, %xmm5
movd %xmm5, %edi
notl %edi
testb $0x1, %dil
je 0x2a6b74
movl %ecx, 0x4(%r14,%rsi)
pxor %xmm3, %xmm5
pextrw $0x4, %xmm5, %edi
testb $0x1, %dil
je 0x2a6b8b
leal (%rax,%rcx), %edi
movl %edi, 0x8(%r14,%rsi)
paddq %xmm4, %xmm2
addq $0x8, %rsi
subl %edx, %ecx
cmpq %rsi, %r10
jne 0x2a6b3d
testl %r8d, %r8d
movq (%rsp), %rdi
movq 0x28(%rsp), %r10
jle 0x2a6c90
leal 0x3(%r13), %eax
shrl $0x2, %eax
shlq $0x4, %rax
movdqa 0x3822c1(%rip), %xmm2   # 0x628e80
movdqa 0x3822c9(%rip), %xmm3   # 0x628e90
xorl %ecx, %ecx
pcmpeqd %xmm4, %xmm4
movdqa 0x3822db(%rip), %xmm5   # 0x628eb0
movdqa %xmm3, %xmm6
pxor %xmm1, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
movd %xmm6, %edx
notl %edx
testb $0x1, %dl
je 0x2a6c11
movl $0xc0000000, (%r15,%rcx) # imm = 0xC0000000
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x2a6c28
movl $0xc0000000, 0x4(%r15,%rcx) # imm = 0xC0000000
movdqa %xmm2, %xmm6
pxor %xmm1, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
pxor %xmm4, %xmm6
pextrw $0x0, %xmm6, %edx
testb $0x1, %dl
je 0x2a6c68
movl $0xc0000000, 0x8(%r15,%rcx) # imm = 0xC0000000
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x2a6c7b
movl $0xc0000000, 0xc(%r15,%rcx) # imm = 0xC0000000
paddq %xmm5, %xmm3
paddq %xmm5, %xmm2
addq $0x10, %rcx
cmpq %rcx, %rax
jne 0x2a6bd5
decl %r10d
xorl %eax, %eax
testl %r8d, %r8d
jle 0x2a6d8e
xorl %ecx, %ecx
movl (%r15,%rcx,4), %edx
subl %r12d, %edx
movl 0x4(%r14,%rcx,4), %esi
subl %ebp, %esi
cmpl %esi, %edx
cmovgl %edx, %esi
movl %esi, (%r15,%rcx,4)
incq %rcx
cmpq %rcx, %r13
jne 0x2a6ca0
testl %r8d, %r8d
jle 0x2a6d8e
movq 0x8(%r11), %rcx
xorl %edx, %edx
cmpl $0x0, 0x30(%r11)
movl 0x18(%r11), %esi
je 0x2a6cde
imull %edx, %esi
jmp 0x2a6ce7
movq 0x18(%rsp), %rdi
imull (%rdi,%rdx,4), %esi
movq 0x8(%rsp), %rdi
movslq (%rdi,%rax,4), %rdi
movslq %esi, %rsi
addq %rdi, %rsi
movl (%r14,%rdx,4), %edi
addl (%rcx,%rsi,4), %edi
movl (%r15,%rdx,4), %esi
cmpl %esi, %edi
cmovlel %esi, %edi
movl %edi, 0x4(%rbx,%rdx,4)
incq %rdx
cmpq %rdx, %r13
jne 0x2a6cce
movl %eax, %ecx
imull %r12d, %ecx
addl %ebp, %ecx
negl %ecx
movl %ecx, (%rbx)
testl %r8d, %r8d
jle 0x2a6dbe
movl $0xc0000000, %edx       # imm = 0xC0000000
xorl %esi, %esi
subl %r12d, %edx
movl (%rbx,%rsi,4), %edi
movl 0x4(%rbx,%rsi,4), %r8d
cmpl %edx, %edi
cmovgl %edi, %edx
movl %edx, %edi
subl %ebp, %edi
cmpl %edi, %r8d
cmovgl %r8d, %edi
movl %edi, 0x4(%r14,%rsi,4)
incq %rsi
cmpq %rsi, %r13
jne 0x2a6d2e
movq 0x20(%rsp), %r8
testl %r8d, %r8d
setle %dl
movl %ecx, (%r14)
cmpq %r10, %rax
setne %cl
orb %dl, %cl
movq (%rsp), %rdi
jne 0x2a6d9d
xorl %ecx, %ecx
movl 0x4(%r14,%rcx,4), %edx
movq 0x10(%r9), %rsi
movq 0x8(%rsi), %rsi
movl %edx, (%rsi,%rcx,4)
incq %rcx
cmpq %rcx, %r13
jne 0x2a6d74
jmp 0x2a6d9d
movl %eax, %ecx
imull %r12d, %ecx
addl %ebp, %ecx
negl %ecx
movl %ecx, (%rbx)
movl %ecx, (%r14)
movq 0x30(%rsp), %rsi
movl (%r14,%rsi,4), %ecx
movq 0x10(%r9), %rdx
movq (%rdx), %rdx
movl %ecx, (%rdx,%rax,4)
incq %rax
cmpq %rdi, %rax
jne 0x2a6c95
jmp 0x2a6dc4
movq (%rsp), %rdi
jmp 0x2a6d9a
decl %r8d
movl (%r14,%rsi,4), %eax
movl %eax, (%r9)
movl %r8d, 0x4(%r9)
movl %r10d, 0x8(%r9)
movq %rbx, %rdi
movq %r11, %rbx
callq 0x20a60d
movq %r15, %rdi
callq 0x20a60d
movq %r14, %rdi
callq 0x20a60d
movq 0x8(%rsp), %rdi
callq 0x20a60d
cmpl $0x0, 0x30(%rbx)
jne 0x2a6e0b
movq 0x18(%rsp), %rdi
callq 0x20a60d
movq 0x10(%rsp), %rax
jmp 0x2a6a7d
movl $0x10, %edi
movq 0x30(%rsp), %rsi
callq 0x20a617
testq %rax, %rax
je 0x2a6a7b
movq %rax, 0x18(%rsp)
movq 0x20(%rsp), %r8
testl %r8d, %r8d
movq 0x10(%rsp), %r9
movq 0x90(%rsp), %r11
jle 0x2a6ecf
movq 0x10(%r11), %rax
movq %rax, 0x50(%rsp)
xorl %ecx, %ecx
movq 0x8(%rsp), %rsi
movq (%rsp), %rdi
movq 0x38(%rsp), %rax
movzbl (%rax,%rcx), %edx
movq 0x50(%rsp), %r10
movl (%r10,%rdx,4), %edx
movq 0x18(%rsp), %r10
movl %edx, (%r10,%rcx,4)
incq %rcx
cmpq %rcx, %r13
jne 0x2a6e66
jmp 0x2a6ac1
callq 0x1a14fd
jmp 0x2a6a7b
callq 0x1a14d7
jmp 0x2a6a7b
callq 0x1a14b1
jmp 0x2a6a7b
callq 0x1a148b
jmp 0x2a6a7b
callq 0x1a1465
jmp 0x2a6a7b
callq 0x1a143f
jmp 0x2a6a7b
callq 0x1a1419
jmp 0x2a6a7b
movq 0x8(%rsp), %rsi
jmp 0x2a6abd
nopl (%rax)