// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/inter.cpp
// Function: mg_gchain_drop_flt(void*, mg_gchains_t*)
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) 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 0x15fb87
shlq $0x2, %rsi
movq %rdi, 0x10(%rsp)
callq 0x1a39c4
xorl %ecx, %ecx
pushq $0x11
popq %rdx
xorl %esi, %esi
movslq 0x8(%rbx), %rdi
cmpq %rdi, %rcx
jge 0x15f9ce
movq 0x18(%rbx), %rdi
orl $-0x1, (%rax,%rcx,4)
testb $0x1, 0x1(%rdi,%rdx,4)
jne 0x15f9c5
cmpl $0x0, -0x38(%rdi,%rdx,4)
je 0x15f9c5
movl %esi, (%rax,%rcx,4)
incl %esi
incq %rcx
addq $0x12, %rdx
jmp 0x15f9a1
xorl %r10d, %r10d
pushq $0x4
popq %r8
xorl %r13d, %r13d
xorl %r14d, %r14d
xorl %r12d, %r12d
movl $0x0, 0x8(%rsp)
movl $0x0, 0x4(%rsp)
movq %rax, 0x18(%rsp)
movslq %edi, %rcx
movslq %r13d, %rbp
cmpq %rcx, %r10
jge 0x15faf2
movq 0x18(%rbx), %rcx
cmpl $0x0, (%rax,%r10,4)
js 0x15fad7
movl %r13d, 0xc(%rsp)
leaq (%rcx,%r8,4), %r13
addq $-0x10, %r13
movq 0x28(%rbx), %rcx
shlq $0x4, %rbp
addq %rcx, %rbp
movslq %r12d, %rsi
shlq $0x4, %rsi
addq %rcx, %rsi
movslq 0x10(%r13), %rdx
shlq $0x4, %rdx
movq %rbp, %rdi
movq %r8, 0x20(%rsp)
movq %r10, %rbp
callq 0x2360
movq 0x20(%rbx), %rax
movl 0x8(%rsp), %r15d
movslq %r15d, %rdi
shlq $0x4, %rdi
addq %rax, %rdi
movslq %r14d, %rsi
shlq $0x4, %rsi
addq %rax, %rsi
movslq 0xc(%r13), %rdx
shlq $0x4, %rdx
callq 0x2360
movq %rbp, %r10
movq 0x18(%rsp), %rax
movl 0x4(%rsp), %r9d
movslq %r9d, %rcx
imulq $0x48, %rcx, %r8
movq 0x18(%rbx), %rdi
addq %r8, %rdi
pushq $0x12
popq %rcx
movq %r13, %rsi
rep  movsl (%rsi), %es:(%rdi)
movq 0x18(%rbx), %rcx
movl %r9d, (%rcx,%r8)
movslq 0x4(%rcx,%r8), %rdx
movl (%rax,%rdx,4), %edx
movl %edx, 0x4(%rcx,%r8)
movq 0x20(%rsp), %r8
incl %r9d
movl %r9d, 0x4(%rsp)
movl 0xc(%r13), %edx
movl 0x10(%r13), %ecx
movl 0xc(%rsp), %r13d
addl %edx, %r15d
movl %r15d, 0x8(%rsp)
addl %ecx, %r13d
movl 0x8(%rbx), %edi
jmp 0x15fae0
movl -0x4(%rcx,%r8,4), %edx
movl (%rcx,%r8,4), %ecx
addl %edx, %r14d
addl %ecx, %r12d
incq %r10
addq $0x12, %r8
jmp 0x15f9f3
cmpl 0xc(%rbx), %r14d
jne 0x15fb96
cmpl 0x10(%rbx), %r12d
jne 0x15fb96
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x1a38cf
movl 0x4(%rsp), %eax
movl %eax, 0x8(%rbx)
movl 0x8(%rsp), %eax
movl %eax, 0xc(%rbx)
movl %r13d, 0x10(%rbx)
cmpl %r12d, %r13d
je 0x15fb71
movq (%rbx), %rdi
movq 0x28(%rbx), %rsi
shlq $0x4, %rbp
movq %rbp, %rdx
callq 0x1a3acc
movq %rax, 0x28(%rbx)
movq (%rbx), %rdi
movq 0x20(%rbx), %rsi
movslq 0xc(%rbx), %rdx
shlq $0x4, %rdx
callq 0x1a3acc
movq %rax, 0x20(%rbx)
movq (%rbx), %rdi
movq 0x18(%rbx), %rsi
movslq 0x8(%rbx), %rax
imulq $0x48, %rax, %rdx
callq 0x1a3acc
movq %rax, 0x18(%rbx)
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x15f8cd
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x924e2(%rip), %rdi     # 0x1f207f
leaq 0x91f7f(%rip), %rsi     # 0x1f1b23
leaq 0x924fb(%rip), %rcx     # 0x1f20a6
movl $0x892, %edx            # imm = 0x892
callq 0x2110