// File: /workspace/github_c_makefile_star2_O0/simh[P]simtools/converters/fsio/os8.c
// Function: os8ParseFilespec
int os8ParseFilespec(
  char *ptr,
  struct os8FileSpec *spec,
  int wildcard
)
{
  int state = P_NAME;
  unsigned int i;

  memset(spec, 0, sizeof(struct os8FileSpec));
  memset(&spec->fname, ' ', sizeof(spec->fname));
  memset(&spec->fext, ' ', sizeof(spec->fext));

  if (wildcard == OS8_M_NONAME)
    if (*ptr == '\0') {
      spec->flags = OS8_WC_NAME | OS8_WC_EXT;
      return 1;
    }

  while (state != P_DONE) {
    i = 0;

    switch (state) {
      case P_NAME:
        while ((*ptr != '\0') &&
               (*ptr != '.') &&
               (i < sizeof(spec->fname))) {
          char ch = toupper(*ptr++);

          if (isalnum(ch)) {
            toSixbit(ch, &spec->name[i >> 1], i & 1);
            spec->fname[i++] = ch;
          } else {
            if (ch == '*')
              if (i == 0) {
                spec->flags |= OS8_WC_NAME;
                break;
              }
            return 0;
          }
        }

        switch (*ptr) {
          case '\0':
            state = P_DONE;
            break;

          case '.':
            state = P_EXT;
            ptr++;
            break;

          default:
            return 0;
        }
        break;

      case P_EXT:
        while ((*ptr != '\0') &&
               (i < sizeof(spec->fext))) {
          char ch = toupper(*ptr++);

          if (isalnum(ch)) {
            toSixbit(ch, &spec->ext, i);
            spec->fext[i++] = ch;
          } else {
            if (ch == '*')
              if (i == 0) {
                spec->flags |= OS8_WC_EXT;
                break;
              }
            return 0;
          }
        }

        if (*ptr != '\0')
          return 0;

        state = P_DONE;
        break;
    }
  }
  return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl $0x1, -0x20(%rbp)
movq -0x18(%rbp), %rdi
xorl %esi, %esi
movl $0x12, %edx
callq 0x3170
movq -0x18(%rbp), %rdi
addq $0xa, %rdi
movl $0x20, %esi
movl $0x6, %edx
callq 0x3170
movq -0x18(%rbp), %rdi
addq $0x10, %rdi
movl $0x20, %esi
movl $0x2, %edx
callq 0x3170
cmpl $0x2, -0x1c(%rbp)
jne 0x1362f
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x1362d
movq -0x18(%rbp), %rax
movb $0x3, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x13871
jmp 0x1362f
jmp 0x13631
cmpl $0x0, -0x20(%rbp)
je 0x1386a
movl $0x0, -0x24(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x2c(%rbp)
subl $0x1, %eax
je 0x13660
jmp 0x1364f
movl -0x2c(%rbp), %eax
subl $0x2, %eax
je 0x1378b
jmp 0x13865
jmp 0x13662
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x2d(%rbp)
je 0x13691
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x2e, %ecx
movb %al, -0x2d(%rbp)
je 0x13691
movl -0x24(%rbp), %eax
cmpq $0x6, %rax
setb %al
movb %al, -0x2d(%rbp)
movb -0x2d(%rbp), %al
testb $0x1, %al
jne 0x1369d
jmp 0x13742
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movsbl (%rax), %edi
callq 0x30d0
movb %al, -0x25(%rbp)
callq 0x32e0
movq (%rax), %rax
movsbl -0x25(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x13712
movb -0x25(%rbp), %al
movq -0x18(%rbp), %rsi
addq $0x2, %rsi
movl -0x24(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
shlq %rcx
addq %rcx, %rsi
movl -0x24(%rbp), %edx
andl $0x1, %edx
movsbl %al, %edi
callq 0x13880
movb -0x25(%rbp), %dl
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x24(%rbp)
movl %ecx, %ecx
movb %dl, 0xa(%rax,%rcx)
jmp 0x1373d
movsbl -0x25(%rbp), %eax
cmpl $0x2a, %eax
jne 0x13731
cmpl $0x0, -0x24(%rbp)
jne 0x1372f
movq -0x18(%rbp), %rax
movzbl (%rax), %ecx
orl $0x1, %ecx
movb %cl, (%rax)
jmp 0x13742
jmp 0x13731
movl $0x0, -0x4(%rbp)
jmp 0x13871
jmp 0x13662
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x34(%rbp)
testl %eax, %eax
je 0x1375c
jmp 0x13752
movl -0x34(%rbp), %eax
subl $0x2e, %eax
je 0x13765
jmp 0x1377a
movl $0x0, -0x20(%rbp)
jmp 0x13786
movl $0x2, -0x20(%rbp)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x13786
movl $0x0, -0x4(%rbp)
jmp 0x13871
jmp 0x13865
jmp 0x1378d
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x35(%rbp)
je 0x137ab
movl -0x24(%rbp), %eax
cmpq $0x2, %rax
setb %al
movb %al, -0x35(%rbp)
movb -0x35(%rbp), %al
testb $0x1, %al
jne 0x137b7
jmp 0x13849
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movsbl (%rax), %edi
callq 0x30d0
movb %al, -0x26(%rbp)
callq 0x32e0
movq (%rax), %rax
movsbl -0x26(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x1381c
movb -0x26(%rbp), %al
movq -0x18(%rbp), %rsi
addq $0x8, %rsi
movl -0x24(%rbp), %edx
movsbl %al, %edi
callq 0x13880
movb -0x26(%rbp), %dl
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x24(%rbp)
movl %ecx, %ecx
movb %dl, 0x10(%rax,%rcx)
jmp 0x13844
movsbl -0x26(%rbp), %eax
cmpl $0x2a, %eax
jne 0x1383b
cmpl $0x0, -0x24(%rbp)
jne 0x13839
movq -0x18(%rbp), %rax
movzbl (%rax), %ecx
orl $0x2, %ecx
movb %cl, (%rax)
jmp 0x13849
jmp 0x1383b
movl $0x0, -0x4(%rbp)
jmp 0x13871
jmp 0x1378d
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x1385e
movl $0x0, -0x4(%rbp)
jmp 0x13871
movl $0x0, -0x20(%rbp)
jmp 0x13631
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)