// File: /workspace/github_c_makefile_star2_O1/nh13[P]ksw/src/parasail/src/nw_stats.c
// Function: parasail_nw_stats_rowcol
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 H = NULL;
    int * restrict HM = NULL;
    int * restrict HS = NULL;
    int * restrict HL = NULL;
    int * restrict F = NULL;
    int * restrict FM = NULL;
    int * restrict FS = NULL;
    int * restrict FL = NULL;
    int i = 0;
    int j = 0;
    int s1Len = 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_PSSM) {
        PARASAIL_CHECK_NULL_PSSM_STATS(_s1);
    }
    else {
        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_table3(s1Len, s2Len);
#else
#ifdef PARASAIL_ROWCOL
    result = parasail_result_new_rowcol3(s1Len, s2Len);
#else
    result = parasail_result_new_stats();
#endif
#endif
    if (!result) return NULL;

    /* set known flags */
    result->flag |= PARASAIL_FLAG_NW | PARASAIL_FLAG_NOVEC
        | PARASAIL_FLAG_STATS
        | 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 */
    s1 = parasail_memalign_int(16, s1Len);
    s2 = parasail_memalign_int(16, s2Len);
    H = parasail_memalign_int(16, s2Len+1);
    HM = parasail_memalign_int(16, s2Len+1);
    HS = parasail_memalign_int(16, s2Len+1);
    HL = parasail_memalign_int(16, s2Len+1);
    F = parasail_memalign_int(16, s2Len+1);
    FM = parasail_memalign_int(16, s2Len+1);
    FS = parasail_memalign_int(16, s2Len+1);
    FL = parasail_memalign_int(16, s2Len+1);

    /* validate heap variables */
    if (!s1) return NULL;
    if (!s2) return NULL;
    if (!H) return NULL;
    if (!HM) return NULL;
    if (!HS) return NULL;
    if (!HL) return NULL;
    if (!F) return NULL;
    if (!FM) return NULL;
    if (!FS) return NULL;
    if (!FL) 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]];
    }

    /* upper left corner */
    H[0] = 0;
    HM[0] = 0;
    HS[0] = 0;
    HL[0] = 0;
    F[0] = NEG_INF_32;
    FM[0] = 0;
    FS[0] = 0;
    FL[0] = 0;
    
    /* first row */
    for (j=1; j<=s2Len; ++j) {
        H[j] = -open - (j-1)*gap;
        HM[j] = 0;
        HS[j] = 0;
        HL[j] = 0;
        F[j] = NEG_INF_32;
        FM[j] = 0;
        FS[j] = 0;
        FL[j] = 0;
    }

    /* iter over first sequence */
    for (i=1; i<=s1Len; ++i) {
        const int * const restrict matrow =
            matrix->type == PARASAIL_MATRIX_TYPE_SQUARE ?
            &matrix->matrix[matrix->size*s1[i-1]] :
            &matrix->matrix[matrix->size*(i-1)];
        /* init first column */
        int NH = H[0];
        int NHM = HM[0];
        int NHS = HS[0];
        int NHL = HL[0];
        int WH = -open - (i-1)*gap;
        int WHM = 0;
        int WHS = 0;
        int WHL = 0;
        int E = NEG_INF_32;
        int EM = 0;
        int ES = 0;
        int EL = 0;
        H[0] = WH;
        HM[0] = WHM;
        HS[0] = WHS;
        HL[0] = WHL;
        for (j=1; j<=s2Len; ++j) {
            int H_dag;
            int H_new;
            int E_opn;
            int E_ext;
            int F_opn;
            int F_ext;
            int NWH = NH;
            int NWM = NHM;
            int NWS = NHS;
            int NWL = NHL;
            NH = H[j];
            NHM = HM[j];
            NHS = HS[j];
            NHL = HL[j];
            F_opn = NH - open;
            F_ext  = F[j] - gap;
            F[j]  = MAX(F_opn, F_ext);
            E_opn = WH - open;
            E_ext = E - gap;
            E = MAX(E_opn, E_ext);
            H_dag = NWH + matrow[s2[j-1]];
            H_new = MAX(H_dag, E);
            H_new = MAX(H_new, F[j]);
            if (F_opn > F_ext) {
                FM[j] = NHM;
                FS[j] = NHS;
                FL[j] = NHL;
            }
            FL[j] += 1;
            if (E_opn > E_ext) {
                EM = WHM;
                ES = WHS;
                EL = WHL;
            }
            EL += 1;
            WH = H_new;
            if (H_new == H_dag) {
                WHM  = NWM + (s1[i-1] == s2[j-1]);
                WHS  = NWS + (matrow[s2[j-1]] > 0);
                WHL  = NWL + 1;
            }
            else if (H_new == F[j]) {
                WHM  = FM[j];
                WHS  = FS[j];
                WHL  = FL[j];
            }
            else {
                WHM  = EM;
                WHS  = ES;
                WHL  = EL;
            }
            H[j] = WH;
            HM[j] = WHM;
            HS[j] = WHS;
            HL[j] = WHL;
#ifdef PARASAIL_TABLE
            result->stats->tables->score_table[1LL*(i-1)*s2Len + (j-1)] = WH;
            result->stats->tables->matches_table[1LL*(i-1)*s2Len + (j-1)] = WHM;
            result->stats->tables->similar_table[1LL*(i-1)*s2Len + (j-1)] = WHS;
            result->stats->tables->length_table[1LL*(i-1)*s2Len + (j-1)] = WHL;
#endif
        }
#ifdef PARASAIL_ROWCOL
        result->stats->rowcols->score_col[i-1] = WH;
        result->stats->rowcols->matches_col[i-1] = WHM;
        result->stats->rowcols->similar_col[i-1] = WHS;
        result->stats->rowcols->length_col[i-1] = WHL;
#endif
    }
#ifdef PARASAIL_ROWCOL
    for (j=1; j<=s2Len; ++j) {
        result->stats->rowcols->score_row[j-1] = H[j];
        result->stats->rowcols->matches_row[j-1] = HM[j];
        result->stats->rowcols->similar_row[j-1] = HS[j];
        result->stats->rowcols->length_row[j-1] = HL[j];
    }
#endif

    result->score = H[s2Len];
    result->end_query = s1Len-1;
    result->end_ref = s2Len-1;
    result->stats->matches = HM[s2Len];
    result->stats->similar = HS[s2Len];
    result->stats->length = HL[s2Len];

    parasail_free(FL);
    parasail_free(FS);
    parasail_free(FM);
    parasail_free(F);
    parasail_free(HL);
    parasail_free(HS);
    parasail_free(HM);
    parasail_free(H);
    parasail_free(s2);
    parasail_free(s1);

    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movl %r8d, 0xc(%rsp)
testq %rdx, %rdx
je 0x2a5b10
movl %ecx, %ebx
testl %ecx, %ecx
jle 0x2a5b17
cmpl $0x0, 0xc(%rsp)
js 0x2a5b1e
movl %r9d, %ebp
testl %r9d, %r9d
js 0x2a5b25
movq 0x110(%rsp), %rcx
testq %rcx, %rcx
je 0x2a5b2c
movl %esi, %r14d
movq %rdi, %r15
movl 0x30(%rcx), %eax
cmpl $0x1, %eax
jne 0x2a543e
testq %r15, %r15
jne 0x2a5450
callq 0x1a178f
jmp 0x2a5b3f
testq %r15, %r15
je 0x2a5b33
testl %r14d, %r14d
jle 0x2a5b3a
movq %rdx, 0x20(%rsp)
testl %eax, %eax
je 0x2a545d
movl 0x34(%rcx), %r14d
movl %r14d, %edi
movl %ebx, %esi
callq 0x20985a
testq %rax, %rax
je 0x2a5b3f
movq %r14, %rcx
movq %rax, %r14
movq %r15, 0x68(%rsp)
orl $0x1450101, 0xc(%rax)   # imm = 0x1450101
movq %rcx, 0x18(%rsp)
movslq %ecx, %rsi
movl $0x10, %edi
callq 0x2094bf
movq %rax, 0x10(%rsp)
movl %ebx, %esi
movl $0x10, %edi
movq %rsi, 0xb8(%rsp)
callq 0x2094bf
movq %rax, %r12
movq %rbx, 0x78(%rsp)
leal 0x1(%rbx), %r15d
movl $0x10, %edi
movq %r15, %rsi
callq 0x2094bf
movq %rax, 0x88(%rsp)
movl $0x10, %edi
movq %r15, %rsi
callq 0x2094bf
movq %rax, 0x70(%rsp)
movl $0x10, %edi
movq %r15, %rsi
callq 0x2094bf
movq %rax, 0x50(%rsp)
movl $0x10, %edi
movq %r15, %rsi
callq 0x2094bf
movq %rax, %rbx
movl $0x10, %edi
movq %r15, %rsi
callq 0x2094bf
movq %rax, %r13
movl $0x10, %edi
movq %r15, %rsi
callq 0x2094bf
movq %rax, 0x48(%rsp)
movl $0x10, %edi
movq %r15, %rsi
callq 0x2094bf
movq %rax, 0x40(%rsp)
movl $0x10, %edi
movq %r15, %rsi
callq 0x2094bf
movq 0x50(%rsp), %rsi
movq 0x70(%rsp), %r9
movq 0x88(%rsp), %rdi
cmpq $0x0, 0x10(%rsp)
sete %dl
movq %r12, 0x60(%rsp)
testq %r12, %r12
sete %cl
orb %dl, %cl
testq %rdi, %rdi
sete %r8b
testq %r9, %r9
sete %dl
orb %r8b, %dl
orb %cl, %dl
testq %rsi, %rsi
sete %r8b
movq %rbx, 0x80(%rsp)
testq %rbx, %rbx
movq 0x48(%rsp), %r12
sete %cl
orb %r8b, %cl
movq %r13, 0x58(%rsp)
testq %r13, %r13
movq 0x40(%rsp), %r13
sete %r8b
orb %cl, %r8b
orb %dl, %r8b
testq %r12, %r12
sete %cl
testq %r13, %r13
sete %dl
orb %cl, %dl
testq %rax, %rax
sete %cl
orb %dl, %cl
orb %r8b, %cl
testb $0x1, %cl
jne 0x2a5b3f
movq %r9, %r10
movq %rax, 0xb0(%rsp)
cmpl $0x0, 0x18(%rsp)
movq 0x110(%rsp), %r8
movq 0x68(%rsp), %r9
movq 0x10(%rsp), %r11
jle 0x2a5615
movq 0x10(%r8), %rax
movl 0x18(%rsp), %ecx
xorl %edx, %edx
movzbl (%r9,%rdx), %esi
movl (%rax,%rsi,4), %esi
movl %esi, (%r11,%rdx,4)
incq %rdx
cmpq %rdx, %rcx
jne 0x2a5601
movq 0x10(%r8), %rax
movq 0x78(%rsp), %rcx
cmpl $0x2, %ecx
movl $0x1, %r15d
cmovgel %ecx, %r15d
xorl %ecx, %ecx
movq 0x58(%rsp), %rbx
movq 0x20(%rsp), %rsi
movq 0x60(%rsp), %r9
movzbl (%rsi,%rcx), %edx
movl (%rax,%rdx,4), %edx
movl %edx, (%r9,%rcx,4)
incq %rcx
cmpq %rcx, %r15
jne 0x2a563c
xorl %eax, %eax
movl %eax, (%rdi)
movl %eax, (%r10)
movq 0x50(%rsp), %rsi
movl %eax, (%rsi)
movq 0x80(%rsp), %r9
movl %eax, (%r9)
movl $0xc0000000, (%rbx)     # imm = 0xC0000000
movl %eax, (%r12)
movl %eax, (%r13)
movq 0xb0(%rsp), %r11
movl %eax, (%r11)
movl 0xc(%rsp), %ecx
negl %ecx
shlq $0x2, %r15
xorl %edx, %edx
movl %ecx, 0x4(%rdi,%rdx)
movl %eax, 0x4(%r10,%rdx)
movl %eax, 0x4(%rsi,%rdx)
movl %eax, 0x4(%r9,%rdx)
movl $0xc0000000, 0x4(%rbx,%rdx) # imm = 0xC0000000
movl %eax, 0x4(%r12,%rdx)
movl %eax, 0x4(%r13,%rdx)
movl %eax, 0x4(%r11,%rdx)
subl %ebp, %ecx
addq $0x4, %rdx
cmpq %rdx, %r15
jne 0x2a568d
movq %r15, 0xd0(%rsp)
cmpl $0x0, 0x18(%rsp)
movq %r9, %r12
movq %r11, %r13
movq 0x10(%rsp), %rdx
movq %r10, %r15
jle 0x2a59fd
movq 0x18(%rsp), %rax
incl %eax
movq %rax, 0xc0(%rsp)
movl $0x1, %ecx
movq %r14, 0xc8(%rsp)
movl %ebp, 0x2c(%rsp)
cmpl $0x0, 0x30(%r8)
je 0x2a5713
movslq 0x18(%r8), %rax
leaq -0x1(%rcx), %rdx
jmp 0x2a571c
movslq 0x18(%r8), %rax
movslq -0x4(%rdx,%rcx,4), %rdx
imulq %rax, %rdx
shlq $0x2, %rdx
addq 0x8(%r8), %rdx
movq %rdx, 0x90(%rsp)
movl (%rdi), %r8d
movl (%r15), %eax
movl %eax, 0x68(%rsp)
movl (%rsi), %r14d
movl (%r12), %eax
movq %rcx, 0xa8(%rsp)
leal -0x1(%rcx), %edx
imull %ebp, %edx
addl 0xc(%rsp), %edx
negl %edx
movl %edx, (%rdi)
xorl %r9d, %r9d
movl %r9d, (%r15)
movl %r9d, (%rsi)
movl %r9d, (%r12)
movl $0xc0000000, 0x70(%rsp) # imm = 0xC0000000
movl $0x0, 0x38(%rsp)
movl $0x0, 0x34(%rsp)
movl $0x0, 0x30(%rsp)
movl $0x0, 0x20(%rsp)
xorl %r10d, %r10d
xorl %ebx, %ebx
movl %r10d, 0xa4(%rsp)
movl 0x68(%rsp), %ecx
movl %ecx, 0xa0(%rsp)
movl %r14d, 0x9c(%rsp)
movl %eax, 0x98(%rsp)
movl 0x4(%rdi,%r9), %ebp
movq %r15, %r11
movl 0x4(%r15,%r9), %eax
movl 0x4(%rsi,%r9), %r14d
movl %ebp, 0x3c(%rsp)
movl 0xc(%rsp), %edi
subl %edi, %ebp
movq 0x58(%rsp), %rcx
movl 0x4(%rcx,%r9), %esi
movl 0x2c(%rsp), %r10d
subl %r10d, %esi
cmpl %esi, %ebp
movl %esi, %r13d
cmovgl %ebp, %r13d
movl 0x4(%r12,%r9), %r12d
movl %r13d, 0x4(%rcx,%r9)
movl %edx, %ecx
subl %edi, %ecx
movl 0x70(%rsp), %edi
subl %r10d, %edi
movl %ecx, %r15d
cmpl %edi, %ecx
jg 0x2a5809
movl %edi, %r15d
movq 0x60(%rsp), %rdx
movslq (%rdx,%r9), %rdx
movq 0x90(%rsp), %r10
addl (%r10,%rdx,4), %r8d
cmpl %r15d, %r8d
movl %r15d, 0x70(%rsp)
movl %r15d, %edx
cmovgl %r8d, %edx
cmpl %r13d, %edx
jg 0x2a5835
movl %r13d, %edx
cmpl %esi, %ebp
movq 0xb0(%rsp), %r13
movl %eax, %r10d
movl %r12d, %eax
movl 0xa4(%rsp), %r15d
jle 0x2a5868
movq 0x48(%rsp), %rsi
movl %r10d, 0x4(%rsi,%r9)
movq 0x40(%rsp), %rsi
movl %r14d, 0x4(%rsi,%r9)
movl %eax, 0x4(%r13,%r9)
movl 0x4(%r13,%r9), %ebp
incl %ebp
movl %ebp, 0x4(%r13,%r9)
cmpl %edi, %ecx
movl 0x20(%rsp), %ecx
jg 0x2a5889
movl 0x30(%rsp), %ebx
movl 0x34(%rsp), %r15d
movl 0x38(%rsp), %ecx
movl %r10d, 0x68(%rsp)
incl %ecx
cmpl %r8d, %edx
movl %ecx, 0x38(%rsp)
movl %r15d, 0x34(%rsp)
movl %ebx, 0x30(%rsp)
jne 0x2a5910
movq 0x60(%rsp), %rcx
movslq (%rcx,%r9), %rcx
xorl %esi, %esi
movq 0x10(%rsp), %rdi
movq 0xa8(%rsp), %r8
cmpl %ecx, -0x4(%rdi,%r8,4)
sete %sil
movl 0xa0(%rsp), %r15d
addl %esi, %r15d
xorl %esi, %esi
movq 0x90(%rsp), %rdi
cmpl $0x0, (%rdi,%rcx,4)
setg %sil
movl 0x9c(%rsp), %r10d
addl %esi, %r10d
movl 0x98(%rsp), %ecx
incl %ecx
movq 0x88(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq 0x80(%rsp), %r12
movl 0x3c(%rsp), %r8d
jmp 0x2a5956
movl %r15d, %r10d
movl %ebx, %r15d
movl %ecx, %esi
movq 0x58(%rsp), %rcx
cmpl 0x4(%rcx,%r9), %edx
movl %esi, %ecx
movq 0x88(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq 0x80(%rsp), %r12
movl 0x3c(%rsp), %r8d
jne 0x2a5956
movq 0x48(%rsp), %rcx
movl 0x4(%rcx,%r9), %r15d
movq 0x40(%rsp), %rcx
movl 0x4(%rcx,%r9), %r10d
movl %ebp, %ecx
movl %edx, 0x4(%rdi,%r9)
movl %r15d, %ebx
movl %r15d, 0x4(%r11,%r9)
movq %r11, %r15
movl %r10d, 0x4(%rsi,%r9)
movl %ecx, 0x20(%rsp)
movl %ecx, 0x4(%r12,%r9)
addq $0x4, %r9
cmpq %r9, 0xd0(%rsp)
jne 0x2a5791
movq 0xc8(%rsp), %r14
movq 0x10(%r14), %rax
movq 0x10(%rax), %rax
movq 0x20(%rax), %rax
movq 0xa8(%rsp), %rcx
movl %edx, -0x4(%rax,%rcx,4)
movq 0x10(%r14), %rax
movq 0x10(%rax), %rax
movq 0x28(%rax), %rax
movl %ebx, -0x4(%rax,%rcx,4)
movq 0x10(%r14), %rax
movq 0x10(%rax), %rax
movq 0x30(%rax), %rax
movl %r10d, -0x4(%rax,%rcx,4)
movq 0x10(%r14), %rax
movq 0x10(%rax), %rax
movq 0x38(%rax), %rax
movl 0x20(%rsp), %edx
movl %edx, -0x4(%rax,%rcx,4)
incq %rcx
cmpq 0xc0(%rsp), %rcx
movq 0x10(%rsp), %rdx
movl 0x2c(%rsp), %ebp
movq 0x110(%rsp), %r8
jne 0x2a5702
movq %r12, %rbx
movq 0x78(%rsp), %rcx
cmpl $0x2, %ecx
movl $0x1, %eax
cmovgel %ecx, %eax
shlq $0x2, %rax
xorl %ecx, %ecx
movq %rsi, %rbp
movl 0x4(%rdi,%rcx), %edx
movq 0x10(%r14), %rsi
movq 0x10(%rsi), %rsi
movq (%rsi), %rsi
movl %edx, (%rsi,%rcx)
movl 0x4(%r15,%rcx), %edx
movq 0x10(%r14), %rsi
movq 0x10(%rsi), %rsi
movq 0x8(%rsi), %rsi
movl %edx, (%rsi,%rcx)
movl 0x4(%rbp,%rcx), %edx
movq 0x10(%r14), %rsi
movq 0x10(%rsi), %rsi
movq 0x10(%rsi), %rsi
movl %edx, (%rsi,%rcx)
movl 0x4(%rbx,%rcx), %edx
movq 0x10(%r14), %rsi
movq 0x10(%rsi), %rsi
movq 0x18(%rsi), %rsi
movl %edx, (%rsi,%rcx)
addq $0x4, %rcx
cmpq %rcx, %rax
jne 0x2a5a19
movq 0xb8(%rsp), %rdx
movl (%rdi,%rdx,4), %eax
movl %eax, (%r14)
movq 0x18(%rsp), %rax
decl %eax
movl %eax, 0x4(%r14)
movq 0x78(%rsp), %rax
decl %eax
movl %eax, 0x8(%r14)
movl (%r15,%rdx,4), %eax
movq 0x10(%r14), %rcx
movl %eax, (%rcx)
movl (%rbp,%rdx,4), %eax
movq 0x10(%r14), %rcx
movl %eax, 0x4(%rcx)
movl (%rbx,%rdx,4), %eax
movq 0x10(%r14), %rcx
movl %eax, 0x8(%rcx)
movq %rdi, %r12
movq %r13, %rdi
callq 0x2094b5
movq 0x40(%rsp), %rdi
callq 0x2094b5
movq 0x48(%rsp), %rdi
callq 0x2094b5
movq 0x58(%rsp), %rdi
callq 0x2094b5
movq %rbx, %rdi
callq 0x2094b5
movq %rbp, %rdi
callq 0x2094b5
movq %r15, %rdi
callq 0x2094b5
movq %r12, %rdi
callq 0x2094b5
movq 0x60(%rsp), %rdi
callq 0x2094b5
movq 0x10(%rsp), %rdi
callq 0x2094b5
jmp 0x2a5b42
callq 0x1a1846
jmp 0x2a5b3f
callq 0x1a1820
jmp 0x2a5b3f
callq 0x1a17fa
jmp 0x2a5b3f
callq 0x1a17d4
jmp 0x2a5b3f
callq 0x1a17ae
jmp 0x2a5b3f
callq 0x1a1769
jmp 0x2a5b3f
callq 0x1a1743
xorl %r14d, %r14d
movq %r14, %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop