// File: /workspace/github_c_makefile_star2_O0/singpolyma[P]mnemonicode/mnemonic.c
// Function: mn_next_word_index
mn_index
mn_next_word_index (char **ptr)
{
  char *wordstart;
  char wordbuf[MN_WORD_BUFLEN];
  int i = 0;
  char c;
  mn_index idx;

  while (**ptr && !isalpha (**ptr))	/* skip separator chars */
    (*ptr)++;
  wordstart = *ptr;		/* save for error reporting */
  while (**ptr && isalpha (**ptr) && i < MN_WORD_BUFLEN - 1)
    {
      c = *(*ptr)++;
      if (c >= 'A' && c <= 'Z')
	c += 'a' - 'A';		/* convert to lowercase */
      wordbuf[i++] = c;
    }
  wordbuf[i] = '\0';
  while (**ptr && isalpha (**ptr))	/* skip tail of long words */
    (*ptr)++;
  while (**ptr && !isalpha (**ptr))	/* skip separators */
    (*ptr)++;

  if (wordbuf[0] == '\0')
    return 0;			/* EOF, no word found */

  for (idx = 1; idx <= MN_WORDS; idx++)
    {
      if (!strcmp (wordbuf, mn_words[idx]))
	return idx;
      /* FIXME: some fancy code should go here
         to accept misspellings and soundalikes.
         (replacing the linear search would also be nice) */
    }
  *ptr = wordstart;
  return 0;			/* not found */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x44(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x4d(%rbp)
je 0xb500
callq 0xb080
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
movb %al, -0x4d(%rbp)
movb -0x4d(%rbp), %al
testb $0x1, %al
jne 0xb509
jmp 0xb519
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
jmp 0xb4c3
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x4e(%rbp)
je 0xb56b
callq 0xb080
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %ecx
andl $0x400, %ecx            # imm = 0x400
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x4e(%rbp)
je 0xb56b
cmpl $0x18, -0x44(%rbp)
setl %al
movb %al, -0x4e(%rbp)
movb -0x4e(%rbp), %al
testb $0x1, %al
jne 0xb574
jmp 0xb5bf
movq -0x10(%rbp), %rcx
movq (%rcx), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, (%rcx)
movb (%rax), %al
movb %al, -0x45(%rbp)
movsbl -0x45(%rbp), %eax
cmpl $0x41, %eax
jl 0xb5a6
movsbl -0x45(%rbp), %eax
cmpl $0x5a, %eax
jg 0xb5a6
movsbl -0x45(%rbp), %eax
addl $0x20, %eax
movb %al, -0x45(%rbp)
movb -0x45(%rbp), %cl
movl -0x44(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x44(%rbp)
cltq
movb %cl, -0x40(%rbp,%rax)
jmp 0xb524
movslq -0x44(%rbp), %rax
movb $0x0, -0x40(%rbp,%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x4f(%rbp)
je 0xb603
callq 0xb080
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
setne %al
movb %al, -0x4f(%rbp)
movb -0x4f(%rbp), %al
testb $0x1, %al
jne 0xb60c
jmp 0xb61c
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
jmp 0xb5c8
jmp 0xb61e
movq -0x10(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x50(%rbp)
je 0xb65b
callq 0xb080
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
movb %al, -0x50(%rbp)
movb -0x50(%rbp), %al
testb $0x1, %al
jne 0xb664
jmp 0xb674
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
jmp 0xb61e
movsbl -0x40(%rbp), %eax
cmpl $0x0, %eax
jne 0xb686
movl $0x0, -0x4(%rbp)
jmp 0xb6db
movl $0x1, -0x4c(%rbp)
cmpl $0x661, -0x4c(%rbp)     # imm = 0x661
ja 0xb6c9
leaq -0x40(%rbp), %rdi
movl -0x4c(%rbp), %eax
movl %eax, %ecx
leaq 0x49ca(%rip), %rax      # 0x10070
movq (%rax,%rcx,8), %rsi
callq 0xb050
cmpl $0x0, %eax
jne 0xb6bc
movl -0x4c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xb6db
jmp 0xb6be
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0xb68d
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)