// File: /workspace/github_c_makefile_star2_O1/lh3[P]minigraph/gcmisc.c
// Function: mg_gchain_drop_flt
void mg_gchain_drop_flt(void *km, mg_gchains_t *gcs)
{
	int32_t i, n_gc, n_lc, n_a, n_lc0, n_a0, *o2n;
	if (gcs->n_gc == 0) return;
	KMALLOC(km, o2n, gcs->n_gc);
	for (i = 0, n_gc = 0; i < gcs->n_gc; ++i) {
		mg_gchain_t *r = &gcs->gc[i];
		o2n[i] = -1;
		if (r->flt || r->cnt == 0) {
			kfree(gcs->km, r->p);
			continue;
		}
		o2n[i] = n_gc++;
	}
	n_gc = n_lc = n_a = 0;
	n_lc0 = n_a0 = 0;
	for (i = 0; i < gcs->n_gc; ++i) {
		mg_gchain_t *r = &gcs->gc[i];
		if (o2n[i] >= 0) {
			memmove(&gcs->a[n_a], &gcs->a[n_a0], r->n_anchor * sizeof(mg128_t));
			memmove(&gcs->lc[n_lc], &gcs->lc[n_lc0], r->cnt * sizeof(mg_llchain_t));
			gcs->gc[n_gc] = *r;
			gcs->gc[n_gc].id = n_gc;
			gcs->gc[n_gc].parent = o2n[gcs->gc[n_gc].parent];
			++n_gc, n_lc += r->cnt, n_a += r->n_anchor;
		}
		n_lc0 += r->cnt, n_a0 += r->n_anchor;
	}
	assert(n_lc0 == gcs->n_lc && n_a0 == gcs->n_a);
	kfree(km, o2n);
	gcs->n_gc = n_gc, gcs->n_lc = n_lc, gcs->n_a = n_a;
	if (n_a != n_a0) {
		KREALLOC(gcs->km, gcs->a, gcs->n_a);
		KREALLOC(gcs->km, gcs->lc, gcs->n_lc);
		KREALLOC(gcs->km, gcs->gc, gcs->n_gc);
	}
	mg_gchain_restore_offset(gcs);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r12
movslq 0x8(%rsi), %rsi
testq %rsi, %rsi
je 0x1ca90
shlq $0x2, %rsi
movq %rdi, 0x20(%rsp)
callq 0x31c1
movq %rax, %rsi
cmpl $0x0, 0x8(%r12)
movq %rax, 0x18(%rsp)
jle 0x1c965
xorl %ebx, %ebx
movl $0x12, %r14d
xorl %ebp, %ebp
movq 0x18(%r12), %rax
movl $0xffffffff, (%rsi,%rbx,4) # imm = 0xFFFFFFFF
testb $0x1, -0x3(%rax,%r14,4)
jne 0x1c942
cmpl $0x0, -0x3c(%rax,%r14,4)
je 0x1c942
movl %ebp, (%rsi,%rbx,4)
incl %ebp
jmp 0x1c954
movq (%r12), %rdi
movq (%rax,%r14,4), %rsi
callq 0x30f6
movq 0x18(%rsp), %rsi
incq %rbx
movslq 0x8(%r12), %rax
addq $0x1a, %r14
cmpq %rax, %rbx
jl 0x1c91f
cmpl $0x0, 0x8(%r12)
jle 0x1ca9f
xorl %r14d, %r14d
movl $0x4, %r15d
movq $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
xorl %ebp, %ebp
xorl %r13d, %r13d
xorl %edi, %edi
movq 0x18(%r12), %rax
cmpl $0x0, (%rsi,%r14,4)
js 0x1ca70
movq %r12, %rbx
leaq (%rax,%r15,4), %r12
addq $-0x10, %r12
movq %rax, 0x28(%rsp)
movq 0x28(%rbx), %rax
movslq %edi, %rdi
movq %rdi, 0x30(%rsp)
shlq $0x4, %rdi
addq %rax, %rdi
movslq %ebp, %rsi
shlq $0x4, %rsi
addq %rax, %rsi
movslq 0x10(%r12), %rdx
shlq $0x4, %rdx
callq 0x22d0
movq 0x20(%rbx), %rax
movl %ebp, 0x14(%rsp)
movq 0x8(%rsp), %rbp
movslq %ebp, %rbp
leaq (%rbp,%rbp,4), %rcx
leaq (%rax,%rcx,4), %rdi
movslq %r13d, %rcx
leaq (%rcx,%rcx,4), %rcx
leaq (%rax,%rcx,4), %rsi
movslq 0xc(%r12), %rax
shlq $0x2, %rax
leaq (%rax,%rax,4), %rdx
callq 0x22d0
movq (%rsp), %r8
movslq %r8d, %r8
imulq $0x68, %r8, %rax
movq 0x18(%rbx), %rdi
addq %rax, %rdi
movl $0xd, %ecx
movq %r12, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq 0x18(%rsp), %rsi
movq 0x18(%rbx), %rcx
movl %r8d, (%rcx,%rax)
movslq 0x4(%rcx,%rax), %rdx
movl (%rsi,%rdx,4), %edx
movl %edx, 0x4(%rcx,%rax)
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rdi
incl %r8d
movq %r8, (%rsp)
addl 0xc(%r12), %ebp
movq %rbp, 0x8(%rsp)
movl 0x14(%rsp), %ebp
addl 0x10(%r12), %edi
movq %rbx, %r12
addl -0x4(%rax,%r15,4), %r13d
addl (%rax,%r15,4), %ebp
incq %r14
movslq 0x8(%r12), %rax
addq $0x1a, %r15
cmpq %rax, %r14
jl 0x1c992
jmp 0x1cab7
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %edi, %edi
xorl %r13d, %r13d
xorl %ebp, %ebp
movq $0x0, 0x8(%rsp)
movq $0x0, (%rsp)
cmpl 0xc(%r12), %r13d
jne 0x1cb62
cmpl 0x10(%r12), %ebp
jne 0x1cb62
movq %rdi, %rbx
movq 0x20(%rsp), %rdi
callq 0x30f6
movq (%rsp), %rax
movl %eax, 0x8(%r12)
movq 0x8(%rsp), %rax
movl %eax, 0xc(%r12)
movl %ebx, 0x10(%r12)
cmpl %ebp, %ebx
je 0x1cb4c
movq (%r12), %rdi
movq 0x28(%r12), %rsi
movslq %ebx, %rdx
shlq $0x4, %rdx
callq 0x32c4
movq %rax, 0x28(%r12)
movq (%r12), %rdi
movq 0x20(%r12), %rsi
movslq 0xc(%r12), %rax
shlq $0x2, %rax
leaq (%rax,%rax,4), %rdx
callq 0x32c4
movq %rax, 0x20(%r12)
movq (%r12), %rdi
movq 0x18(%r12), %rsi
movslq 0x8(%r12), %rax
imulq $0x68, %rax, %rdx
callq 0x32c4
movq %rax, 0x18(%r12)
movq %r12, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1c339
leaq 0xcfe8(%rip), %rdi      # 0x29b51
leaq 0xcf50(%rip), %rsi      # 0x29ac0
leaq 0xd001(%rip), %rcx      # 0x29b78
movl $0xb3, %edx
callq 0x2160