// File: /workspace/github_c_makefile_star2_O0/DReichLab[P]adna/trim.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
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movl %r9d, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x20d0
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x54f5
movq -0x8(%rbp), %rax
movl (%rax), %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdx
movl -0x28(%rbp), %ecx
movq -0x10(%rbp), %r8
movl -0x1c(%rbp), %r11d
movl -0x18(%rbp), %r10d
leaq -0x50(%rbp), %rax
xorl %r9d, %r9d
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl $0x4, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x3740
movl %eax, -0x24(%rbp)
jmp 0x5545
movq -0x8(%rbp), %rax
movl (%rax), %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdx
movl -0x28(%rbp), %ecx
movq -0x10(%rbp), %r8
movl -0x1c(%rbp), %r11d
movl -0x18(%rbp), %r10d
leaq -0x50(%rbp), %rax
xorl %r9d, %r9d
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl $0x4, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x3630
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jle 0x569e
cmpl $0x0, -0x20(%rbp)
jne 0x55b4
movq -0x50(%rbp), %rax
shrq $0x20, %rax
movq -0x50(%rbp), %rcx
movl %ecx, %ecx
addq %rcx, %rax
movq -0x8(%rbp), %rcx
movl (%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %ecx, %ecx
cmpq %rcx, %rax
je 0x55b4
movl -0x24(%rbp), %eax
subl $0x1, %eax
cltq
movq -0x50(%rbp,%rax,8), %rax
shrq $0x20, %rax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq -0x50(%rbp,%rcx,8), %rcx
movl %ecx, %ecx
addq %rcx, %rax
movq -0x8(%rbp), %rcx
movl (%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %ecx, %ecx
cmpq %rcx, %rax
jne 0x569e
movq -0x8(%rbp), %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq -0x50(%rbp,%rcx,8), %rcx
shrq $0x20, %rcx
subq %rcx, %rax
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x5610
movl -0x54(%rbp), %eax
cmpl -0x18(%rbp), %eax
jle 0x55f5
movq -0x8(%rbp), %rdi
movl -0x54(%rbp), %esi
callq 0x52c0
jmp 0x560b
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movslq -0x54(%rbp), %rdx
movl $0x22, %esi
callq 0x2110
jmp 0x569c
movl -0x54(%rbp), %eax
cmpl -0x18(%rbp), %eax
jle 0x5671
movl -0x54(%rbp), %ecx
movq -0x8(%rbp), %rax
movl (%rax), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
subl %ecx, %edx
movl (%rax), %ecx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl $0x80000000, %ecx       # imm = 0x80000000
orl %edx, %ecx
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x8(%rbp), %rcx
movl (%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rcx
movl (%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
jmp 0x569a
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x8(%rbp), %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
subl -0x54(%rbp), %eax
cltq
addq %rax, %rdi
movslq -0x54(%rbp), %rdx
movl $0x22, %esi
callq 0x2110
jmp 0x569c
jmp 0x569e
addq $0x80, %rsp
popq %rbp
retq
nopw (%rax,%rax)