// File: /workspace/github_c_makefile_star2_O3/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, %rbx
movslq 0x8(%rsi), %rsi
testq %rsi, %rsi
je 0x1cbd7
shlq $0x2, %rsi
movq %rdi, 0x30(%rsp)
callq 0x30e5
movq %rax, %r12
cmpl $0x0, 0x8(%rbx)
jle 0x1cb17
xorl %r14d, %r14d
movl $0x12, %r15d
xorl %ebp, %ebp
movq 0x18(%rbx), %rax
movl $0xffffffff, (%r12,%r14,4) # imm = 0xFFFFFFFF
testb $0x1, -0x3(%rax,%r15,4)
jne 0x1c9a8
cmpl $0x0, -0x3c(%rax,%r15,4)
je 0x1c9a8
movl %ebp, (%r12,%r14,4)
incl %ebp
jmp 0x1c9b4
movq (%rbx), %rdi
movq (%rax,%r15,4), %rsi
callq 0x301f
incq %r14
movslq 0x8(%rbx), %rcx
addq $0x1a, %r15
cmpq %rcx, %r14
jl 0x1c984
testl %ecx, %ecx
jle 0x1cb17
movq 0x18(%rbx), %rax
xorl %r14d, %r14d
movl $0x4, %r15d
movq $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
xorl %r8d, %r8d
xorl %r13d, %r13d
movq $0x0, 0x10(%rsp)
movq %r12, 0x28(%rsp)
movq %rbx, 0x18(%rsp)
cmpl $0x0, (%r12,%r14,4)
js 0x1caf3
leaq (%rax,%r15,4), %r12
addq $-0x10, %r12
movq 0x28(%rbx), %rax
movq 0x10(%rsp), %rbx
movslq %ebx, %rbx
movq %rbx, %rdi
shlq $0x4, %rdi
addq %rax, %rdi
movslq %r8d, %rsi
shlq $0x4, %rsi
addq %rax, %rsi
movslq 0x10(%r12), %rdx
shlq $0x4, %rdx
movl %r8d, 0x24(%rsp)
callq 0x22d0
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rax
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
movl 0x24(%rsp), %r8d
movq (%rsp), %r9
movslq %r9d, %r9
imulq $0x68, %r9, %rdx
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rdi
addq %rdx, %rdi
movl $0xd, %ecx
movq %r12, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
movl %r9d, (%rax,%rdx)
movslq 0x4(%rax,%rdx), %rcx
movq 0x28(%rsp), %rsi
movl (%rsi,%rcx,4), %ecx
movl %ecx, 0x4(%rax,%rdx)
incl %r9d
movq %r9, (%rsp)
movl 0xc(%r12), %esi
movl 0x10(%r12), %edx
movq 0x28(%rsp), %r12
addl %esi, %ebp
movq %rbp, 0x8(%rsp)
addl %edx, %ebx
movq %rbx, 0x10(%rsp)
movq 0x18(%rsp), %rbx
movl 0x8(%rbx), %ecx
jmp 0x1cafc
movl -0x4(%rax,%r15,4), %esi
movl (%rax,%r15,4), %edx
addl %esi, %r13d
addl %edx, %r8d
incq %r14
movslq %ecx, %rdx
addq $0x1a, %r15
cmpq %rdx, %r14
jl 0x1ca03
jmp 0x1cb37
movq $0x0, 0x10(%rsp)
xorl %r13d, %r13d
xorl %r8d, %r8d
movq $0x0, 0x8(%rsp)
movq $0x0, (%rsp)
cmpl 0xc(%rbx), %r13d
jne 0x1cbe6
cmpl 0x10(%rbx), %r8d
jne 0x1cbe6
movq 0x30(%rsp), %rdi
movq %r12, %rsi
movl %r8d, %ebp
callq 0x301f
movq (%rsp), %rax
movl %eax, 0x8(%rbx)
movq 0x8(%rsp), %rax
movl %eax, 0xc(%rbx)
movq 0x10(%rsp), %rax
movl %eax, 0x10(%rbx)
cmpl %ebp, %eax
je 0x1cbc1
movq (%rbx), %rdi
movq 0x28(%rbx), %rsi
movslq %eax, %rdx
shlq $0x4, %rdx
callq 0x31ed
movq %rax, 0x28(%rbx)
movq (%rbx), %rdi
movq 0x20(%rbx), %rsi
movslq 0xc(%rbx), %rax
shlq $0x2, %rax
leaq (%rax,%rax,4), %rdx
callq 0x31ed
movq %rax, 0x20(%rbx)
movq (%rbx), %rdi
movq 0x18(%rbx), %rsi
movslq 0x8(%rbx), %rax
imulq $0x68, %rax, %rdx
callq 0x31ed
movq %rax, 0x18(%rbx)
movq %rbx, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1c341
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xd010(%rip), %rdi      # 0x29bfd
leaq 0xcf78(%rip), %rsi      # 0x29b6c
leaq 0xd029(%rip), %rcx      # 0x29c24
movl $0xb3, %edx
callq 0x2160