// File: /workspace/github_c_makefile_star2_O0/nh13[P]ksw/src/parasail/src/pssw.c
// Function: parasail_ssw_profile
parasail_result_ssw_t* parasail_ssw_profile(
        const parasail_profile_t * const restrict profile,
        const char * const restrict s2, const int s2Len_,
        const int open, const int gap)
{
    const char *s1 = profile->s1;
    const parasail_matrix_t *matrix = profile->matrix;
    parasail_result_t *result_forward = NULL;
    parasail_result_t *result_reverse = NULL;
    parasail_result_t *result_final = NULL;
    parasail_result_ssw_t *result_ssw = NULL;
    int has8 = 0;
    int has16 = 0;
    char *s1_reverse = NULL;
    char *s2_reverse = NULL;
    int s1Len = 0;
    int s2Len = 0;
    int s1Off = 0;
    int s2Off = 0;
    parasail_cigar_t *cigar = NULL;

    /* find the end loc first with the faster implementation */
    has8 = (NULL != profile->profile8.score);
    has16 = (NULL != profile->profile16.score);

    /* find the end loc first with the faster implementation */
    if (has8) {
        result_forward = parasail_sw_striped_profile_8(profile, s2, s2Len_, open, gap);
        if (parasail_result_is_saturated(result_forward)) {
            has8 = 0;
            parasail_result_free(result_forward);
            result_forward = NULL;
        }
    }
    if (NULL == result_forward && has16) {
        result_forward = parasail_sw_striped_profile_16(profile, s2, s2Len_, open, gap);
        if (parasail_result_is_saturated(result_forward)) {
            parasail_result_free(result_forward);
            result_forward = NULL;
        }
    }
    /* 8- and/or 16-bit options could fail */
    if (NULL == result_forward) {
        return NULL;
    }

    /* find beginning loc by going in reverse */
    s1Len = result_forward->end_query+1;
    s2Len = result_forward->end_ref+1;
    s1_reverse = parasail_reverse(s1, s1Len);
    s2_reverse = parasail_reverse(s2, s2Len);
    if (has8) {
        result_reverse = parasail_sw_striped_8(
                s1_reverse, s1Len,
                s2_reverse, s2Len,
                open, gap, matrix);
        if (parasail_result_is_saturated(result_reverse)) {
            has8 = 0;
            parasail_result_free(result_reverse);
            result_reverse = NULL;
        }
    }
    if (NULL == result_reverse && has16) {
        result_reverse = parasail_sw_striped_16(
                s1_reverse, s1Len,
                s2_reverse, s2Len,
                open, gap, matrix);
        if (parasail_result_is_saturated(result_reverse)) {
            parasail_result_free(result_reverse);
            result_reverse = NULL;
        }
    }
    free(s2_reverse);
    free(s1_reverse);

    /* 8- and/or 16-bit options could fail */
    if (NULL == result_reverse) {
        parasail_result_free(result_forward); /* free the forward result */
        return NULL;
    }

    /* run trace version of sw on just the aligned portion */
    s1Off = result_forward->end_query - result_reverse->end_query;
    s2Off = result_forward->end_ref - result_reverse->end_ref;
    s1Len = result_reverse->end_query+1;
    s2Len = result_reverse->end_ref+1;
    if (has8) {
        result_final = parasail_sw_trace_striped_8(
                &s1[s1Off], s1Len,
                &s2[s2Off], s2Len,
                open, gap, matrix);
        if (parasail_result_is_saturated(result_final)) {
            has8 = 0;
            parasail_result_free(result_final);
            result_final = NULL;
        }
    }
    if (NULL == result_final && has16) {
        result_final = parasail_sw_trace_striped_16(
                &s1[s1Off], s1Len,
                &s2[s2Off], s2Len,
                open, gap, matrix);
        if (parasail_result_is_saturated(result_final)) {
            parasail_result_free(result_final);
            result_final = NULL;
        }
    }

    /* 8- and/or 16-bit options could fail */
    if (NULL == result_final) {
        parasail_result_free(result_reverse); /* free reverse result */
        parasail_result_free(result_forward); /* free forward result */
        return NULL;
    }

    /* get cigar from traceback */
    cigar = parasail_result_get_cigar(result_final,
            &s1[s1Off], s1Len,
            &s2[s2Off], s2Len,
            matrix);

    result_ssw = (parasail_result_ssw_t*)malloc(sizeof(parasail_result_ssw_t));
    result_ssw->score1 = result_forward->score;
    result_ssw->ref_begin1 = s2Off;
    result_ssw->ref_end1 = result_forward->end_ref;
    result_ssw->read_begin1 = s1Off;
    result_ssw->read_end1 = result_forward->end_query;
    result_ssw->cigar = cigar->seq;
    result_ssw->cigarLen = cigar->len;

    free(cigar);
    parasail_result_free(result_final);
    parasail_result_free(result_reverse);
    parasail_result_free(result_forward);

    return result_ssw;;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
movl $0x0, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movl $0x0, -0x74(%rbp)
movl $0x0, -0x78(%rbp)
movl $0x0, -0x7c(%rbp)
movl $0x0, -0x80(%rbp)
movq $0x0, -0x88(%rbp)
movq -0x10(%rbp), %rcx
xorl %eax, %eax
cmpq 0x18(%rcx), %rax
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x5c(%rbp)
movq -0x10(%rbp), %rcx
xorl %eax, %eax
cmpq 0x30(%rcx), %rax
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x60(%rbp)
cmpl $0x0, -0x5c(%rbp)
je 0x1fc90c
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
movl -0x24(%rbp), %r8d
callq 0x2169d0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0x1f9d70
cmpl $0x0, %eax
je 0x1fc90a
movl $0x0, -0x5c(%rbp)
movq -0x40(%rbp), %rdi
callq 0x1f7f70
movq $0x0, -0x40(%rbp)
jmp 0x1fc90c
xorl %eax, %eax
cmpq -0x40(%rbp), %rax
jne 0x1fc956
cmpl $0x0, -0x60(%rbp)
je 0x1fc956
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
movl -0x24(%rbp), %r8d
callq 0x216990
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0x1f9d70
cmpl $0x0, %eax
je 0x1fc954
movq -0x40(%rbp), %rdi
callq 0x1f7f70
movq $0x0, -0x40(%rbp)
jmp 0x1fc956
xorl %eax, %eax
cmpq -0x40(%rbp), %rax
jne 0x1fc96b
movq $0x0, -0x8(%rbp)
jmp 0x1fcc7d
movq -0x40(%rbp), %rax
movl 0x4(%rax), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
movq -0x40(%rbp), %rax
movl 0x8(%rax), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
movq -0x30(%rbp), %rdi
movslq -0x74(%rbp), %rsi
callq 0x1f9a80
movq %rax, -0x68(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x78(%rbp), %rsi
callq 0x1f9a80
movq %rax, -0x70(%rbp)
cmpl $0x0, -0x5c(%rbp)
je 0x1fc9fc
movq -0x68(%rbp), %rdi
movl -0x74(%rbp), %esi
movq -0x70(%rbp), %rdx
movl -0x78(%rbp), %ecx
movl -0x20(%rbp), %r8d
movl -0x24(%rbp), %r9d
movq -0x38(%rbp), %rax
movq %rax, (%rsp)
callq 0x215000
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x1f9d70
cmpl $0x0, %eax
je 0x1fc9fa
movl $0x0, -0x5c(%rbp)
movq -0x48(%rbp), %rdi
callq 0x1f7f70
movq $0x0, -0x48(%rbp)
jmp 0x1fc9fc
xorl %eax, %eax
cmpq -0x48(%rbp), %rax
jne 0x1fca52
cmpl $0x0, -0x60(%rbp)
je 0x1fca52
movq -0x68(%rbp), %rdi
movl -0x74(%rbp), %esi
movq -0x70(%rbp), %rdx
movl -0x78(%rbp), %ecx
movl -0x20(%rbp), %r8d
movl -0x24(%rbp), %r9d
movq -0x38(%rbp), %rax
movq %rax, (%rsp)
callq 0x214fb0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x1f9d70
cmpl $0x0, %eax
je 0x1fca50
movq -0x48(%rbp), %rdi
callq 0x1f7f70
movq $0x0, -0x48(%rbp)
jmp 0x1fca52
movq -0x70(%rbp), %rdi
callq 0x1f01a0
movq -0x68(%rbp), %rdi
callq 0x1f01a0
xorl %eax, %eax
cmpq -0x48(%rbp), %rax
jne 0x1fca82
movq -0x40(%rbp), %rdi
callq 0x1f7f70
movq $0x0, -0x8(%rbp)
jmp 0x1fcc7d
movq -0x40(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x48(%rbp), %rcx
subl 0x4(%rcx), %eax
movl %eax, -0x7c(%rbp)
movq -0x40(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x48(%rbp), %rcx
subl 0x8(%rcx), %eax
movl %eax, -0x80(%rbp)
movq -0x48(%rbp), %rax
movl 0x4(%rax), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
movq -0x48(%rbp), %rax
movl 0x8(%rax), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
cmpl $0x0, -0x5c(%rbp)
je 0x1fcb21
movq -0x30(%rbp), %rdi
movslq -0x7c(%rbp), %rax
addq %rax, %rdi
movl -0x74(%rbp), %esi
movq -0x18(%rbp), %rdx
movslq -0x80(%rbp), %rax
addq %rax, %rdx
movl -0x78(%rbp), %ecx
movl -0x20(%rbp), %r8d
movl -0x24(%rbp), %r9d
movq -0x38(%rbp), %rax
movq %rax, (%rsp)
callq 0x216680
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
callq 0x1f9d70
cmpl $0x0, %eax
je 0x1fcb1f
movl $0x0, -0x5c(%rbp)
movq -0x50(%rbp), %rdi
callq 0x1f7f70
movq $0x0, -0x50(%rbp)
jmp 0x1fcb21
xorl %eax, %eax
cmpq -0x50(%rbp), %rax
jne 0x1fcb85
cmpl $0x0, -0x60(%rbp)
je 0x1fcb85
movq -0x30(%rbp), %rdi
movslq -0x7c(%rbp), %rax
addq %rax, %rdi
movl -0x74(%rbp), %esi
movq -0x18(%rbp), %rdx
movslq -0x80(%rbp), %rax
addq %rax, %rdx
movl -0x78(%rbp), %ecx
movl -0x20(%rbp), %r8d
movl -0x24(%rbp), %r9d
movq -0x38(%rbp), %rax
movq %rax, (%rsp)
callq 0x216630
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
callq 0x1f9d70
cmpl $0x0, %eax
je 0x1fcb83
movq -0x50(%rbp), %rdi
callq 0x1f7f70
movq $0x0, -0x50(%rbp)
jmp 0x1fcb85
xorl %eax, %eax
cmpq -0x50(%rbp), %rax
jne 0x1fcbac
movq -0x48(%rbp), %rdi
callq 0x1f7f70
movq -0x40(%rbp), %rdi
callq 0x1f7f70
movq $0x0, -0x8(%rbp)
jmp 0x1fcc7d
movq -0x50(%rbp), %rdi
movq -0x30(%rbp), %rsi
movslq -0x7c(%rbp), %rax
addq %rax, %rsi
movl -0x74(%rbp), %edx
movq -0x18(%rbp), %rcx
movslq -0x80(%rbp), %rax
addq %rax, %rcx
movl -0x78(%rbp), %r8d
movq -0x38(%rbp), %r9
callq 0xccc030
movq %rax, -0x88(%rbp)
movl $0x28, %edi
callq 0x1f01c0
movq %rax, -0x58(%rbp)
movq -0x40(%rbp), %rax
movl (%rax), %eax
movw %ax, %cx
movq -0x58(%rbp), %rax
movw %cx, (%rax)
movl -0x80(%rbp), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x40(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0x7c(%rbp), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x40(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x88(%rbp), %rax
movq (%rax), %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x88(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x88(%rbp), %rdi
callq 0x1f01a0
movq -0x50(%rbp), %rdi
callq 0x1f7f70
movq -0x48(%rbp), %rdi
callq 0x1f7f70
movq -0x40(%rbp), %rdi
callq 0x1f7f70
movq -0x58(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopw (%rax,%rax)