// File: 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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x28b7bf
jmp 0x28baec
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq 0x8(%rax), %rsi
shlq $0x2, %rsi
callq 0x30e4f0
movq %rax, -0x30(%rbp)
movl $0x0, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x28b857
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movslq -0x14(%rbp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movq -0x38(%rbp), %rax
movl 0x44(%rax), %eax
shrl $0x8, %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x28b834
movq -0x38(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jne 0x28b836
jmp 0x28b84c
movl -0x18(%rbp), %edx
movl %edx, %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
movq -0x30(%rbp), %rax
movslq -0x14(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x28b7e6
movl $0x0, -0x20(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x28b9e0
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movslq -0x14(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jl 0x28b9b8
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
movslq -0x20(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
movslq -0x28(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rsi
movq -0x40(%rbp), %rax
movslq 0x10(%rax), %rdx
shlq $0x4, %rdx
callq 0x2350
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movslq -0x1c(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
movslq -0x24(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rsi
movq -0x40(%rbp), %rax
movslq 0xc(%rax), %rdx
shlq $0x4, %rdx
callq 0x2350
movq -0x40(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movslq -0x18(%rbp), %rax
imulq $0x48, %rax, %rax
addq %rax, %rdi
movl $0x48, %edx
callq 0x2180
movl -0x18(%rbp), %ecx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rdx
imulq $0x48, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
movslq -0x18(%rbp), %rdx
imulq $0x48, %rdx, %rdx
addq %rdx, %rcx
movslq 0x4(%rcx), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rdx
imulq $0x48, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
movq -0x40(%rbp), %rax
movl 0xc(%rax), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x40(%rbp), %rax
movl 0x10(%rax), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x40(%rbp), %rax
movl 0xc(%rax), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x40(%rbp), %rax
movl 0x10(%rax), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x28b881
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rdx
xorl %eax, %eax
cmpl 0xc(%rdx), %ecx
movb %al, -0x41(%rbp)
jne 0x28ba01
movl -0x28(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x10(%rcx), %eax
sete %al
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
testb $0x1, %al
jne 0x28ba0a
jmp 0x28ba0c
jmp 0x28ba2b
leaq 0x105378(%rip), %rdi    # 0x390d8b
leaq 0x104e15(%rip), %rsi    # 0x39082f
movl $0x892, %edx            # imm = 0x892
leaq 0x10538c(%rip), %rcx    # 0x390db2
callq 0x2130
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x30e2d0
movl -0x18(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0x1c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xc(%rax)
movl -0x20(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
movl -0x20(%rbp), %eax
cmpl -0x28(%rbp), %eax
je 0x28bae3
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
movq -0x10(%rbp), %rax
movslq 0x10(%rax), %rdx
shlq $0x4, %rdx
callq 0x30e740
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x10(%rbp), %rax
movslq 0xc(%rax), %rdx
shlq $0x4, %rdx
callq 0x30e740
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x10(%rbp), %rax
movslq 0x8(%rax), %rax
imulq $0x48, %rax, %rdx
callq 0x30e740
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rdi
callq 0x28b670
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)