// File: /workspace/github_cpp_makefile_star2_O3/ParkerLab[P]cta/src/cta.cpp
// Function: trim_pair(FASTQRecord&, FASTQRecord&, long long, long long, long long, long long, bool)
void trim_pair(FASTQRecord& rec1, FASTQRecord& rec2, long long int rc_length, long long int max_edit_distance, long long int fudge = 0, long long int trim_start = 0, bool verbose = false) {
    long long int alignment_start = -1;
    std::string rec2_rc = reverse_complement(rec2.sequence.substr(0, rc_length));
    if (verbose) {
        std::cout << rec1.sequence << '\n' << rec2.sequence << '\n' << rec2_rc << '\n';
    }

    size_t position_of_rec2_rc_in_rec1 = rec1.sequence.rfind(rec2_rc);
    long long int trim_end = rc_length - fudge;

    if (position_of_rec2_rc_in_rec1 != std::string::npos) {
        alignment_start = position_of_rec2_rc_in_rec1;

        if (verbose) {
            std::cout << "trim_pair: rec2 rc " << rec2_rc << " found at " << position_of_rec2_rc_in_rec1 << " in rec1 " << rec1.sequence  << '\n';
        }
    } else if (max_edit_distance > 0) {
        alignment_start = align(rec2_rc, rec1.sequence, max_edit_distance, verbose);

        if (verbose) {
            std::cout << "trim_pair: rec2 rc " << rec2_rc << " not found in " << rec1.sequence << "; alignment result: " << alignment_start << '\n';
        }
    }

    if (alignment_start > 0) {
        if (verbose) {
            std::cout << "trim_pair: best alignment at " << alignment_start << '\n';
        }
        if (alignment_start > 0) {
            if (verbose) {
                std::cout << "trim_pair: trimming pair " << rec1.name << '\n';
            }
            trim_fastq_record(rec1, trim_start, alignment_start + trim_end);
            trim_fastq_record(rec2, trim_start, alignment_start + trim_end);
        }
    } else if (verbose) {
        std::cout << "not touching pair " << rec1.name << '\n';
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, 0x48(%rsp)
movq %r8, %rbp
movq %rcx, %r13
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %rbx
addq $0x40, %rsi
leaq 0x28(%rsp), %r14
movq %r14, %rdi
xorl %edx, %edx
movq %r12, %rcx
callq 0xb4c0
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0xc0e9
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xca29
movq 0x38(%rsp), %rsi
incq %rsi
callq 0xb480
cmpb $0x0, 0x90(%rsp)
je 0xcaa8
movq 0x40(%rbx), %rsi
movq 0x48(%rbx), %rdx
movq 0x3053e(%rip), %rdi     # 0x3cf80
callq 0xb540
leaq 0x28(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0xb540
movq 0x40(%r15), %rsi
movq 0x48(%r15), %rdx
movq %rax, %rdi
callq 0xb540
leaq 0x28(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0xb540
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rax, %rdi
callq 0xb540
leaq 0x28(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0xb540
movq %rbp, 0x50(%rsp)
leaq 0x40(%rbx), %r14
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rcx
movq %r14, %rdi
movq $-0x1, %rdx
callq 0xb630
cmpq $-0x1, %rax
je 0xcb76
movq %rax, %rbp
cmpb $0x0, 0x90(%rsp)
je 0xcc34
movq 0x30494(%rip), %rdi     # 0x3cf80
leaq 0x1c751(%rip), %rsi     # 0x29244
movl $0x13, %edx
callq 0xb540
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x30472(%rip), %rdi     # 0x3cf80
callq 0xb540
movq %rax, %r14
leaq 0x1c73b(%rip), %rsi     # 0x29258
movl $0xa, %edx
movq %rax, %rdi
callq 0xb540
movq %r14, %rdi
movq %rbp, %rsi
callq 0xb320
movq %rax, %r14
leaq 0x1c724(%rip), %rsi     # 0x29263
movl $0x9, %edx
movq %rax, %rdi
callq 0xb540
movq 0x40(%rbx), %rsi
movq 0x48(%rbx), %rdx
movq %r14, %rdi
callq 0xb540
leaq 0x28(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0xb540
jmp 0xcc34
testq %r13, %r13
jle 0xcced
movzbl 0x90(%rsp), %ecx
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0xc4f8
movq %rax, %rbp
cmpb $0x0, 0x90(%rsp)
je 0xcc34
movq 0x303d1(%rip), %rdi     # 0x3cf80
leaq 0x1c68e(%rip), %rsi     # 0x29244
movl $0x13, %edx
callq 0xb540
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x303af(%rip), %rdi     # 0x3cf80
callq 0xb540
movq %rax, %r14
leaq 0x1c68d(%rip), %rsi     # 0x2926d
movl $0xe, %edx
movq %rax, %rdi
callq 0xb540
movq 0x40(%rbx), %rsi
movq 0x48(%rbx), %rdx
movq %r14, %rdi
callq 0xb540
movq %rax, %r14
leaq 0x1c675(%rip), %rsi     # 0x2927c
movl $0x14, %edx
movq %rax, %rdi
callq 0xb540
movq %r14, %rdi
movq %rbp, %rsi
callq 0xb1d0
leaq 0x28(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0xb540
testq %rbp, %rbp
jle 0xcced
cmpb $0x0, 0x90(%rsp)
je 0xccc3
movq 0x30332(%rip), %rdi     # 0x3cf80
leaq 0x1c63c(%rip), %rsi     # 0x29291
movl $0x1d, %edx
callq 0xb540
movq 0x3031a(%rip), %rdi     # 0x3cf80
movq %rbp, %rsi
callq 0xb1d0
leaq 0x28(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0xb540
movq 0x302f6(%rip), %rdi     # 0x3cf80
leaq 0x1c61e(%rip), %rsi     # 0x292af
movl $0x19, %edx
callq 0xb540
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0x302d7(%rip), %rdi     # 0x3cf80
callq 0xb540
leaq 0x28(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0xb540
subq 0x50(%rsp), %r12
addq %r12, %rbp
movq %rbx, %rdi
movq 0x48(%rsp), %rsi
movq %rbp, %rdx
callq 0xc92e
movq %r15, %rdi
movq 0x48(%rsp), %rsi
movq %rbp, %rdx
callq 0xc92e
jmp 0xcd37
cmpb $0x0, 0x90(%rsp)
je 0xcd37
movq 0x30282(%rip), %rdi     # 0x3cf80
leaq 0x1c5c4(%rip), %rsi     # 0x292c9
movl $0x12, %edx
callq 0xb540
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0x30263(%rip), %rdi     # 0x3cf80
callq 0xb540
leaq 0x28(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0xb540
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xcd52
movq 0x18(%rsp), %rsi
incq %rsi
callq 0xb480
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xcd99
movq 0x38(%rsp), %rsi
jmp 0xcd91
jmp 0xcd7b
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xcd99
movq 0x18(%rsp), %rsi
incq %rsi
callq 0xb480
movq %rbx, %rdi
callq 0xb7d0