// File: /workspace/github_c_makefile_star2_O1/lh3[P]pre-pe/pre-lianti.c
// Function: trim_adap
static inline void trim_adap(bseq1_t *s, const char *adap, int is_5, int min_len, int max_pen, int allow_contained)
{
	int n_hits, l_adap;
	uint64_t hits[4];
	l_adap = strlen(adap);
	if (is_5) n_hits = lt_ue_rev(s->l_seq, s->seq, s->qual, l_adap, adap, 0, max_pen, min_len, 4, hits);
	else n_hits = lt_ue_for(s->l_seq, s->seq, s->qual, l_adap, adap, 0, max_pen, min_len, 4, hits);
	if (n_hits > 0 && (allow_contained || (hits[0]>>32) + (uint32_t)hits[0] == s->l_seq || (hits[n_hits-1]>>32) + (uint32_t)hits[n_hits-1] == s->l_seq)) {
		int len = s->l_seq - (hits[n_hits-1]>>32); // trim the longest hit
		if (is_5) {
			if (len > min_len) trim_bseq_5(s, len); // trim
			else memset(s->qual, 33+1, len); // reduce baseQ
		} else {
			if (len > min_len) s->l_seq -= len, s->seq[s->l_seq] = s->qual[s->l_seq] = 0; // trim
			else memset(s->qual + (s->l_seq - len), 33+1, len); // reduce baseQ
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r9d, %r15d
movl %r8d, %r12d
movl %ecx, %r14d
movl %edx, %ebp
movq %rsi, %r13
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x20c0
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
andl (%rbx), %edi
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdx
movq %rsp, %r10
movl %eax, %ecx
movq %r13, %r8
xorl %r9d, %r9d
testl %ebp, %ebp
je 0x4e83
pushq %r10
pushq $0x4
pushq %r14
pushq %r12
callq 0x2fe5
jmp 0x4e90
pushq %r10
pushq $0x4
pushq %r14
pushq %r12
callq 0x2ec4
addq $0x20, %rsp
testl %eax, %eax
jle 0x4f8c
testl %r15d, %r15d
jne 0x4ed4
movq (%rsp), %rcx
movl %ecx, %edx
shrq $0x20, %rcx
addq %rcx, %rdx
movl (%rbx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpq %rcx, %rdx
je 0x4ed4
leal -0x1(%rax), %edx
movq (%rsp,%rdx,8), %rdx
movl %edx, %esi
shrq $0x20, %rdx
addq %rdx, %rsi
cmpq %rcx, %rsi
jne 0x4f8c
movl (%rbx), %esi
movl %esi, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
decl %eax
movq (%rsp,%rax,8), %rdx
movq %rdx, %rax
shrq $0x20, %rax
subl %eax, %ecx
testl %ebp, %ebp
je 0x4f56
movslq %ecx, %r15
cmpl %r14d, %ecx
jle 0x4f9b
movq 0x10(%rbx), %rdi
leaq (%rdi,%r15), %rsi
sarq $0x20, %rdx
callq 0x21e0
movq 0x18(%rbx), %rdi
leaq (%rdi,%r15), %rsi
movl (%rbx), %edx
movl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
andq %r14, %rdx
subq %r15, %rdx
callq 0x21e0
movl (%rbx), %eax
movl %eax, %ecx
subl %r15d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl $0x80000000, %eax       # imm = 0x80000000
orl %ecx, %eax
movl %eax, (%rbx)
movq 0x18(%rbx), %rax
xorl %edx, %edx
movb %dl, (%rax,%rcx)
movq 0x10(%rbx), %rax
movl (%rbx), %ecx
andq %r14, %rcx
movb %dl, (%rax,%rcx)
jmp 0x4f8c
cmpl %r14d, %ecx
jle 0x4fa9
movl %eax, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl $0x80000000, %esi       # imm = 0x80000000
orl %ecx, %esi
movl %esi, (%rbx)
movq 0x18(%rbx), %rcx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andq %rdx, %rax
xorl %esi, %esi
movb %sil, (%rcx,%rax)
movq 0x10(%rbx), %rax
movl (%rbx), %ecx
andq %rdx, %rcx
movb %sil, (%rax,%rcx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rbx), %rdi
movl $0x22, %esi
movq %r15, %rdx
jmp 0x4fbf
sarq $0x20, %rdx
addq 0x18(%rbx), %rdx
movslq %ecx, %rax
movq %rdx, %rdi
movl $0x22, %esi
movq %rax, %rdx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2110