// File: /workspace/github_c_makefile_star2_O3/simh[P]simtools/crossassemblers/macro11/parse.c
// Function: get_symbol
char           *get_symbol(
    char *cp,
    char **endp,
    int *islocal)
{
    int             len;
    char           *symcp;
    int             digits = 0;

    cp = skipwhite(cp);                /* Skip leading whitespace */

    if (!issym((unsigned char)*cp))
        return NULL;

    digits = 0;
    if (isdigit((unsigned char)*cp))
        digits = 2;                    /* Think about digit count */

    for (symcp = cp + 1; issym((unsigned char)*symcp); symcp++) {
        if (!isdigit((unsigned char)*symcp)) /* Not a digit? */
            digits--;                  /* Make a note. */
    }

    if (digits == 2)
        return NULL;                   /* Not a symbol, it's a digit string */

    if (endp)
        *endp = symcp;

    len = (int) (symcp - cp);

    /* Now limit length */
    if (len > symbol_len)
        len = symbol_len;

    symcp = memcheck(malloc(len + 1));

    memcpy(symcp, cp, len);
    symcp[len] = 0;
    upcase(symcp);

    if (islocal) {
        *islocal = 0;

        /* Turn to local label format */
        if (digits == 1) {
            if (symcp[len - 1] == '$') {
                char           *newsym = memcheck(malloc(32));  /* Overkill */

                sprintf(newsym, "%ld$%d", strtol(symcp, NULL, 10), lsb);
                if (enabl_debug && lstfile) {
                    fprintf(lstfile, "lsb %d: %s -> %s\n",
                            lsb, symcp, newsym);
                }
                free(symcp);
                symcp = newsym;
                if (islocal)
                    *islocal = SYMBOLFLAG_LOCAL;
                lsb_used++;
            } else {
                free(symcp);
                return NULL;
            }
        }
    } else {
        /* disallow local label format */
        if (isdigit((unsigned char)*symcp)) {
            free(symcp);
            return NULL;
        }
    }

    return symcp;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, (%rsp)
movq %rsi, %r12
movq %rdi, %r14
movzbl (%r14), %ebx
cmpl $0x20, %ebx
je 0x8b1c
cmpl $0x9, %ebx
jne 0x8b21
incq %r14
jmp 0x8b0e
callq 0x2300
movq %rax, %r15
movq (%rax), %rax
movzwl (%rax,%rbx,2), %ebp
testl $0xc00, %ebp            # imm = 0xC00
je 0x8ca5
shrl $0xa, %ebp
andl $0x2, %ebp
leaq 0xeb37(%rip), %rcx      # 0x17680
movl (%rcx), %ecx
movl $0x1, %r13d
movzbl (%r14,%r13), %esi
movzwl (%rax,%rsi,2), %edx
testl $0xc00, %edx            # imm = 0xC00
je 0x8b79
btl $0xb, %edx
movl $0x0, %edx
adcw $-0x1, %dx
movswl %dx, %edx
addl %edx, %ebp
incq %r13
jmp 0x8b51
cmpl $0x24, %esi
je 0x8b62
cmpl $0x2e, %esi
je 0x8b62
cmpl $0x5f, %esi
jne 0x8b8c
testl %ecx, %ecx
jne 0x8b62
cmpl $0x2, %ebp
je 0x8cee
testq %r12, %r12
je 0x8ba2
leaq (%r14,%r13), %rax
movq %rax, (%r12)
leaq 0xcf3f(%rip), %rax      # 0x15ae8
movl (%rax), %eax
cmpl %r13d, %eax
cmovll %eax, %r13d
leal 0x1(%r13), %eax
movslq %eax, %rdi
callq 0x2230
movq %rax, %rdi
callq 0xe094
movq %rax, %r12
movslq %r13d, %r13
movq %rax, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x2220
movb $0x0, (%r12,%r13)
movq %r12, %rdi
callq 0xe0d8
movq (%rsp), %r14
testq %r14, %r14
je 0x8cd2
movl $0x0, (%r14)
cmpl $0x1, %ebp
jne 0x8ce1
cmpb $0x24, -0x1(%r12,%r13)
jne 0x8ce6
movl $0x20, %edi
callq 0x2230
movq %rax, %rdi
callq 0xe094
movq %rax, %r13
movq %r12, %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x2210
leaq 0xcf2d(%rip), %rbx      # 0x15b68
movl (%rbx), %ecx
leaq 0x79d8(%rip), %rsi      # 0x1061c
movq %r13, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x22b0
leaq 0xcf20(%rip), %rax      # 0x15b78
cmpl $0x0, (%rax)
setne %al
leaq 0xe9fb(%rip), %rcx      # 0x17660
movq (%rcx), %rdi
testq %rdi, %rdi
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x8c8b
movl (%rbx), %edx
leaq 0x79a5(%rip), %rsi      # 0x10623
movq %r12, %rcx
movq %r13, %r8
xorl %eax, %eax
callq 0x21e0
movq %r12, %rdi
callq 0x2050
movl $0x20, (%r14)
leaq 0xcecb(%rip), %rax      # 0x15b6c
incl (%rax)
jmp 0x8cf1
cmpq $0x24, %rbx
je 0x8b3c
cmpl $0x2e, %ebx
je 0x8b3c
xorl %r13d, %r13d
cmpl $0x5f, %ebx
jne 0x8cf1
leaq 0xe9b9(%rip), %rcx      # 0x17680
cmpl $0x0, (%rcx)
jne 0x8b3c
jmp 0x8cf1
movq (%r15), %rax
movzbl (%r12), %ecx
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x8ce6
movq %r12, %r13
jmp 0x8cf1
movq %r12, %rdi
callq 0x2050
xorl %r13d, %r13d
movq %r13, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq