// File: /workspace/github_c_makefile_star2_O2/nh13[P]ksw/src/parasail/src/nw.c
// Function: parasail_nw_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 F = 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
        | 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);
    H = parasail_memalign_int(16, s2Len+1);
    F = parasail_memalign_int(16, s2Len+1);

    /* validate heap variables */
    if (!s2) return NULL;
    if (!H) return NULL;
    if (!F) 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]];
    }

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

    /* 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 WH = -open - (i-1)*gap;
        int E = NEG_INF_32;
        H[0] = WH;
        for (j=1; j<=s2Len; ++j) {
            int H_dag;
            int E_opn;
            int E_ext;
            int F_opn;
            int F_ext;
            int NWH = NH;
            NH = H[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]];
            WH = MAX(H_dag, E);
            WH = MAX(WH, F[j]);
            H[j] = WH;
#ifdef PARASAIL_TABLE
            result->tables->score_table[1LL*(i-1)*s2Len + (j-1)] = WH;
#endif
        }
#ifdef PARASAIL_ROWCOL
        result->rowcols->score_col[i-1] = WH;
#endif
    }
#ifdef PARASAIL_ROWCOL
    for (j=1; j<=s2Len; ++j) {
        result->rowcols->score_row[j-1] = H[j];
    }
#endif

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

    parasail_free(F);
    parasail_free(H);
    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 $0x48, %rsp
testq %rdx, %rdx
je 0x247811
movl %ecx, %r14d
testl %ecx, %ecx
jle 0x247835
movl %r8d, %r12d
testl %r8d, %r8d
js 0x247859
movl %r9d, %r15d
testl %r9d, %r9d
js 0x24787d
movq 0x80(%rsp), %rax
testq %rax, %rax
je 0x24789e
movq %rdx, %r13
movq %rdi, %rbp
cmpl $0x0, 0x30(%rax)
je 0x247540
movl 0x34(%rax), %ebx
jmp 0x247553
testq %rbp, %rbp
je 0x2478bf
movl %esi, %ebx
testl %esi, %esi
jle 0x2478e0
movl %ebx, %edi
movl %r14d, %esi
callq 0x1ab93b
testq %rax, %rax
je 0x247906
movq %rbp, 0x38(%rsp)
movq %r13, 0x20(%rsp)
movl %ebx, 0xc(%rsp)
movq %rax, 0x10(%rsp)
orl $0x1440101, 0xc(%rax)   # imm = 0x1440101
movl %r14d, %esi
pushq $0x10
popq %rbx
movq %rbx, %rdi
movq %rsi, 0x30(%rsp)
callq 0x1ab76d
movq %rax, %r13
movq %r14, 0x40(%rsp)
leal 0x1(%r14), %ebp
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x1ab76d
movq %rax, %r14
movq %rbx, %rdi
movq %rbp, 0x28(%rsp)
movq %rbp, %rsi
callq 0x1ab76d
movq %rax, %rbx
testq %r13, %r13
sete %al
testq %r14, %r14
sete %cl
orb %al, %cl
testq %rbx, %rbx
sete %al
orb %cl, %al
jne 0x247906
movq 0x80(%rsp), %r8
cmpl $0x0, 0x30(%r8)
je 0x2477ad
movq $0x0, 0x18(%rsp)
movq 0x10(%rsp), %rdi
movq 0x20(%rsp), %r10
movq 0x10(%r8), %rax
xorl %ecx, %ecx
movq 0x28(%rsp), %rsi
cmpq %rcx, 0x30(%rsp)
je 0x247626
movzbl (%r10,%rcx), %edx
movl (%rax,%rdx,4), %edx
movl %edx, (%r13,%rcx,4)
incq %rcx
jmp 0x24760d
andl $0x0, (%r14)
movl $0xc0000000, (%rbx)     # imm = 0xC0000000
movl %r12d, %eax
negl %eax
pushq $0x1
popq %rcx
cmpq %rcx, %rsi
je 0x247650
movl %eax, (%r14,%rcx,4)
movl $0xc0000000, (%rbx,%rcx,4) # imm = 0xC0000000
incq %rcx
subl %r15d, %eax
jmp 0x247638
xorl %ecx, %ecx
movl 0xc(%rsp), %eax
testl %eax, %eax
cmovgl %eax, %ecx
incl %ecx
movq %rcx, 0x20(%rsp)
leaq -0x1(%rsi), %rcx
pushq $0x1
popq %rdx
cmpq 0x20(%rsp), %rdx
je 0x24773e
leaq -0x1(%rdx), %rsi
cmpl $0x0, 0x30(%r8)
movslq 0x18(%r8), %rax
je 0x24768c
imulq %rsi, %rax
movq %rax, %rdi
jmp 0x24769a
movq 0x18(%rsp), %rdi
movslq -0x4(%rdi,%rdx,4), %rdi
imulq %rax, %rdi
movq 0x8(%r8), %rax
leaq (%rax,%rdi,4), %rdi
movl (%r14), %r10d
imull %r15d, %esi
addl %r12d, %esi
negl %esi
movl %esi, (%r14)
movl $0xc0000000, %eax       # imm = 0xC0000000
xorl %r9d, %r9d
cmpq %r9, %rcx
je 0x247718
movl 0x4(%r14,%r9,4), %ebp
movl %ebp, %r11d
subl %r12d, %r11d
movl 0x4(%rbx,%r9,4), %r8d
subl %r15d, %r8d
cmpl %r8d, %r11d
cmovgl %r11d, %r8d
movl %r8d, 0x4(%rbx,%r9,4)
subl %r12d, %esi
subl %r15d, %eax
movl %esi, %r11d
cmpl %eax, %esi
jg 0x2476ed
movl %eax, %r11d
movslq (%r13,%r9,4), %rax
addl (%rdi,%rax,4), %r10d
cmpl %r11d, %r10d
cmovlel %r11d, %r10d
cmpl %r8d, %r10d
jg 0x247705
movl %r8d, %r10d
movl %r10d, %esi
movl %r10d, 0x4(%r14,%r9,4)
incq %r9
movl %ebp, %r10d
movl %r11d, %eax
jmp 0x2476b9
movq 0x10(%rsp), %rdi
movq 0x10(%rdi), %rax
movq 0x8(%rax), %rax
movl %esi, -0x4(%rax,%rdx,4)
incq %rdx
movq 0x80(%rsp), %r8
movq 0x28(%rsp), %rsi
jmp 0x247669
pushq $0x1
popq %rax
cmpq %rax, %rsi
je 0x24775a
movl (%r14,%rax,4), %ecx
movq 0x10(%rdi), %rdx
movq (%rdx), %rdx
movl %ecx, -0x4(%rdx,%rax,4)
incq %rax
jmp 0x247741
movq 0x30(%rsp), %rax
movl (%r14,%rax,4), %eax
movl %eax, (%rdi)
movl 0xc(%rsp), %eax
decl %eax
movl %eax, 0x4(%rdi)
movq 0x40(%rsp), %rax
decl %eax
movl %eax, 0x8(%rdi)
movq %rbx, %rdi
movq %r8, %rbx
callq 0x1ab763
movq %r14, %rdi
callq 0x1ab763
movq %r13, %rdi
callq 0x1ab763
cmpl $0x0, 0x30(%rbx)
jne 0x2477a3
movq 0x18(%rsp), %rdi
callq 0x1ab763
movq 0x10(%rsp), %rax
jmp 0x247908
movl 0xc(%rsp), %ebp
movslq %ebp, %rsi
pushq $0x10
popq %rdi
callq 0x1ab76d
xorl %r9d, %r9d
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x247906
testl %ebp, %ebp
movl $0x0, %ecx
cmovgl %ebp, %ecx
movq 0x10(%rsp), %rdi
movq 0x80(%rsp), %r8
movq 0x20(%rsp), %r10
movq 0x38(%rsp), %r11
movq 0x18(%rsp), %rax
cmpq %r9, %rcx
je 0x247602
movq 0x10(%r8), %rdx
movzbl (%r11,%r9), %esi
movl (%rdx,%rsi,4), %edx
movl %edx, (%rax,%r9,4)
incq %r9
jmp 0x2477f3
movq 0x4f37c0(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x37f7c9(%rip), %rsi    # 0x5c6feb
leaq 0x33e6ae(%rip), %rdx    # 0x585ed7
leaq 0x37fecd(%rip), %rcx    # 0x5c76fd
jmp 0x2478ff
movq 0x4f379c(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x37febb(%rip), %rsi    # 0x5c7701
leaq 0x33e68a(%rip), %rdx    # 0x585ed7
leaq 0x37fec1(%rip), %rcx    # 0x5c7715
jmp 0x2478ff
movq 0x4f3778(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x37feb1(%rip), %rsi    # 0x5c771b
leaq 0x33e666(%rip), %rdx    # 0x585ed7
leaq 0x37feb8(%rip), %rcx    # 0x5c7730
jmp 0x2478ff
movq 0x4f3754(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x37fe8d(%rip), %rsi    # 0x5c771b
leaq 0x33e642(%rip), %rdx    # 0x585ed7
leaq 0x37fe99(%rip), %rcx    # 0x5c7735
jmp 0x2478ff
movq 0x4f3733(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x37f73c(%rip), %rsi    # 0x5c6feb
leaq 0x33e621(%rip), %rdx    # 0x585ed7
leaq 0x380085(%rip), %rcx    # 0x5c7942
jmp 0x2478ff
movq 0x4f3712(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x37f71b(%rip), %rsi    # 0x5c6feb
leaq 0x33e600(%rip), %rdx    # 0x585ed7
leaq 0x37fe5b(%rip), %rcx    # 0x5c7739
jmp 0x2478ff
movq 0x4f36f1(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x37fe10(%rip), %rsi    # 0x5c7701
leaq 0x33e5df(%rip), %rdx    # 0x585ed7
leaq 0x37fe3e(%rip), %rcx    # 0x5c773d
xorl %eax, %eax
callq 0x19e180
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop