// File: /workspace/github_c_makefile_star2_O2/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 $0x28, %rsp
movq %rsi, %rbx
movslq 0x8(%rsi), %rsi
testq %rsi, %rsi
je 0x1934d
shlq $0x2, %rsi
movq %rdi, 0x18(%rsp)
callq 0x266c
movq %rax, %r13
xorl %r14d, %r14d
pushq $0x12
popq %r15
xorl %ebp, %ebp
movslq 0x8(%rbx), %rax
cmpq %rax, %r14
jge 0x19193
movq 0x18(%rbx), %rax
orl $-0x1, (%r13,%r14,4)
testb $0x1, -0x3(%rax,%r15,4)
jne 0x1917e
cmpl $0x0, -0x3c(%rax,%r15,4)
je 0x1917e
movl %ebp, (%r13,%r14,4)
incl %ebp
jmp 0x1918a
movq (%rbx), %rdi
movq (%rax,%r15,4), %rsi
callq 0x2577
incq %r14
addq $0x1a, %r15
jmp 0x19152
xorl %r14d, %r14d
pushq $0x4
popq %rdi
xorl %r12d, %r12d
xorl %r8d, %r8d
xorl %r15d, %r15d
movl $0x0, 0x8(%rsp)
movl $0x0, 0x4(%rsp)
movq %r13, 0x10(%rsp)
movslq %eax, %rcx
movslq %r12d, %rbp
cmpq %rcx, %r14
jge 0x192b8
movq 0x18(%rbx), %rcx
cmpl $0x0, (%r13,%r14,4)
js 0x1929f
movl %r12d, 0xc(%rsp)
leaq (%rcx,%rdi,4), %r13
addq $-0x10, %r13
movq 0x28(%rbx), %rax
shlq $0x4, %rbp
addq %rax, %rbp
movslq %r15d, %rsi
shlq $0x4, %rsi
addq %rax, %rsi
movslq 0x10(%r13), %rdx
shlq $0x4, %rdx
movq %rdi, 0x20(%rsp)
movq %rbp, %rdi
movl %r8d, %r12d
callq 0x22d0
movq 0x20(%rbx), %rax
movl 0x8(%rsp), %ebp
movslq %ebp, %rcx
imulq $0x14, %rcx, %rdi
addq %rax, %rdi
movslq %r12d, %rcx
imulq $0x14, %rcx, %rsi
addq %rax, %rsi
movslq 0xc(%r13), %rax
imulq $0x14, %rax, %rdx
callq 0x22d0
movl 0x4(%rsp), %r8d
movslq %r8d, %rax
imulq $0x68, %rax, %rax
movq 0x18(%rbx), %rdi
addq %rax, %rdi
pushq $0xd
popq %rcx
movq %r13, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq 0x20(%rsp), %rdi
movq 0x18(%rbx), %rcx
movl %r8d, (%rcx,%rax)
movslq 0x4(%rcx,%rax), %rdx
movq 0x10(%rsp), %r9
movl (%r9,%rdx,4), %edx
movl %edx, 0x4(%rcx,%rax)
incl %r8d
movl %r8d, 0x4(%rsp)
movl %r12d, %r8d
movl 0xc(%r13), %edx
movl 0x10(%r13), %ecx
movq 0x10(%rsp), %r13
movl 0xc(%rsp), %r12d
addl %edx, %ebp
movl %ebp, 0x8(%rsp)
addl %ecx, %r12d
movl 0x8(%rbx), %eax
jmp 0x192a6
movl -0x4(%rcx,%rdi,4), %edx
movl (%rcx,%rdi,4), %ecx
addl %edx, %r8d
addl %ecx, %r15d
incq %r14
addq $0x1a, %rdi
jmp 0x191b7
cmpl 0xc(%rbx), %r8d
jne 0x1935c
cmpl 0x10(%rbx), %r15d
jne 0x1935c
movq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x2577
movl 0x4(%rsp), %eax
movl %eax, 0x8(%rbx)
movl 0x8(%rsp), %eax
movl %eax, 0xc(%rbx)
movl %r12d, 0x10(%rbx)
cmpl %r15d, %r12d
je 0x19337
movq (%rbx), %rdi
movq 0x28(%rbx), %rsi
shlq $0x4, %rbp
movq %rbp, %rdx
callq 0x2774
movq %rax, 0x28(%rbx)
movq (%rbx), %rdi
movq 0x20(%rbx), %rsi
movslq 0xc(%rbx), %rax
imulq $0x14, %rax, %rdx
callq 0x2774
movq %rax, 0x20(%rbx)
movq (%rbx), %rdi
movq 0x18(%rbx), %rsi
movslq 0x8(%rbx), %rax
imulq $0x68, %rax, %rdx
callq 0x2774
movq %rax, 0x18(%rbx)
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x18bcf
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb876(%rip), %rdi      # 0x24bd9
leaq 0xb7de(%rip), %rsi      # 0x24b48
leaq 0xb88f(%rip), %rcx      # 0x24c00
movl $0xb3, %edx
callq 0x2160