// File: /workspace/github_c_makefile_star2_O0/simh[P]simtools/crossassemblers/macro11/parse.c
// Function: brackrange
int brackrange(
    char *cp,
    int *start,
    int *length,
    char **endp)
{
    char            endstr[6];
    int             endlen;
    int             nest;
    int             len;

    switch (*cp) {
    case '^':
        endstr[0] = cp[1];
        strcpy(endstr + 1, "\n");
        *start = 2;
        endlen = 1;
        break;
    case '<':
        strcpy(endstr, "<>\n");
        endlen = 1;
        *start = 1;
        break;
    default:
        return FALSE;
    }

    cp += *start;

    len = 0;
    if (endstr[1] == '>') { /* <>\n */
        nest = 1;
        while (nest) {
            int             sublen;

            sublen = strcspn(cp + len, endstr);
            if (cp[len + sublen] == '<') {
                nest++;
                sublen++;  /* avoid infinite loop when sublen == 0 */
            } else {
                nest--;
                if (nest > 0 && cp[len + sublen] == '>')
                    sublen++;  /* avoid infinite loop when sublen == 0 */
            }
            len += sublen;
            if (sublen == 0)
                break;
        }
    } else {
        int             sublen;

        sublen = strcspn(cp + len, endstr);
        len += sublen;
    }

    *length = len;
    if (endp)
        *endp = cp + len + endlen;

    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x48(%rbp)
subl $0x3c, %eax
je 0xbbe4
jmp 0xbba9
movl -0x48(%rbp), %eax
subl $0x5e, %eax
jne 0xbc07
jmp 0xbbb3
movq -0x10(%rbp), %rax
movb 0x1(%rax), %al
movb %al, -0x2e(%rbp)
leaq -0x2e(%rbp), %rdi
addq $0x1, %rdi
leaq 0xa033(%rip), %rsi      # 0x15bff
callq 0x2070
movq -0x18(%rbp), %rax
movl $0x2, (%rax)
movl $0x1, -0x34(%rbp)
jmp 0xbc13
leaq -0x2e(%rbp), %rdi
leaq 0x9b2e(%rip), %rsi      # 0x1571d
callq 0x2070
movl $0x1, -0x34(%rbp)
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
jmp 0xbc13
movl $0x0, -0x4(%rbp)
jmp 0xbd25
movq -0x18(%rbp), %rax
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
movl $0x0, -0x3c(%rbp)
movsbl -0x2d(%rbp), %eax
cmpl $0x3e, %eax
jne 0xbcd5
movl $0x1, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
je 0xbcd3
movq -0x10(%rbp), %rdi
movslq -0x3c(%rbp), %rax
addq %rax, %rdi
leaq -0x2e(%rbp), %rsi
callq 0x2160
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movl -0x3c(%rbp), %ecx
addl -0x40(%rbp), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3c, %eax
jne 0xbc8d
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0xbcbd
movl -0x38(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
jle 0xbcbb
movq -0x10(%rbp), %rax
movl -0x3c(%rbp), %ecx
addl -0x40(%rbp), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3e, %eax
jne 0xbcbb
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0xbcbd
movl -0x40(%rbp), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x40(%rbp)
jne 0xbcce
jmp 0xbcd3
jmp 0xbc42
jmp 0xbcf5
movq -0x10(%rbp), %rdi
movslq -0x3c(%rbp), %rax
addq %rax, %rdi
leaq -0x2e(%rbp), %rsi
callq 0x2160
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
cmpq $0x0, -0x28(%rbp)
je 0xbd1e
movq -0x10(%rbp), %rcx
movslq -0x3c(%rbp), %rax
addq %rax, %rcx
movslq -0x34(%rbp), %rax
addq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nop