// File: /workspace/github_c_makefile_star2_O2/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
pushq %rax
movq (%rdi), %rbx
testq %rbx, %rbx
je 0xa7f0
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %r15
pushq $0x20
popq %rsi
movq %rbx, %rdi
callq 0x50b0
testq %rax, %rax
je 0xa803
movq %rax, %rcx
incq %rcx
movb $0x0, (%rax)
jmp 0xa805
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ecx, %ecx
movq %rcx, (%r15)
testl %r14d, %r14d
je 0xa8a1
leaq 0x6d8e(%rip), %rsi      # 0x115a6
pushq $0x6
popq %rdx
movq %rbx, %rdi
callq 0x5050
testl %eax, %eax
je 0xa8e8
leaq 0x6d7b(%rip), %rsi      # 0x115ad
pushq $0x5
popq %rdx
movq %rbx, %rdi
callq 0x5050
testl %eax, %eax
je 0xa918
leaq 0x6d67(%rip), %rsi      # 0x115b3
pushq $0x7
popq %rdx
movq %rbx, %rdi
callq 0x5050
testl %eax, %eax
je 0xa948
leaq 0x6d55(%rip), %rsi      # 0x115bb
pushq $0x7
popq %rdx
movq %rbx, %rdi
callq 0x5050
testl %eax, %eax
je 0xa978
movb (%rbx), %al
leal -0x30(%rax), %ecx
cmpb $0x9, %cl
ja 0xa8a1
xorl %ebp, %ebp
leal -0x30(%rax), %ecx
cmpb $0x9, %cl
ja 0xa9f5
imull $0xa, %ebp, %eax
movzbl %cl, %ebp
addl %eax, %ebp
movb 0x1(%rbx), %al
incq %rbx
jmp 0xa885
testl %ebp, %ebp
je 0xa8bc
leaq 0x6d17(%rip), %rdi      # 0x115c3
movq %rbx, %rsi
callq 0x5110
testl %eax, %eax
je 0xa7f2
xorl %ebp, %ebp
leaq 0xa4eb(%rip), %r14      # 0x14db0
movl %ebp, %eax
movq (%r14,%rax,8), %rdi
testq %rdi, %rdi
je 0xa9fd
movq %rbx, %rsi
callq 0x5110
testl %eax, %eax
je 0xa7f2
incl %ebp
jmp 0xa8c5
leaq 0x6(%rbx), %r14
xorl %ebp, %ebp
leaq 0xa88b(%rip), %r15      # 0x15180
movl %ebp, %eax
movq (%r15,%rax,8), %rdi
testq %rdi, %rdi
je 0xa9fd
movq %r14, %rsi
callq 0x5110
testl %eax, %eax
je 0xa7f2
incl %ebp
jmp 0xa8f5
leaq 0x5(%rbx), %r14
xorl %ebp, %ebp
leaq 0xa8cb(%rip), %r15      # 0x151f0
movl %ebp, %eax
movq (%r15,%rax,8), %rdi
testq %rdi, %rdi
je 0xa9fd
movq %r14, %rsi
callq 0x5110
testl %eax, %eax
je 0xa7f2
incl %ebp
jmp 0xa925
leaq 0x7(%rbx), %r14
xorl %ebp, %ebp
leaq 0xa92b(%rip), %r15      # 0x15280
movl %ebp, %eax
movq (%r15,%rax,8), %rdi
testq %rdi, %rdi
je 0xa9fd
movq %r14, %rsi
callq 0x5110
testl %eax, %eax
je 0xa7f2
incl %ebp
jmp 0xa955
leaq 0x7(%rbx), %rax
movq %rax, (%rsp)
xorl %ebp, %ebp
leaq 0xa727(%rip), %r15      # 0x150b0
xorl %r14d, %r14d
movl %r14d, %eax
movq (%r15,%rax,8), %r13
testq %r13, %r13
je 0xa9fd
movq (%rsp), %rdi
pushq $0x5f
popq %rsi
callq 0x50b0
testq %rax, %rax
je 0xa9c2
movq %rax, %r12
movq %rax, %rdx
movq (%rsp), %rsi
subq %rsi, %rdx
movq %r13, %rdi
callq 0x5050
testl %eax, %eax
je 0xa9ca
incl %r14d
addl $0x20, %ebp
jmp 0xa98c
incq %r12
xorl %r13d, %r13d
movl %r13d, %eax
movq (%r15,%rax,8), %rdi
testq %rdi, %rdi
je 0xa9c2
movq %r12, %rsi
callq 0x5110
testl %eax, %eax
je 0xa9ed
incl %r13d
jmp 0xa9d0
addl %r13d, %ebp
jmp 0xa7f2
testb %al, %al
je 0xa7f2
movq 0xb5f4(%rip), %rax      # 0x15ff8
movq (%rax), %rdi
movl 0xd893(%rip), %ecx      # 0x182a0
leaq 0x6bb3(%rip), %rsi      # 0x115c7
movq %rbx, %rdx
xorl %eax, %eax
callq 0x5130
pushq $0x1
popq %rdi
callq 0x51c0