// File: /workspace/github_cpp_makefile_star2_O1/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 $0x48, %rsp
movq %rsi, %rax
movslq 0x8(%rsi), %rsi
testq %rsi, %rsi
je 0x19e93f
shlq $0x2, %rsi
movq %rdi, 0x30(%rsp)
movq %rax, 0x8(%rsp)
callq 0x1e36fd
movq 0x8(%rsp), %r8
cmpl $0x0, 0x8(%r8)
jle 0x19e7ff
movq 0x18(%r8), %rdi
addq $0x44, %rdi
xorl %ecx, %ecx
xorl %edx, %edx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
testb $0x1, 0x1(%rdi)
jne 0x19e7ef
cmpl $0x0, -0x38(%rdi)
je 0x19e7ef
movl %edx, (%rax,%rcx,4)
incl %edx
incq %rcx
movslq 0x8(%r8), %rsi
addq $0x48, %rdi
cmpq %rsi, %rcx
jl 0x19e7d7
cmpl $0x0, 0x8(%r8)
jle 0x19e94e
xorl %r14d, %r14d
movl $0x4, %ebx
movq $0x0, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
xorl %ebp, %ebp
xorl %r13d, %r13d
movq $0x0, 0x20(%rsp)
movq %rax, 0x38(%rsp)
movq 0x18(%r8), %rcx
cmpl $0x0, (%rax,%r14,4)
js 0x19e921
leaq (%rcx,%rbx,4), %r12
addq $-0x10, %r12
movq %rcx, 0x40(%rsp)
movq 0x28(%r8), %rcx
movq 0x20(%rsp), %r15
movslq %r15d, %r15
movq %r15, %rdi
shlq $0x4, %rdi
addq %rcx, %rdi
movslq %ebp, %rsi
shlq $0x4, %rsi
addq %rcx, %rsi
movslq 0x10(%r12), %rdx
shlq $0x4, %rdx
callq 0x2360
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movl %ebp, 0x2c(%rsp)
movq 0x18(%rsp), %rbp
movslq %ebp, %rbp
movq %rbp, %rdi
shlq $0x4, %rdi
addq %rax, %rdi
movslq %r13d, %rsi
shlq $0x4, %rsi
addq %rax, %rsi
movslq 0xc(%r12), %rdx
shlq $0x4, %rdx
callq 0x2360
movq 0x38(%rsp), %rax
movq 0x8(%rsp), %r8
movq 0x10(%rsp), %r10
movslq %r10d, %r10
leaq (,%r10,8), %rcx
leaq (%rcx,%rcx,8), %r9
movq 0x18(%r8), %rdi
addq %r9, %rdi
movl $0x12, %ecx
movq %r12, %rsi
rep  movsl (%rsi), %es:(%rdi)
movq 0x18(%r8), %rcx
movl %r10d, (%rcx,%r9)
movslq 0x4(%rcx,%r9), %rdx
movl (%rax,%rdx,4), %edx
movl %edx, 0x4(%rcx,%r9)
movq 0x40(%rsp), %rcx
incl %r10d
movq %r10, 0x10(%rsp)
addl 0xc(%r12), %ebp
movq %rbp, 0x18(%rsp)
movl 0x2c(%rsp), %ebp
addl 0x10(%r12), %r15d
movq %r15, 0x20(%rsp)
addl -0x4(%rcx,%rbx,4), %r13d
addl (%rcx,%rbx,4), %ebp
incq %r14
movslq 0x8(%r8), %rcx
addq $0x12, %rbx
cmpq %rcx, %r14
jl 0x19e837
jmp 0x19e96e
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq $0x0, 0x20(%rsp)
xorl %r13d, %r13d
xorl %ebp, %ebp
movq $0x0, 0x18(%rsp)
movq $0x0, 0x10(%rsp)
cmpl 0xc(%r8), %r13d
jne 0x19ea3e
cmpl 0x10(%r8), %ebp
jne 0x19ea3e
movq 0x30(%rsp), %rdi
movq %rax, %rsi
callq 0x1e3632
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %rax
movl %eax, 0x8(%rcx)
movq 0x18(%rsp), %rax
movl %eax, 0xc(%rcx)
movq 0x20(%rsp), %rax
movl %eax, 0x10(%rcx)
cmpl %ebp, %eax
je 0x19ea28
movq (%rcx), %rdi
movq 0x28(%rcx), %rsi
movslq %eax, %rdx
shlq $0x4, %rdx
callq 0x1e3800
movq 0x8(%rsp), %rcx
movq %rax, 0x28(%rcx)
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rsi
movq 0x8(%rsp), %rax
movslq 0xc(%rax), %rdx
shlq $0x4, %rdx
callq 0x1e3800
movq 0x8(%rsp), %rcx
movq %rax, 0x20(%rcx)
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rsi
movq 0x8(%rsp), %rax
movslq 0x8(%rax), %rax
shlq $0x3, %rax
leaq (%rax,%rax,8), %rdx
callq 0x1e3800
movq 0x8(%rsp), %rcx
movq %rax, 0x18(%rcx)
movq %rcx, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x19e6ce
leaq 0x954a2(%rip), %rdi     # 0x233ee7
leaq 0x94f3f(%rip), %rsi     # 0x23398b
leaq 0x954bb(%rip), %rcx     # 0x233f0e
movl $0x892, %edx            # imm = 0x892
callq 0x2110