// File: /workspace/github_c_makefile_star2_O3/zenkj[P]luajit-arm64/src/host/buildvm_fold.c
// Function: nexttoken
static uint32_t nexttoken(char **pp, int allowlit, int allowany)
{
  char *p = *pp;
  if (p) {
    uint32_t i;
    char *q = strchr(p, ' ');
    if (q) *q++ = '\0';
    *pp = q;
    if (allowlit && !strncmp(p, "IRFPM_", 6)) {
      for (i = 0; irfpm_names[i]; i++)
	if (!strcmp(irfpm_names[i], p+6))
	  return i;
    } else if (allowlit && !strncmp(p, "IRFL_", 5)) {
      for (i = 0; irfield_names[i]; i++)
	if (!strcmp(irfield_names[i], p+5))
	  return i;
    } else if (allowlit && !strncmp(p, "IRCALL_", 7)) {
      for (i = 0; ircall_names[i]; i++)
	if (!strcmp(ircall_names[i], p+7))
	  return i;
    } else if (allowlit && !strncmp(p, "IRCONV_", 7)) {
      for (i = 0; irt_names[i]; i++) {
	const char *r = strchr(p+7, '_');
	if (r && !strncmp(irt_names[i], p+7, r-(p+7))) {
	  uint32_t j;
	  for (j = 0; irt_names[j]; j++)
	    if (!strcmp(irt_names[j], r+1))
	      return (i << 5) + j;
	}
      }
    } else if (allowlit && *p >= '0' && *p <= '9') {
      for (i = 0; *p >= '0' && *p <= '9'; p++)
	i = i*10 + (*p - '0');
      if (*p == '\0')
	return i;
    } else if (allowany && !strcmp("any", p)) {
      return allowany;
    } else {
      for (i = 0; ir_names[i]; i++)
	if (!strcmp(ir_names[i], p))
	  return i;
    }
    fprintf(stderr, "Error: bad fold definition token \"%s\" at line %d\n", p, lineno);
    exit(1);
  }
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq (%rdi), %rbx
testq %rbx, %rbx
je 0xb18e
movl %edx, %r14d
movl %esi, %ebp
movq %rdi, %r15
movq %rbx, %rdi
movl $0x20, %esi
callq 0x50b0
testq %rax, %rax
je 0xb1a3
movq %rax, %rcx
incq %rcx
movb $0x0, (%rax)
jmp 0xb1a5
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ecx, %ecx
movq %rcx, (%r15)
testl %ebp, %ebp
je 0xb255
leaq 0x73ef(%rip), %rsi      # 0x125a6
movl $0x6, %edx
movq %rbx, %rdi
callq 0x5050
testl %eax, %eax
je 0xb2a8
leaq 0x73da(%rip), %rsi      # 0x125ad
movl $0x5, %edx
movq %rbx, %rdi
callq 0x5050
testl %eax, %eax
je 0xb2e1
leaq 0x73c4(%rip), %rsi      # 0x125b3
movl $0x7, %edx
movq %rbx, %rdi
callq 0x5050
testl %eax, %eax
je 0xb316
leaq 0x73b0(%rip), %rsi      # 0x125bb
movl $0x7, %edx
movq %rbx, %rdi
callq 0x5050
testl %eax, %eax
je 0xb351
movb (%rbx), %al
leal -0x30(%rax), %ecx
cmpb $0x9, %cl
ja 0xb255
xorl %r14d, %r14d
leal (%r14,%r14,4), %ecx
addb $-0x30, %al
movzbl %al, %eax
leal (%rax,%rcx,2), %r14d
movb 0x1(%rbx), %al
incq %rbx
leal -0x30(%rax), %ecx
cmpb $0xa, %cl
jb 0xb22d
testb %al, %al
je 0xb191
jmp 0xb349
testl %r14d, %r14d
je 0xb271
leaq 0x7362(%rip), %rdi      # 0x125c3
movq %rbx, %rsi
callq 0x5110
testl %eax, %eax
je 0xb191
leaq 0x9b38(%rip), %r15      # 0x14db0
movq (%r15), %rdi
testq %rdi, %rdi
je 0xb349
xorl %r14d, %r14d
movq %rbx, %rsi
callq 0x5110
testl %eax, %eax
je 0xb191
incl %r14d
movq (%r15,%r14,8), %rdi
testq %rdi, %rdi
jne 0xb287
jmp 0xb349
leaq 0x9ed1(%rip), %r12      # 0x15180
movq (%r12), %rdi
testq %rdi, %rdi
je 0xb349
leaq 0x6(%rbx), %r15
xorl %r14d, %r14d
movq %r15, %rsi
callq 0x5110
testl %eax, %eax
je 0xb191
incl %r14d
movq (%r12,%r14,8), %rdi
testq %rdi, %rdi
jne 0xb2c3
jmp 0xb349
leaq 0x9f08(%rip), %r12      # 0x151f0
movq (%r12), %rdi
testq %rdi, %rdi
je 0xb349
leaq 0x5(%rbx), %r15
xorl %r14d, %r14d
movq %r15, %rsi
callq 0x5110
testl %eax, %eax
je 0xb191
incl %r14d
movq (%r12,%r14,8), %rdi
testq %rdi, %rdi
jne 0xb2f8
jmp 0xb349
leaq 0x9f63(%rip), %r12      # 0x15280
movq (%r12), %rdi
testq %rdi, %rdi
je 0xb349
leaq 0x7(%rbx), %r15
xorl %r14d, %r14d
movq %r15, %rsi
callq 0x5110
testl %eax, %eax
je 0xb191
incl %r14d
movq (%r12,%r14,8), %rdi
testq %rdi, %rdi
jne 0xb32d
movq %rbx, %rdi
callq 0x5665
leaq 0x9d58(%rip), %rax      # 0x150b0
movq (%rax), %r14
testq %r14, %r14
je 0xb349
leaq 0x7(%rbx), %r15
movq %r15, %rdi
movl $0x5f, %esi
callq 0x50b0
movq %rax, %rcx
movq %r15, 0x18(%rsp)
subq %r15, %rcx
movq %rcx, 0x10(%rsp)
movq %rax, 0x20(%rsp)
leaq 0x1(%rax), %rbp
xorl %r13d, %r13d
movq %r14, 0x8(%rsp)
movq %r14, %rdi
xorl %r12d, %r12d
cmpq $0x0, 0x20(%rsp)
je 0xb3ea
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %rdx
callq 0x5050
testl %eax, %eax
jne 0xb3ea
movl $0x1, %r15d
movl %r13d, %r14d
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
callq 0x5110
testl %eax, %eax
je 0xb191
movl %r15d, %eax
leaq 0x9cd5(%rip), %rcx      # 0x150b0
movq (%rcx,%rax,8), %rdi
incl %r14d
incl %r15d
testq %rdi, %rdi
jne 0xb3c1
incl %r12d
leaq 0x9cbc(%rip), %rax      # 0x150b0
movq (%rax,%r12,8), %rdi
addl $0x20, %r13d
testq %rdi, %rdi
jne 0xb398
jmp 0xb349