// File: /workspace/github_c_makefile_star2_O0/lh3[P]fermi-lite/mag.c
// Function: mag_v_trim_open
void mag_v_trim_open(mag_t *g, magv_t *v, int trim_len, int trim_depth)
{
	int i, j, tl[2];
	if (v->nei[0].n > 0 && v->nei[1].n > 0) return; // no open end; do nothing
	if (v->nei[0].n == 0 && v->nei[1].n == 0 && v->len < trim_len * 3) { // disconnected short vertex
		mag_v_del(g, v);
		return;
	}
	for (j = 0; j < 2; ++j) {
		ku128_v *r = &v->nei[!j];
		int max_ovlp = 0;
		for (i = 0; i < r->n; ++i)
			max_ovlp = max_ovlp > r->a[i].y? max_ovlp : r->a[i].y;
		tl[j] = v->len - max_ovlp < trim_len? v->len - max_ovlp : trim_len;
	}
	if (v->nei[0].n == 0) {
		for (i = 0; i < tl[0] && v->cov[i] - 33 < trim_depth; ++i);
		tl[0] = i;
		v->len -= i;
		memmove(v->seq, v->seq + tl[0], v->len);
		memmove(v->cov, v->cov + tl[0], v->len);
	}
	if (v->nei[1].n == 0) {
		for (i = v->len - 1; i >= v->len - tl[1] && v->cov[i] - 33 < trim_depth; --i);
		tl[1] = v->len - 1 - i;
		v->len -= tl[1];
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jbe 0x1c7c1
movq -0x10(%rbp), %rax
cmpq $0x0, 0x38(%rax)
jbe 0x1c7c1
jmp 0x1ca00
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x1c7f7
movq -0x10(%rbp), %rax
cmpq $0x0, 0x38(%rax)
jne 0x1c7f7
movq -0x10(%rbp), %rax
movl (%rax), %eax
imull $0x3, -0x14(%rbp), %ecx
cmpl %ecx, %eax
jge 0x1c7f7
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x18490
jmp 0x1ca00
movl $0x0, -0x20(%rbp)
cmpl $0x2, -0x20(%rbp)
jge 0x1c8d8
movq -0x10(%rbp), %rax
addq $0x20, %rax
cmpl $0x0, -0x20(%rbp)
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x1c(%rbp)
movslq -0x1c(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x1c89d
movslq -0x34(%rbp), %rax
movq -0x30(%rbp), %rcx
movq 0x10(%rcx), %rcx
movslq -0x1c(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
cmpq 0x8(%rcx), %rax
jbe 0x1c870
movslq -0x34(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x1c88b
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movl %eax, -0x34(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1c83c
movq -0x10(%rbp), %rax
movl (%rax), %eax
subl -0x34(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x1c8b9
movq -0x10(%rbp), %rax
movl (%rax), %eax
subl -0x34(%rbp), %eax
movl %eax, -0x44(%rbp)
jmp 0x1c8bf
movl -0x14(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %ecx
movslq -0x20(%rbp), %rax
movl %ecx, -0x28(%rbp,%rax,4)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1c7fe
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x1c986
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %ecx
xorl %eax, %eax
cmpl -0x28(%rbp), %ecx
movb %al, -0x45(%rbp)
jge 0x1c917
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0x1c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
subl $0x21, %eax
cmpl -0x18(%rbp), %eax
setl %al
movb %al, -0x45(%rbp)
movb -0x45(%rbp), %al
testb $0x1, %al
jne 0x1c920
jmp 0x1c92d
jmp 0x1c922
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1c8ee
movl -0x1c(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x1c(%rbp), %edx
movq -0x10(%rbp), %rax
movl (%rax), %ecx
subl %edx, %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rsi
movslq -0x28(%rbp), %rax
addq %rax, %rsi
movq -0x10(%rbp), %rax
movslq (%rax), %rdx
callq 0x2220
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rsi
movslq -0x28(%rbp), %rax
addq %rax, %rsi
movq -0x10(%rbp), %rax
movslq (%rax), %rdx
callq 0x2220
movq -0x10(%rbp), %rax
cmpq $0x0, 0x38(%rax)
jne 0x1ca00
movq -0x10(%rbp), %rax
movl (%rax), %eax
subl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl (%rax), %edx
subl -0x24(%rbp), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x46(%rbp)
jl 0x1c9ce
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0x1c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
subl $0x21, %eax
cmpl -0x18(%rbp), %eax
setl %al
movb %al, -0x46(%rbp)
movb -0x46(%rbp), %al
testb $0x1, %al
jne 0x1c9d7
jmp 0x1c9e4
jmp 0x1c9d9
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1c99d
movq -0x10(%rbp), %rax
movl (%rax), %eax
subl $0x1, %eax
subl -0x1c(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %edx
movq -0x10(%rbp), %rax
movl (%rax), %ecx
subl %edx, %ecx
movl %ecx, (%rax)
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)