// File: /workspace/github_c_makefile_star2_O0/lh3[P]minimap2/hit.c
// Function: mm_sync_regs
void mm_sync_regs(void *km, int n_regs, mm_reg1_t *regs) // keep mm_reg1_t::{id,parent} in sync; also reset id
{
	int *tmp, i, max_id = -1, n_tmp;
	if (n_regs <= 0) return;
	for (i = 0; i < n_regs; ++i) // NB: doesn't work if mm_reg1_t::id is negative
		max_id = max_id > regs[i].id? max_id : regs[i].id;
	n_tmp = max_id + 1;
	tmp = (int*)kmalloc(km, n_tmp * sizeof(int));
	for (i = 0; i < n_tmp; ++i) tmp[i] = -1;
	for (i = 0; i < n_regs; ++i)
		if (regs[i].id >= 0) tmp[regs[i].id] = i;
	for (i = 0; i < n_regs; ++i) {
		mm_reg1_t *r = &regs[i];
		r->id = i;
		if (r->parent == MM_PARENT_TMP_PRI)
			r->parent = i;
		else if (r->parent >= 0 && tmp[r->parent] >= 0)
			r->parent = tmp[r->parent];
		else r->parent = MM_PARENT_UNSET;
	}
	kfree(km, tmp);
	mm_set_sam_pri(n_regs, regs);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl $0xffffffff, -0x28(%rbp) # imm = 0xFFFFFFFF
cmpl $0x0, -0xc(%rbp)
jg 0x2ae85
jmp 0x2b019
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x2aed7
movl -0x28(%rbp), %eax
movq -0x18(%rbp), %rcx
movslq -0x24(%rbp), %rdx
imulq $0x50, %rdx, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jle 0x2aeb2
movl -0x28(%rbp), %eax
movl %eax, -0x3c(%rbp)
jmp 0x2aec6
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2ae8c
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rdi
movslq -0x2c(%rbp), %rsi
shlq $0x2, %rsi
callq 0x1aae0
movq %rax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x2af1e
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2aefc
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x2af6a
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, (%rax)
jl 0x2af5d
movl -0x24(%rbp), %edx
movq -0x20(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq -0x24(%rbp), %rsi
imulq $0x50, %rsi, %rsi
addq %rsi, %rcx
movslq (%rcx), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x2af5f
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2af25
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x2b000
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl -0x24(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
movq -0x38(%rbp), %rax
cmpl $-0x2, 0x20(%rax)
jne 0x2afaf
movl -0x24(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x20(%rax)
jmp 0x2aff0
movq -0x38(%rbp), %rax
cmpl $0x0, 0x20(%rax)
jl 0x2afe3
movq -0x20(%rbp), %rax
movq -0x38(%rbp), %rcx
movslq 0x20(%rcx), %rcx
cmpl $0x0, (%rax,%rcx,4)
jl 0x2afe3
movq -0x20(%rbp), %rax
movq -0x38(%rbp), %rcx
movslq 0x20(%rcx), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x20(%rax)
jmp 0x2afee
movq -0x38(%rbp), %rax
movl $0xffffffff, 0x20(%rax) # imm = 0xFFFFFFFF
jmp 0x2aff0
jmp 0x2aff2
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2af71
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x1a8c0
movl -0xc(%rbp), %edi
movq -0x18(%rbp), %rsi
callq 0x2ada0
addq $0x40, %rsp
popq %rbp
retq
nop