// File: /workspace/github_c_makefile_star2_O1/lh3[P]pre-pe/pre-meta.c
// Function: trim_olig
static inline void trim_olig(bseq1_t *s, const char *adap, int is_5, int min_len, int max_pen, int *trim_pos, char *trim_seq, int if_output)
{
	int n_hits, l_adap;
	uint64_t hits[16];
	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, 16, hits);
	else n_hits = lt_ue_for(s->l_seq, s->seq, s->qual, l_adap, adap, 0, max_pen, min_len, 16, hits);
	if (n_hits > 0) {
		int len = s->l_seq - (hits[n_hits-1]>>32); // trim the longest hit
		if (is_5) {
			if (len > min_len) { // trim
				if (if_output) {
					strncpy(trim_seq, s->seq, len);
					trim_seq[len] = 0;
					*trim_pos = len;
				}
				trim_bseq_5(s, len); 
			} else {
				memset(s->qual, 33+1, len); // reduce baseQ
			}
		} else {
			if (len > min_len) {  // trim
				s->l_seq -= len, s->seq[s->l_seq] = s->qual[s->l_seq] = 0;
			} 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 $0x98, %rsp
movq %r9, 0x8(%rsp)
movl %r8d, %r13d
movl %ecx, %r12d
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movl 0xd8(%rsp), %r15d
movq 0xd0(%rsp), %rax
movq %rax, (%rsp)
movq %rsi, %rdi
callq 0x20c0
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
andl (%rbx), %edi
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdx
leaq 0x10(%rsp), %r10
movl %eax, %ecx
movq %r14, %r8
xorl %r9d, %r9d
testl %ebp, %ebp
je 0x4166
pushq %r10
pushq $0x10
pushq %r12
pushq %r13
callq 0x2b22
jmp 0x4173
pushq %r10
pushq $0x10
pushq %r12
pushq %r13
callq 0x2a01
addq $0x20, %rsp
testl %eax, %eax
jle 0x426b
movl (%rbx), %ecx
movl %ecx, %r13d
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
decl %eax
movq 0x10(%rsp,%rax,8), %rdi
movq %rdi, %rax
shrq $0x20, %rax
subl %eax, %r13d
testl %ebp, %ebp
je 0x4235
cmpl %r12d, %r13d
jle 0x427d
testl %r15d, %r15d
je 0x41d5
movq 0x18(%rbx), %rsi
movslq %r13d, %r14
movq (%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
callq 0x2070
movb $0x0, (%r15,%r14)
movq 0x8(%rsp), %rax
movl %r13d, (%rax)
movq 0x18(%rbx), %rdi
movslq %r13d, %r15
leaq (%rdi,%r15), %rsi
movl (%rbx), %edx
movl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
andq %r14, %rdx
subq %r15, %rdx
callq 0x21e0
movq 0x20(%rbx), %rdi
leaq (%rdi,%r15), %rsi
movl (%rbx), %edx
andq %r14, %rdx
subq %r15, %rdx
callq 0x21e0
movl (%rbx), %eax
movl %eax, %ecx
subl %r13d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl $0x80000000, %eax       # imm = 0x80000000
orl %ecx, %eax
movl %eax, (%rbx)
movq 0x20(%rbx), %rax
xorl %edx, %edx
movb %dl, (%rax,%rcx)
movq 0x18(%rbx), %rax
movl (%rbx), %ecx
andq %r14, %rcx
movb %dl, (%rax,%rcx)
jmp 0x426b
cmpl %r12d, %r13d
jle 0x4283
movl %eax, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl $0x80000000, %ecx       # imm = 0x80000000
orl %edx, %ecx
movl %ecx, (%rbx)
movq 0x20(%rbx), %rcx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andq %rdx, %rax
xorl %esi, %esi
movb %sil, (%rcx,%rax)
movq 0x18(%rbx), %rax
movl (%rbx), %ecx
andq %rdx, %rcx
movb %sil, (%rax,%rcx)
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x20(%rbx), %rdi
jmp 0x428b
sarq $0x20, %rdi
addq 0x20(%rbx), %rdi
movslq %r13d, %rdx
movl $0x22, %esi
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2110