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

  memset(spec, 0, sizeof(struct rt11FileSpec));
  memset(&spec->fname, ' ', sizeof(spec->fname));
  memset(&spec->ftype, ' ', sizeof(spec->ftype));

  if (wildcard == RT11_M_NONAME)
    if (*ptr == '\0') {
      spec->flags = RT11_WC_NAME | RT11_WC_TYPE;
      spec->fname[0] = spec->ftype[0] = '*';
      return 1;
    }

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

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

          spec->fname[i++] = ch;

          if (!isalnum(ch))
            switch (ch) {
              case '*':
              case '%':
                if (wildcard) {
                  spec->flags |= RT11_WC_NAME;
                  break;
                }
                /* FALLTHROUGH */

              default:
                return 0;
            }
        }

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

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

          default:
            return 0;
        }
        break;

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

          spec->ftype[i++] = ch;

          if (!isalnum(ch))
            switch (ch) {
              case '*':
              case '%':
                if (wildcard) {
                  spec->flags |= RT11_WC_TYPE;
                  break;
                }
                /* FALLTHROUGH */

              default:
                return 0;
            }
        }

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

        state = P_DONE;
        break;
    }
  }

  if ((spec->flags & RT11_WC_NAME) == 0) {
    spec->name[0] = ascR50(&spec->fname[0]);
    spec->name[1] = ascR50(&spec->fname[3]);
  }
  if ((spec->flags & RT11_WC_TYPE) == 0)
    spec->type = ascR50(&spec->ftype[0]);

  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 $0x8, %rdi
movl $0x20, %esi
movl $0x6, %edx
callq 0x3170
movq -0x18(%rbp), %rdi
addq $0xe, %rdi
movl $0x20, %esi
movl $0x3, %edx
callq 0x3170
cmpl $0x2, -0x1c(%rbp)
jne 0xb9bf
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0xb9bd
movq -0x18(%rbp), %rax
movb $0x3, (%rax)
movq -0x18(%rbp), %rax
movb $0x2a, 0xe(%rax)
movq -0x18(%rbp), %rax
movb $0x2a, 0x8(%rax)
movl $0x1, -0x4(%rbp)
jmp 0xbc44
jmp 0xb9bf
jmp 0xb9c1
cmpl $0x0, -0x20(%rbp)
je 0xbbd3
movl $0x0, -0x24(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x2c(%rbp)
subl $0x1, %eax
je 0xb9f0
jmp 0xb9df
movl -0x2c(%rbp), %eax
subl $0x2, %eax
je 0xbafe
jmp 0xbbce
jmp 0xb9f2
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x2d(%rbp)
je 0xba21
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x2e, %ecx
movb %al, -0x2d(%rbp)
je 0xba21
movl -0x24(%rbp), %eax
cmpq $0x6, %rax
setb %al
movb %al, -0x2d(%rbp)
movb -0x2d(%rbp), %al
testb $0x1, %al
jne 0xba2d
jmp 0xbab5
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movb (%rax), %al
movb %al, -0x25(%rbp)
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, 0x8(%rax,%rcx)
callq 0x32e0
movq (%rax), %rax
movsbl -0x25(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0xbab0
movsbl -0x25(%rbp), %eax
movl %eax, -0x34(%rbp)
subl $0x25, %eax
je 0xba8c
jmp 0xba82
movl -0x34(%rbp), %eax
subl $0x2a, %eax
jne 0xbaa2
jmp 0xba8c
cmpl $0x0, -0x1c(%rbp)
je 0xbaa0
movq -0x18(%rbp), %rax
movzbl (%rax), %ecx
orl $0x1, %ecx
movb %cl, (%rax)
jmp 0xbaae
jmp 0xbaa2
movl $0x0, -0x4(%rbp)
jmp 0xbc44
jmp 0xbab0
jmp 0xb9f2
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x38(%rbp)
testl %eax, %eax
je 0xbacf
jmp 0xbac5
movl -0x38(%rbp), %eax
subl $0x2e, %eax
je 0xbad8
jmp 0xbaed
movl $0x0, -0x20(%rbp)
jmp 0xbaf9
movl $0x2, -0x20(%rbp)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0xbaf9
movl $0x0, -0x4(%rbp)
jmp 0xbc44
jmp 0xbbce
jmp 0xbb00
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x39(%rbp)
je 0xbb1e
movl -0x24(%rbp), %eax
cmpq $0x3, %rax
setb %al
movb %al, -0x39(%rbp)
movb -0x39(%rbp), %al
testb $0x1, %al
jne 0xbb2a
jmp 0xbbb2
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movb (%rax), %al
movb %al, -0x26(%rbp)
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, 0xe(%rax,%rcx)
callq 0x32e0
movq (%rax), %rax
movsbl -0x26(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0xbbad
movsbl -0x26(%rbp), %eax
movl %eax, -0x40(%rbp)
subl $0x25, %eax
je 0xbb89
jmp 0xbb7f
movl -0x40(%rbp), %eax
subl $0x2a, %eax
jne 0xbb9f
jmp 0xbb89
cmpl $0x0, -0x1c(%rbp)
je 0xbb9d
movq -0x18(%rbp), %rax
movzbl (%rax), %ecx
orl $0x2, %ecx
movb %cl, (%rax)
jmp 0xbbab
jmp 0xbb9f
movl $0x0, -0x4(%rbp)
jmp 0xbc44
jmp 0xbbad
jmp 0xbb00
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xbbc7
movl $0x0, -0x4(%rbp)
jmp 0xbc44
movl $0x0, -0x20(%rbp)
jmp 0xb9c1
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0xbc16
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
callq 0x5d50
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x2(%rax)
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
addq $0x3, %rdi
callq 0x5d50
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x4(%rax)
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0xbc3d
movq -0x18(%rbp), %rdi
addq $0xe, %rdi
callq 0x5d50
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x6(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)