// File: /workspace/github_c_makefile_star2_O0/zenkj[P]luajit-arm64/src/host/buildvm_fold.c
// Function: tryhash
static int tryhash(uint32_t *htab, uint32_t sz, uint32_t r, int dorol)
{
  uint32_t i;
  if (dorol && ((r & 31) == 0 || (r>>5) == 0))
    return 0;  /* Avoid zero rotates. */
  memset(htab, 0xff, (sz+1)*sizeof(uint32_t));
  for (i = 0; i < nkeys; i++) {
    uint32_t key = foldkeys[i];
    uint32_t k = key & 0xffffff;
    uint32_t h = (dorol ? lj_rol(lj_rol(k, r>>5) - k, r&31) :
			  (((k << (r>>5)) - k) << (r&31))) % sz;
    if (htab[h] != 0xffffffff) {  /* Collision on primary slot. */
      if (htab[h+1] != 0xffffffff) {  /* Collision on secondary slot. */
	/* Try to move the colliding key, if possible. */
	if (h < sz-1 && htab[h+2] == 0xffffffff) {
	  uint32_t k2 = htab[h+1] & 0xffffff;
	  uint32_t h2 = (dorol ? lj_rol(lj_rol(k2, r>>5) - k2, r&31) :
				 (((k2 << (r>>5)) - k2) << (r&31))) % sz;
	  if (h2 != h+1) return 0;  /* Cannot resolve collision. */
	  htab[h+2] = htab[h+1];  /* Move colliding key to secondary slot. */
	} else {
	  return 0;  /* Collision. */
	}
      }
      htab[h+1] = key;
    } else {
      htab[h] = key;
    }
  }
  return 1;  /* Success, all keys could be stored. */
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movl %esi, 0x34(%rsp)
movl %edx, 0x30(%rsp)
movl %ecx, 0x2c(%rsp)
cmpl $0x0, 0x2c(%rsp)
je 0xee81
movl 0x30(%rsp), %eax
andl $0x1f, %eax
cmpl $0x0, %eax
je 0xee74
movl 0x30(%rsp), %eax
shrl $0x5, %eax
cmpl $0x0, %eax
jne 0xee81
movl $0x0, 0x44(%rsp)
jmp 0xf142
movq 0x38(%rsp), %rdi
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edx
shlq $0x2, %rdx
movl $0xff, %esi
callq 0x50c0
movl $0x0, 0x28(%rsp)
movl 0x28(%rsp), %eax
cmpl 0xd3e7(%rip), %eax      # 0x1c298
jae 0xf13a
movl 0x28(%rsp), %eax
movl %eax, %ecx
leaq 0xd3dc(%rip), %rax      # 0x1c2a0
movl (%rax,%rcx,4), %eax
movl %eax, 0x24(%rsp)
movl 0x24(%rsp), %eax
andl $0xffffff, %eax         # imm = 0xFFFFFF
movl %eax, 0x20(%rsp)
cmpl $0x0, 0x2c(%rsp)
je 0xef64
movl 0x20(%rsp), %eax
movl 0x30(%rsp), %ecx
shrl $0x5, %ecx
shll %cl, %eax
movl 0x20(%rsp), %edx
movl 0x30(%rsp), %esi
shrl $0x5, %esi
xorl %ecx, %ecx
subl %esi, %ecx
movslq %ecx, %rcx
andq $0x1f, %rcx
shrl %cl, %edx
movl %edx, %ecx
orl %ecx, %eax
subl 0x20(%rsp), %eax
movl 0x30(%rsp), %ecx
andl $0x1f, %ecx
shll %cl, %eax
movl 0x20(%rsp), %edx
movl 0x30(%rsp), %ecx
shrl $0x5, %ecx
shll %cl, %edx
movl 0x20(%rsp), %esi
movl 0x30(%rsp), %edi
shrl $0x5, %edi
xorl %ecx, %ecx
subl %edi, %ecx
movslq %ecx, %rcx
andq $0x1f, %rcx
shrl %cl, %esi
movl %esi, %ecx
orl %ecx, %edx
subl 0x20(%rsp), %edx
movl 0x30(%rsp), %esi
andl $0x1f, %esi
xorl %ecx, %ecx
subl %esi, %ecx
movslq %ecx, %rcx
andq $0x1f, %rcx
shrl %cl, %edx
movl %edx, %ecx
orl %ecx, %eax
movl %eax, 0x10(%rsp)
jmp 0xef82
movl 0x20(%rsp), %eax
movl 0x30(%rsp), %ecx
shrl $0x5, %ecx
shll %cl, %eax
subl 0x20(%rsp), %eax
movl 0x30(%rsp), %ecx
andl $0x1f, %ecx
shll %cl, %eax
movl %eax, 0x10(%rsp)
movl 0x10(%rsp), %eax
xorl %edx, %edx
divl 0x34(%rsp)
movl %edx, 0x1c(%rsp)
movq 0x38(%rsp), %rax
movl 0x1c(%rsp), %ecx
cmpl $-0x1, (%rax,%rcx,4)
je 0xf118
movq 0x38(%rsp), %rax
movl 0x1c(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
cmpl $-0x1, (%rax,%rcx,4)
je 0xf101
movl 0x1c(%rsp), %eax
movl 0x34(%rsp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jae 0xf0f5
movq 0x38(%rsp), %rax
movl 0x1c(%rsp), %ecx
addl $0x2, %ecx
movl %ecx, %ecx
cmpl $-0x1, (%rax,%rcx,4)
jne 0xf0f5
movq 0x38(%rsp), %rax
movl 0x1c(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
andl $0xffffff, %eax         # imm = 0xFFFFFF
movl %eax, 0x18(%rsp)
cmpl $0x0, 0x2c(%rsp)
je 0xf08c
movl 0x18(%rsp), %eax
movl 0x30(%rsp), %ecx
shrl $0x5, %ecx
shll %cl, %eax
movl 0x18(%rsp), %edx
movl 0x30(%rsp), %esi
shrl $0x5, %esi
xorl %ecx, %ecx
subl %esi, %ecx
movslq %ecx, %rcx
andq $0x1f, %rcx
shrl %cl, %edx
movl %edx, %ecx
orl %ecx, %eax
subl 0x18(%rsp), %eax
movl 0x30(%rsp), %ecx
andl $0x1f, %ecx
shll %cl, %eax
movl 0x18(%rsp), %edx
movl 0x30(%rsp), %ecx
shrl $0x5, %ecx
shll %cl, %edx
movl 0x18(%rsp), %esi
movl 0x30(%rsp), %edi
shrl $0x5, %edi
xorl %ecx, %ecx
subl %edi, %ecx
movslq %ecx, %rcx
andq $0x1f, %rcx
shrl %cl, %esi
movl %esi, %ecx
orl %ecx, %edx
subl 0x18(%rsp), %edx
movl 0x30(%rsp), %esi
andl $0x1f, %esi
xorl %ecx, %ecx
subl %esi, %ecx
movslq %ecx, %rcx
andq $0x1f, %rcx
shrl %cl, %edx
movl %edx, %ecx
orl %ecx, %eax
movl %eax, 0xc(%rsp)
jmp 0xf0aa
movl 0x18(%rsp), %eax
movl 0x30(%rsp), %ecx
shrl $0x5, %ecx
shll %cl, %eax
subl 0x18(%rsp), %eax
movl 0x30(%rsp), %ecx
andl $0x1f, %ecx
shll %cl, %eax
movl %eax, 0xc(%rsp)
movl 0xc(%rsp), %eax
xorl %edx, %edx
divl 0x34(%rsp)
movl %edx, 0x14(%rsp)
movl 0x14(%rsp), %eax
movl 0x1c(%rsp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
je 0xf0d1
movl $0x0, 0x44(%rsp)
jmp 0xf142
movq 0x38(%rsp), %rax
movl 0x1c(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %edx
movq 0x38(%rsp), %rax
movl 0x1c(%rsp), %ecx
addl $0x2, %ecx
movl %ecx, %ecx
movl %edx, (%rax,%rcx,4)
jmp 0xf0ff
movl $0x0, 0x44(%rsp)
jmp 0xf142
jmp 0xf101
movl 0x24(%rsp), %edx
movq 0x38(%rsp), %rax
movl 0x1c(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movl %edx, (%rax,%rcx,4)
jmp 0xf128
movl 0x24(%rsp), %edx
movq 0x38(%rsp), %rax
movl 0x1c(%rsp), %ecx
movl %edx, (%rax,%rcx,4)
jmp 0xf12a
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
jmp 0xeea7
movl $0x1, 0x44(%rsp)
movl 0x44(%rsp), %eax
addq $0x48, %rsp
retq
nopl (%rax,%rax)