// File: /workspace/github_cpp_makefile_star2_O3/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 $0x38, %rsp
movq %rsi, %rbx
movslq 0x8(%rsi), %rsi
testq %rsi, %rsi
je 0x1a7715
shlq $0x2, %rsi
movq %rdi, 0x28(%rsp)
callq 0x1ee115
cmpl $0x0, 0x8(%rbx)
movq %rbx, 0x20(%rsp)
jle 0x1a7650
movq 0x18(%rbx), %rdi
addq $0x44, %rdi
xorl %edx, %edx
xorl %esi, %esi
movl $0xffffffff, (%rax,%rdx,4) # imm = 0xFFFFFFFF
testb $0x1, 0x1(%rdi)
jne 0x1a74f8
cmpl $0x0, -0x38(%rdi)
je 0x1a74f8
movl %esi, (%rax,%rdx,4)
incl %esi
incq %rdx
movslq 0x8(%rbx), %rcx
addq $0x48, %rdi
cmpq %rcx, %rdx
jl 0x1a74e0
testl %ecx, %ecx
jle 0x1a7650
movq 0x18(%rbx), %rdi
xorl %r14d, %r14d
movl $0x4, %ebx
movq $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
xorl %r8d, %r8d
xorl %r9d, %r9d
movq $0x0, 0x10(%rsp)
movq %rax, 0x30(%rsp)
movq 0x20(%rsp), %r15
cmpl $0x0, (%rax,%r14,4)
js 0x1a762e
leaq (%rdi,%rbx,4), %r12
addq $-0x10, %r12
movq 0x28(%r15), %rcx
movq 0x10(%rsp), %rbp
movslq %ebp, %rbp
movq %rbp, %rdi
shlq $0x4, %rdi
addq %rcx, %rdi
movslq %r8d, %rsi
shlq $0x4, %rsi
addq %rcx, %rsi
movslq 0x10(%r12), %rdx
shlq $0x4, %rdx
movl %r8d, 0x1c(%rsp)
movl %r9d, 0x18(%rsp)
callq 0x2360
movq 0x20(%r15), %rax
movq 0x8(%rsp), %r13
movslq %r13d, %r13
movq %r13, %rdi
shlq $0x4, %rdi
addq %rax, %rdi
movslq 0x18(%rsp), %rsi
shlq $0x4, %rsi
addq %rax, %rsi
movslq 0xc(%r12), %rdx
shlq $0x4, %rdx
callq 0x2360
movl 0x1c(%rsp), %r8d
movq 0x30(%rsp), %rax
movq (%rsp), %r9
movslq %r9d, %r9
leaq (,%r9,8), %rcx
leaq (%rcx,%rcx,8), %rdx
movq 0x18(%r15), %rdi
addq %rdx, %rdi
movl $0x12, %ecx
movq %r12, %rsi
rep  movsl (%rsi), %es:(%rdi)
movq 0x18(%r15), %rdi
movl %r9d, (%rdi,%rdx)
movslq 0x4(%rdi,%rdx), %rcx
movl (%rax,%rcx,4), %ecx
movl %ecx, 0x4(%rdi,%rdx)
incl %r9d
movq %r9, (%rsp)
movl 0x18(%rsp), %r9d
movl 0xc(%r12), %esi
movl 0x10(%r12), %edx
addl %esi, %r13d
movq %r13, 0x8(%rsp)
addl %edx, %ebp
movq %rbp, 0x10(%rsp)
movl 0x8(%r15), %ecx
jmp 0x1a7635
movl -0x4(%rdi,%rbx,4), %esi
movl (%rdi,%rbx,4), %edx
addl %esi, %r9d
addl %edx, %r8d
incq %r14
movslq %ecx, %rdx
addq $0x12, %rbx
cmpq %rdx, %r14
jl 0x1a7546
jmp 0x1a7670
movq $0x0, 0x10(%rsp)
xorl %r9d, %r9d
xorl %r8d, %r8d
movq $0x0, 0x8(%rsp)
movq $0x0, (%rsp)
movq 0x20(%rsp), %rbx
cmpl 0xc(%rbx), %r9d
jne 0x1a7724
cmpl 0x10(%rbx), %r8d
jne 0x1a7724
movq 0x28(%rsp), %rdi
movq %rax, %rsi
movl %r8d, %ebp
callq 0x1ee04f
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 0x1a76ff
movq (%rbx), %rdi
movq 0x28(%rbx), %rsi
movslq %eax, %rdx
shlq $0x4, %rdx
callq 0x1ee21d
movq %rax, 0x28(%rbx)
movq (%rbx), %rdi
movq 0x20(%rbx), %rsi
movslq 0xc(%rbx), %rdx
shlq $0x4, %rdx
callq 0x1ee21d
movq %rax, 0x20(%rbx)
movq (%rbx), %rdi
movq 0x18(%rbx), %rsi
movslq 0x8(%rbx), %rax
shlq $0x3, %rax
leaq (%rax,%rax,8), %rdx
callq 0x1ee21d
movq %rax, 0x18(%rbx)
movq %rbx, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1a73da
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x98a8c(%rip), %rdi     # 0x2401b7
leaq 0x98529(%rip), %rsi     # 0x23fc5b
leaq 0x98aa5(%rip), %rcx     # 0x2401de
movl $0x892, %edx            # imm = 0x892
callq 0x2110