// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xe0, %rsp
movl 0x18(%rbp), %eax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movq %r9, -0x28(%rbp)
movq -0x10(%rbp), %rdi
callq 0x20c0
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x4a3f
movq -0x8(%rbp), %rax
movl (%rax), %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdx
movl -0x30(%rbp), %ecx
movq -0x10(%rbp), %r8
movl -0x1c(%rbp), %r11d
movl -0x18(%rbp), %r10d
leaq -0xb0(%rbp), %rax
xorl %r9d, %r9d
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl $0x10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x2e70
movl %eax, -0x2c(%rbp)
jmp 0x4a92
movq -0x8(%rbp), %rax
movl (%rax), %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdx
movl -0x30(%rbp), %ecx
movq -0x10(%rbp), %r8
movl -0x1c(%rbp), %r11d
movl -0x18(%rbp), %r10d
leaq -0xb0(%rbp), %rax
xorl %r9d, %r9d
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl $0x10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x2d60
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jle 0x4bda
movq -0x8(%rbp), %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl -0x2c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq -0xb0(%rbp,%rcx,8), %rcx
shrq $0x20, %rcx
subq %rcx, %rax
movl %eax, -0xb4(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x4b40
movl -0xb4(%rbp), %eax
cmpl -0x18(%rbp), %eax
jle 0x4b22
cmpl $0x0, 0x18(%rbp)
je 0x4b11
movq 0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
movslq -0xb4(%rbp), %rdx
callq 0x2060
movq 0x10(%rbp), %rax
movslq -0xb4(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl -0xb4(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rdi
movl -0xb4(%rbp), %esi
callq 0x46a0
jmp 0x4b3b
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
movslq -0xb4(%rbp), %rdx
movl $0x22, %esi
callq 0x2110
jmp 0x4bd8
movl -0xb4(%rbp), %eax
cmpl -0x18(%rbp), %eax
jle 0x4ba7
movl -0xb4(%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 0x20(%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 0x18(%rax), %rax
movq -0x8(%rbp), %rcx
movl (%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
jmp 0x4bd6
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x8(%rbp), %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
subl -0xb4(%rbp), %eax
cltq
addq %rax, %rdi
movslq -0xb4(%rbp), %rdx
movl $0x22, %esi
callq 0x2110
jmp 0x4bd8
jmp 0x4bda
addq $0xe0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)