// File: /workspace/github_c_makefile_star2_O0/lh3[P]miniprot/hit.c
// Function: mp_sync_regs
void mp_sync_regs(void *km, int n_regs, mp_reg1_t *regs) // keep mp_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 mp_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) {
		mp_reg1_t *r = &regs[i];
		r->id = i;
		if (r->parent == MP_PARENT_TMP_PRI)
			r->parent = i;
		else if (r->parent >= 0 && tmp[r->parent] >= 0)
			r->parent = tmp[r->parent];
		else r->parent = MP_PARENT_UNSET;
	}
	kfree(km, tmp);
}

// 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 0x1b105
jmp 0x1b292
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x1b159
movl -0x28(%rbp), %eax
movq -0x18(%rbp), %rcx
movslq -0x24(%rbp), %rdx
imulq $0x68, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
jle 0x1b133
movl -0x28(%rbp), %eax
movl %eax, -0x3c(%rbp)
jmp 0x1b148
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%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 0x1b10c
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rdi
movslq -0x2c(%rbp), %rsi
shlq $0x2, %rsi
callq 0xaeb0
movq %rax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x1b1a0
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 0x1b17e
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x1b1ee
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x8(%rax)
jl 0x1b1e1
movl -0x24(%rbp), %edx
movq -0x20(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq -0x24(%rbp), %rsi
imulq $0x68, %rsi, %rsi
addq %rsi, %rcx
movslq 0x8(%rcx), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x1b1e3
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1b1a7
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x1b285
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl -0x24(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x38(%rbp), %rax
cmpl $-0x2, 0xc(%rax)
jne 0x1b234
movl -0x24(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0xc(%rax)
jmp 0x1b275
movq -0x38(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jl 0x1b268
movq -0x20(%rbp), %rax
movq -0x38(%rbp), %rcx
movslq 0xc(%rcx), %rcx
cmpl $0x0, (%rax,%rcx,4)
jl 0x1b268
movq -0x20(%rbp), %rax
movq -0x38(%rbp), %rcx
movslq 0xc(%rcx), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0xc(%rax)
jmp 0x1b273
movq -0x38(%rbp), %rax
movl $0xffffffff, 0xc(%rax)  # imm = 0xFFFFFFFF
jmp 0x1b275
jmp 0x1b277
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1b1f5
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xac90
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)