// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
testq %rdx, %rdx
je 0x2a479e
movl %ecx, %ebx
testl %ecx, %ecx
jle 0x2a47a5
movl %r8d, %r15d
testl %r8d, %r8d
js 0x2a47ac
movl %r9d, %ebp
testl %r9d, %r9d
js 0x2a47b3
movq 0x70(%rsp), %rcx
testq %rcx, %rcx
je 0x2a47ba
movq %rdi, %r14
movl 0x30(%rcx), %eax
testl %eax, %eax
jne 0x2a446d
testq %r14, %r14
je 0x2a47cb
movl %esi, %r8d
testl %esi, %esi
jle 0x2a47d2
testl %eax, %eax
je 0x2a4471
movl 0x34(%rcx), %r8d
movq %rdx, 0x8(%rsp)
movl %r8d, %edi
movl %ebx, %esi
movq %r8, %r13
callq 0x209630
testq %rax, %rax
je 0x2a47d7
movq %r14, 0x30(%rsp)
movq %rax, 0x10(%rsp)
orl $0x1440201, 0xc(%rax)   # imm = 0x1440201
movq %rbx, 0x28(%rsp)
movl %ebx, %esi
movl $0x10, %edi
callq 0x2094bf
movq %rax, %r12
leal 0x1(%r13), %eax
movslq %eax, %rbx
movl $0x10, %edi
movq %rbx, %rsi
callq 0x2094bf
movq %r13, %rcx
movq %rax, %r13
movq %rcx, (%rsp)
movslq %ecx, %rsi
movl $0x10, %edi
movq %rsi, 0x20(%rsp)
callq 0x2094bf
movq %rax, %r14
movl $0x10, %edi
movq %rbx, %rsi
callq 0x2094bf
movq %rax, %rbx
testq %r12, %r12
sete %al
testq %r13, %r13
sete %cl
testq %r14, %r14
sete %dl
orb %al, %dl
orb %cl, %dl
testq %rbx, %rbx
sete %al
orb %dl, %al
jne 0x2a47d7
movq %r12, %rdi
movq 0x70(%rsp), %rsi
cmpl $0x0, 0x30(%rsi)
movq (%rsp), %r9
movl %r9d, %r12d
movq %rdi, 0x18(%rsp)
je 0x2a4745
xorl %eax, %eax
movq 0x10(%rsp), %r11
movq 0x8(%rsp), %r10
movq 0x10(%rsi), %r8
movq 0x28(%rsp), %rdx
cmpl $0x2, %edx
movl $0x1, %ecx
cmovgel %edx, %ecx
xorl %edx, %edx
movzbl (%r10,%rdx), %esi
movl (%r8,%rsi,4), %esi
movl %esi, (%rdi,%rdx,4)
incq %rdx
cmpq %rdx, %rcx
jne 0x2a4558
xorl %ecx, %ecx
movl %ecx, (%r13)
movl %ecx, (%rbx)
testl %r9d, %r9d
jle 0x2a458f
movl %r15d, %edx
negl %edx
xorl %ecx, %ecx
movl %edx, 0x4(%r13,%rcx,4)
incq %rcx
subl %ebp, %edx
cmpq %rcx, %r12
jne 0x2a4580
movq %rax, 0x8(%rsp)
testl %r9d, %r9d
jle 0x2a45ab
xorl %eax, %eax
movl $0xc0000000, (%r14,%rax,4) # imm = 0xC0000000
incq %rax
cmpq %rax, %r12
jne 0x2a459b
movq 0x28(%rsp), %rax
leal -0x1(%rax), %ecx
movq %rcx, (%rsp)
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
xorl %edx, %edx
testl %r9d, %r9d
jle 0x2a45ec
xorl %esi, %esi
movl (%r14,%rsi,4), %edi
subl %ebp, %edi
movl 0x4(%r13,%rsi,4), %r8d
subl %r15d, %r8d
cmpl %r8d, %edi
cmovgl %edi, %r8d
movl %r8d, (%r14,%rsi,4)
incq %rsi
cmpq %rsi, %r12
jne 0x2a45cb
movq %r9, %rax
testl %r9d, %r9d
movq 0x70(%rsp), %r10
jle 0x2a464e
movq 0x8(%r10), %rsi
xorl %edi, %edi
cmpl $0x0, 0x30(%r10)
je 0x2a4610
movl 0x18(%r10), %r8d
imull %edi, %r8d
jmp 0x2a461e
movq 0x8(%rsp), %r8
movl (%r8,%rdi,4), %r8d
imull 0x18(%r10), %r8d
movq 0x18(%rsp), %r9
movslq (%r9,%rdx,4), %r9
movslq %r8d, %r8
addq %r9, %r8
movl (%r13,%rdi,4), %r9d
addl (%rsi,%r8,4), %r9d
movl (%r14,%rdi,4), %r8d
cmpl %r8d, %r9d
cmovlel %r8d, %r9d
movl %r9d, 0x4(%rbx,%rdi,4)
incq %rdi
cmpq %rdi, %r12
jne 0x2a45ff
movl %edx, %esi
imull %ebp, %esi
addl %r15d, %esi
negl %esi
movl %esi, (%rbx)
testl %eax, %eax
jle 0x2a4692
movl $0xc0000000, %edi       # imm = 0xC0000000
xorl %r8d, %r8d
subl %ebp, %edi
movl (%rbx,%r8,4), %r9d
movl 0x4(%rbx,%r8,4), %r10d
cmpl %edi, %r9d
cmovgl %r9d, %edi
movl %edi, %r9d
subl %r15d, %r9d
cmpl %r9d, %r10d
cmovgl %r10d, %r9d
movl %r9d, 0x4(%r13,%r8,4)
incq %r8
cmpq %r8, %r12
jne 0x2a4666
movq %rax, %r9
testl %r9d, %r9d
setle %dil
movl %esi, (%r13)
cmpq (%rsp), %rdx
setne %sil
orb %dil, %sil
jne 0x2a46c8
xorl %esi, %esi
movl 0x4(%r13,%rsi,4), %edi
movq 0x10(%r11), %r8
movq 0x8(%r8), %r8
movl %edi, (%r8,%rsi,4)
incq %rsi
cmpq %rsi, %r12
jne 0x2a46af
movq 0x20(%rsp), %rax
movl (%r13,%rax,4), %esi
movq 0x10(%r11), %rdi
movq (%rdi), %rdi
movl %esi, (%rdi,%rdx,4)
incq %rdx
cmpq %rcx, %rdx
jne 0x2a45c4
decl %r9d
movq 0x20(%rsp), %rax
movl (%r13,%rax,4), %ecx
movl %ecx, (%r11)
movl %r9d, 0x4(%r11)
movq (%rsp), %rax
movl %eax, 0x8(%r11)
movq %rbx, %rdi
callq 0x2094b5
movq %r14, %rdi
callq 0x2094b5
movq %r13, %rdi
callq 0x2094b5
movq 0x18(%rsp), %rdi
callq 0x2094b5
movq 0x70(%rsp), %rax
cmpl $0x0, 0x30(%rax)
jne 0x2a473b
movq 0x8(%rsp), %rdi
callq 0x2094b5
movq 0x10(%rsp), %rax
jmp 0x2a47d9
movl $0x10, %edi
movq 0x20(%rsp), %rsi
callq 0x2094bf
testq %rax, %rax
je 0x2a47d7
movq (%rsp), %r9
testl %r9d, %r9d
movq 0x10(%rsp), %r11
movq 0x8(%rsp), %r10
movq 0x70(%rsp), %rsi
jle 0x2a47c1
movq 0x10(%rsi), %r8
xorl %ecx, %ecx
movq 0x18(%rsp), %rdi
movq 0x30(%rsp), %rsi
movzbl (%rsi,%rcx), %edx
movl (%r8,%rdx,4), %edx
movl %edx, (%rax,%rcx,4)
incq %rcx
cmpq %rcx, %r12
jne 0x2a4781
movq 0x70(%rsp), %rsi
jmp 0x2a4542
callq 0x1a1509
jmp 0x2a47d7
callq 0x1a14e3
jmp 0x2a47d7
callq 0x1a14bd
jmp 0x2a47d7
callq 0x1a1497
jmp 0x2a47d7
callq 0x1a1471
jmp 0x2a47d7
movq 0x18(%rsp), %rdi
jmp 0x2a4542
callq 0x1a144b
jmp 0x2a47d7
callq 0x1a1425
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq