// File: /workspace/github_c_makefile_star2_O3/nh13[P]ksw/src/parasail/src/nw_trace_scan.c
// Function: parasail_nw_trace_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;
    int8_t * restrict HT = NULL;
    int * restrict Ex = 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_SQUARE) {
        PARASAIL_CHECK_NULL(_s1);
        PARASAIL_CHECK_GT0(_s1Len);
    }

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

    /* initialize result */
    result = parasail_result_new_trace(s1Len, s2Len, 16, sizeof(int8_t));
    if (!result) return NULL;

    /* set known flags */
    result->flag |= PARASAIL_FLAG_NW | PARASAIL_FLAG_NOVEC_SCAN
        | PARASAIL_FLAG_TRACE
        | PARASAIL_FLAG_BITS_INT | PARASAIL_FLAG_LANES_1;

    /* 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;
    HT = (int8_t* const restrict)result->trace->trace_table;
    Ex = parasail_memalign_int(16, s1Len);

    /* validate heap variables */
    if (!s2) return NULL;
    if (!HB) return NULL;
    if (!E) return NULL;
    if (!HtB) return NULL;
    if (!HT) return NULL;
    if (!Ex) 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) {
            int E_opn = H[i]-open;
            int E_ext = E[i]-gap;
            E[i] = MAX(E_ext, E_opn);
            HT[1LL*i*s2Len + j] = (E_opn > E_ext) ? PARASAIL_DIAG_E
                                                  : PARASAIL_INS_E;
        }
        /* 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]];
            int H_dag = H[i-1]+matval;
            Ht[i] = MAX(H_dag, E[i]);
            Ex[i] = (E[i] > H_dag);
        }
        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;
            if (H[i-1] > Ft_ext) {
                HT[1LL*i*s2Len + j] |= PARASAIL_DIAG_F;
            }
            else {
                HT[1LL*i*s2Len + j] |= PARASAIL_DEL_F;
            }
            if (Ht[i] > Ft_opn) {
                H[i] = Ht[i];
                HT[1LL*i*s2Len + j] |= Ex[i] ? PARASAIL_INS : PARASAIL_DIAG;
            }
            else {
                H[i] = Ft_opn;
                if (Ht[i] == Ft_opn) {
                    if (Ex[i]) {
                        HT[1LL*i*s2Len + j] |= PARASAIL_DEL;
                    }
                    else {
                        HT[1LL*i*s2Len + j] |= PARASAIL_DIAG;
                    }
                }
                else {
                    HT[1LL*i*s2Len + j] |= PARASAIL_DEL;
                }
            }
        }
        H[-1] = -open - j*gap;
    }

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

    parasail_free(Ex);
    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 $0x68, %rsp
movq %r9, 0x28(%rsp)
testq %rdx, %rdx
je 0x2acea6
movl %ecx, %r15d
testl %ecx, %ecx
jle 0x2acead
movl %r8d, %ebp
testl %r8d, %r8d
js 0x2aceb4
cmpl $0x0, 0x28(%rsp)
js 0x2acebb
movq 0xa0(%rsp), %rax
testq %rax, %rax
je 0x2acec2
movq %rdi, %rbx
cmpl $0x0, 0x30(%rax)
je 0x2ac90e
movl 0x34(%rax), %r8d
jmp 0x2ac922
testq %rbx, %rbx
je 0x2aced8
movl %esi, %r8d
testl %esi, %esi
jle 0x2acedf
movq %rdx, 0x40(%rsp)
movl $0x10, %edx
movl $0x1, %ecx
movl %r8d, %edi
movl %r15d, %esi
movq %r8, %r14
callq 0x20adf4
testq %rax, %rax
je 0x2acee4
movq %rbx, 0x50(%rsp)
orl $0x1480201, 0xc(%rax)   # imm = 0x1480201
movl %r15d, 0x34(%rsp)
movl %r15d, %ebx
movl $0x10, %edi
movq %rbx, %rsi
movq %rax, 0x48(%rsp)
callq 0x20a617
movq %rax, 0x8(%rsp)
leal 0x1(%r14), %eax
movq %rax, 0x58(%rsp)
movslq %eax, %r13
movl $0x10, %edi
movq %r13, %rsi
callq 0x20a617
movq %rax, %r12
movq %r14, (%rsp)
movslq %r14d, %r15
movl $0x10, %edi
movq %r15, %rsi
callq 0x20a617
movq %rax, %r14
movl $0x10, %edi
movq %r13, %rsi
callq 0x20a617
movq %rax, %r13
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq %rax, 0x20(%rsp)
movl $0x10, %edi
movq %r15, 0x38(%rsp)
movq %r15, %rsi
callq 0x20a617
movq 0x8(%rsp), %r9
movq %rax, 0x18(%rsp)
movq %r9, %xmm0
movq %r12, %xmm1
punpcklqdq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]
movq %r14, %xmm1
movq %r13, %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, %ecx
xorl %eax, %eax
testl %ecx, %ecx
jne 0x2acee6
movq 0x20(%rsp), %rsi
testq %rsi, %rsi
je 0x2acee6
cmpq $0x0, 0x18(%rsp)
je 0x2acee6
movq 0xa0(%rsp), %r10
cmpl $0x0, 0x30(%r10)
movl (%rsp), %r15d
je 0x2ace31
xorl %eax, %eax
movq 0x28(%rsp), %r8
movq 0x40(%rsp), %r11
movq 0x10(%r10), %rdi
xorl %ecx, %ecx
movzbl (%r11,%rcx), %edx
movl (%rdi,%rdx,4), %edx
movl %edx, (%r9,%rcx,4)
incq %rcx
cmpq %rcx, %rbx
jne 0x2aca6a
xorl %ecx, %ecx
movl %ecx, (%r12)
movl %ecx, (%r13)
cmpl $0x0, (%rsp)
movq %rax, 0x10(%rsp)
jle 0x2acc30
leaq -0x1(%r15), %rax
movq %rax, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movq 0x58(%rsp), %r11
shrl %r11d
shlq $0x3, %r11
movl %r8d, %eax
negl %eax
movl %ebp, %ecx
negl %ecx
leal (%r8,%r8), %edx
movdqa 0x37c3ca(%rip), %xmm2   # 0x628e90
xorl %esi, %esi
movdqa 0x37c3d0(%rip), %xmm1   # 0x628ea0
pxor %xmm1, %xmm0
pcmpeqd %xmm3, %xmm3
movdqa 0x37c410(%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 0x2acb17
movl %ecx, 0x4(%r12,%rsi)
pxor %xmm3, %xmm5
pextrw $0x4, %xmm5, %edi
testb $0x1, %dil
je 0x2acb2e
leal (%rax,%rcx), %edi
movl %edi, 0x8(%r12,%rsi)
paddq %xmm4, %xmm2
addq $0x8, %rsi
subl %edx, %ecx
cmpq %rsi, %r11
jne 0x2acae0
cmpl $0x0, (%rsp)
movq 0x20(%rsp), %rsi
jle 0x2acc30
leal 0x3(%r15), %eax
shrl $0x2, %eax
shlq $0x4, %rax
movdqa 0x37c321(%rip), %xmm2   # 0x628e80
movdqa 0x37c329(%rip), %xmm3   # 0x628e90
xorl %ecx, %ecx
pcmpeqd %xmm4, %xmm4
movdqa 0x37c33b(%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 0x2acbb1
movl $0xc0000000, (%r14,%rcx) # imm = 0xC0000000
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x2acbc8
movl $0xc0000000, 0x4(%r14,%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 0x2acc08
movl $0xc0000000, 0x8(%r14,%rcx) # imm = 0xC0000000
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x2acc1b
movl $0xc0000000, 0xc(%r14,%rcx) # imm = 0xC0000000
paddq %xmm5, %xmm3
paddq %xmm5, %xmm2
addq $0x10, %rcx
cmpq %rcx, %rax
jne 0x2acb75
xorl %eax, %eax
cmpl $0x0, (%rsp)
jle 0x2acda3
movq %rsi, %r11
movq %rsi, %rcx
xorl %edx, %edx
movl 0x4(%r12,%rdx,4), %esi
subl %ebp, %esi
movl (%r14,%rdx,4), %edi
subl %r8d, %edi
cmpl %esi, %edi
cmovlel %esi, %edi
movl %edi, (%r14,%rdx,4)
setge %sil
shlb $0x3, %sil
addb $0x8, %sil
movb %sil, (%rcx)
incq %rdx
addq %rbx, %rcx
cmpq %rdx, %r15
jne 0x2acc44
cmpl $0x0, (%rsp)
movq %r11, %rsi
jle 0x2acda3
movq 0x8(%r10), %rcx
xorl %edx, %edx
cmpl $0x0, 0x30(%r10)
movl 0x18(%r10), %esi
je 0x2acc98
imull %edx, %esi
jmp 0x2acca1
movq 0x10(%rsp), %rdi
imull (%rdi,%rdx,4), %esi
movslq (%r9,%rax,4), %rdi
movslq %esi, %rsi
addq %rdi, %rsi
movl (%r12,%rdx,4), %edi
addl (%rcx,%rsi,4), %edi
movl (%r14,%rdx,4), %esi
cmpl %esi, %edi
cmovgl %edi, %esi
movl %esi, 0x4(%r13,%rdx,4)
xorl %esi, %esi
cmpl %edi, (%r14,%rdx,4)
setg %sil
movq 0x18(%rsp), %rdi
movl %esi, (%rdi,%rdx,4)
incq %rdx
cmpq %rdx, %r15
jne 0x2acc88
movl %eax, %ecx
imull %r8d, %ecx
addl %ebp, %ecx
negl %ecx
movl %ecx, (%r13)
cmpl $0x0, (%rsp)
jle 0x2acd9e
movl $0xc0000000, %edi       # imm = 0xC0000000
movq %r11, %rdx
xorl %esi, %esi
movl %edi, %r9d
movl (%r13,%rsi,4), %edi
subl %r8d, %r9d
cmpl %r9d, %edi
cmovlel %r9d, %edi
movl %edi, %r8d
subl %ebp, %r8d
cmpl %r9d, (%r12,%rsi,4)
setle %r9b
shlb $0x5, %r9b
addb $0x20, %r9b
orb %r9b, (%rdx)
movl 0x4(%r13,%rsi,4), %r9d
cmpl %r8d, %r9d
jle 0x2acd53
movl %r9d, 0x4(%r12,%rsi,4)
xorl %r8d, %r8d
movq 0x18(%rsp), %r9
cmpl $0x0, (%r9,%rsi,4)
sete %r8b
leal (%r8,%r8,2), %r8d
incl %r8d
orb %r8b, (%rdx)
jmp 0x2acd7c
movl %r8d, 0x4(%r12,%rsi,4)
cmpl %r8d, 0x4(%r13,%rsi,4)
jne 0x2acd79
movq 0x18(%rsp), %r8
cmpl $0x0, (%r8,%rsi,4)
movb (%rdx), %r8b
movq 0x8(%rsp), %r9
je 0x2acd83
orb $0x2, %r8b
jmp 0x2acd87
orb $0x2, (%rdx)
movq 0x8(%rsp), %r9
jmp 0x2acd8a
orb $0x4, %r8b
movb %r8b, (%rdx)
incq %rsi
addq %rbx, %rdx
cmpq %rsi, %r15
movq 0x28(%rsp), %r8
jne 0x2accfc
movq %r11, %rsi
jmp 0x2acdb1
movl %eax, %ecx
imull %r8d, %ecx
addl %ebp, %ecx
negl %ecx
movl %ecx, (%r13)
movl %ecx, (%r12)
incq %rax
incq %rsi
cmpq %rbx, %rax
jne 0x2acc32
movq (%rsp), %rcx
decl %ecx
movq 0x38(%rsp), %rax
movl (%r12,%rax,4), %eax
movq 0x48(%rsp), %r15
movl %eax, (%r15)
movl %ecx, 0x4(%r15)
movl 0x34(%rsp), %eax
decl %eax
movl %eax, 0x8(%r15)
movq 0x18(%rsp), %rdi
movq %r10, %rbx
movq %r9, %rbp
callq 0x20a60d
movq %r13, %rdi
callq 0x20a60d
movq %r14, %rdi
callq 0x20a60d
movq %r12, %rdi
callq 0x20a60d
movq %rbp, %rdi
callq 0x20a60d
cmpl $0x0, 0x30(%rbx)
jne 0x2ace29
movq 0x10(%rsp), %rdi
callq 0x20a60d
movq %r15, %rax
jmp 0x2acee6
movl $0x10, %edi
movq 0x38(%rsp), %rsi
callq 0x20a617
testq %rax, %rax
je 0x2acee4
cmpl $0x0, (%rsp)
movq 0x28(%rsp), %r8
movq 0x40(%rsp), %r11
movq 0xa0(%rsp), %r10
jle 0x2acec9
movq %rax, 0x10(%rsp)
movq 0x10(%r10), %rax
movq %rax, 0x60(%rsp)
xorl %ecx, %ecx
movq 0x8(%rsp), %r9
movq 0x20(%rsp), %rsi
movq 0x50(%rsp), %rdi
movzbl (%rdi,%rcx), %edx
movq 0x60(%rsp), %rax
movl (%rax,%rdx,4), %edx
movq 0x10(%rsp), %rax
movl %edx, (%rax,%rcx,4)
incq %rcx
cmpq %rcx, %r15
jne 0x2ace80
movq 0x10(%rsp), %rax
jmp 0x2aca64
callq 0x1a222f
jmp 0x2acee4
callq 0x1a2209
jmp 0x2acee4
callq 0x1a21e3
jmp 0x2acee4
callq 0x1a21bd
jmp 0x2acee4
callq 0x1a2197
jmp 0x2acee4
movq 0x8(%rsp), %r9
movq 0x20(%rsp), %rsi
jmp 0x2aca64
callq 0x1a2171
jmp 0x2acee4
callq 0x1a214b
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)