// File: /workspace/github_c_makefile_star2_O1/BernardTatin[P]s7sh/s7.c
// Function: read_sharp
static token_t read_sharp(s7_scheme *sc, s7_pointer pt)
                {
                    int32_t c;
                    /* inchar can return EOF, so it can't be used directly as an index into the digits array */
                    c = inchar(pt);
                    switch (c)
                    {
                        case EOF:
                            s7_error(sc, sc->read_error_symbol, set_elist_1(sc, wrap_string(sc, "unexpected '#' at end of input", 30)));
                            break;

                        case '(':
                            sc->w = small_int(1);
                            return(TOKEN_VECTOR);

                        case 'i':
                            if (read_sharp(sc, pt) == TOKEN_VECTOR)
                                return(TOKEN_INT_VECTOR);
                            backchar('i', pt);
                            break;

                        case 'r':
                            if (read_sharp(sc, pt) == TOKEN_VECTOR)
                                return(TOKEN_FLOAT_VECTOR);
                            backchar('r', pt);
                            break;

                        case 'u':
                            if (s7_peek_char(sc, pt) == chars['8']) /* backwards compatibility: #u8(...) == #u(...) */
                            {
                                int32_t bc;
                                bc = inchar(pt);
                                if (s7_peek_char(sc, pt) == chars['('])
                                {
                                    inchar(pt);
                                    sc->w = small_int(1);
                                    return(TOKEN_BYTE_VECTOR);
                                }
                                backchar(bc, pt);
                            }
                            if (read_sharp(sc, pt) == TOKEN_VECTOR)
                                return(TOKEN_BYTE_VECTOR);
                            backchar('u', pt);
                            break;

                        case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
                            {
                                /* here we can get an overflow: #1231231231231232131D() */
                                s7_int dims;
                                int32_t d, loc = 0;
                                sc->strbuf[loc++] = (unsigned char)c;
                                dims = digits[c];

                                while (true)
                                {
                                    s7_int dig;
                                    d = inchar(pt);
                                    if (d == EOF)
                                        s7_error(sc, sc->read_error_symbol,
                                                set_elist_1(sc, wrap_string(sc, "unexpected end of input while reading #n...", 43)));

                                    dig = digits[d];
                                    if (dig >= 10) break;
                                    dims = dig + (dims * 10);
                                    if ((dims <= 0) ||
                                            (dims > S7_SHORT_MAX))
                                        s7_error(sc, sc->read_error_symbol,
                                                set_elist_2(sc, wrap_string(sc, "overflow while reading #nD: ~A", 30), wrap_integer1(sc, dims)));
                                    sc->strbuf[loc++] = (unsigned char)d;
                                }
                                sc->strbuf[loc++] = d;
                                if ((d == 'd') || (d == 'i') || (d == 'r') || (d == 'u'))
                                {
                                    int32_t e;
                                    e = inchar(pt);
                                    if (e == EOF)
                                        s7_error(sc, sc->read_error_symbol,
                                                set_elist_1(sc, wrap_string(sc, "unexpected end of input while reading #n()", 42)));
                                    sc->strbuf[loc++] = (unsigned char)e;
                                    if (e == '(')
                                    {
                                        sc->w = make_integer(sc, dims);
                                        if (d == 'd') return(TOKEN_VECTOR);
                                        if (d == 'r') return(TOKEN_FLOAT_VECTOR);
                                        if (d == 'u') return(TOKEN_BYTE_VECTOR);
                                        return(TOKEN_INT_VECTOR);
                                    }
                                }
                                /* try to back out */
                                for (d = loc - 1; d > 0; d--)
                                    backchar(sc->strbuf[d], pt);
                            }
                            break;

                        case ':':  /* turn #: into : -- this is for compatibility with Guile, sigh.
                                    *   I just noticed that Rick is using this -- I'll just leave it alone.
                                    *   but that means : readers need to handle this case specially.
                                    * I don't think #! is special anymore -- maybe remove that code?
                                    */
                            sc->strbuf[0] = ':';
                            return(TOKEN_ATOM);

                            /* block comments in #! ... !# */
                            /* this is needed when an input file is treated as a script:
#!/home/bil/cl/snd
!#
(format #t "a test~%")
(exit)
                             * but very often the closing !# is omitted which is too bad
                             */
                        case '!':
                            {
                                char last_char;
                                s7_pointer reader;

                                /* make it possible to override #! handling */
                                for (reader = slot_value(sc->sharp_readers); is_pair(reader); reader = cdr(reader))
                                    if (s7_character(caar(reader)) == '!')
                                    {
                                        sc->strbuf[0] = (unsigned char)c;
                                        return(TOKEN_SHARP_CONST); /* next stage notices any errors */
                                    }

                                /* not #! as block comment (for Guile I guess) */
                                last_char = ' ';
                                while ((c = inchar(pt)) != EOF)
                                {
                                    if ((c == '#') &&
                                            (last_char == '!'))
                                        break;
                                    last_char = c;
                                }
                                if (c == EOF)
                                    s7_error(sc, sc->read_error_symbol,
                                            set_elist_1(sc, wrap_string(sc, "unexpected end of input while reading #!", 40)));
                                return(token(sc));
                            }

                            /* block comments in #| ... |#
                             *   since we ignore everything until the |#, internal semicolon comments are ignored,
                             *   meaning that ;|# is as effective as |#
                             */
                        case '|':
                            {
                                if (is_file_port(pt))
                                {
                                    char last_char;
                                    last_char = ' ';
                                    while (true)
                                    {
                                        c = fgetc(port_file(pt));
                                        if (c == EOF)
                                            s7_error(sc, sc->read_error_symbol,
                                                    set_elist_1(sc, wrap_string(sc, "unexpected end of input while reading #|", 40)));
                                        if ((c == '#') &&
                                                (last_char == '|'))
                                            break;
                                        last_char = c;
                                        if (c == '\n')
                                            port_line_number(pt)++;
                                    }
                                    return(token(sc));
                                }
                                else
                                {
                                    const char *str, *orig_str, *p, *pend;

                                    orig_str = (const char *)(port_data(pt) + port_position(pt));
                                    pend = (const char *)(port_data(pt) + port_data_size(pt));
                                    str = orig_str;

                                    while (true)
                                    {
                                        p = strchr(str, (int)'|');
                                        if ((!p) || (p >= pend))
                                        {
                                            port_position(pt) = port_data_size(pt);
                                            s7_error(sc, sc->read_error_symbol,
                                                    set_elist_1(sc, wrap_string(sc, "unexpected end of input while reading #|", 40)));
                                        }
                                        if (p[1] == '#')
                                            break;
                                        str = (const char *)(p + 1);
                                    }
                                    port_position(pt) += (p - orig_str + 2);

                                    /* now count newline inside the comment */
                                    str = (const char *)orig_str;
                                    pend = p;
                                    while (true)
                                    {
                                        p = strchr(str, (int)'\n');
                                        if ((p) && (p < pend))
                                        {
                                            port_line_number(pt)++;
                                            str = (char *)(p + 1);
                                        }
                                        else break;
                                    }
                                    return(token(sc));
                                }
                            }
                    }
                    sc->strbuf[0] = (unsigned char)c;
                    return(TOKEN_SHARP_CONST); /* next stage notices any errors */
                }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r13
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x97c27
movl %eax, %r15d
cmpl $0x68, %eax
jg 0x9773e
leal -0x21(%r15), %eax
cmpl $0x19, %eax
ja 0x978e6
leaq 0x7998a(%rip), %rcx     # 0x110ea0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x4b0(%rbx), %rax
movb %r15b, (%rax)
movq %r15, 0x8(%rsp)
movslq %r15d, %rax
leaq 0xc6128(%rip), %rcx     # 0x15d660
movslq (%rcx,%rax,4), %rbp
movl $0x1, %r15d
movq %r13, %r14
movq %r13, %rdi
callq 0x97c27
movl %eax, %r12d
cmpl $-0x1, %eax
jne 0x975a6
movq 0x1908(%rbx), %rsi
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rbx)
leaq 0x881e6(%rip), %rcx     # 0x11f766
movq %rcx, 0x10(%rax)
movq $0x2b, 0x8(%rax)
movq 0x6d8(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x6d8(%rbx), %rdx
movq %rbx, %rdi
callq 0x3b366
movslq %r12d, %rax
leaq 0xc60b0(%rip), %rcx     # 0x15d660
movslq (%rcx,%rax,4), %r13
cmpq $0x9, %r13
jg 0x97667
leaq (,%rbp,4), %rax
addq %rbp, %rax
leaq (,%rax,2), %rbp
addq %r13, %rbp
movq $-0x8000, %rcx          # imm = 0x8000
leaq (%rcx,%rbp), %rax
cmpq %rcx, %rax
ja 0x97656
movq 0x1908(%rbx), %rsi
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rbx)
leaq 0x88183(%rip), %rcx     # 0x11f792
movq %rcx, 0x10(%rax)
movq $0x1e, 0x8(%rax)
movq 0x1f00(%rbx), %rcx
movq %rbp, 0x8(%rcx)
movq 0x1f00(%rbx), %rcx
movq 0x6e0(%rbx), %rdx
movq %rax, 0x8(%rdx)
movq 0x6e0(%rbx), %rax
movq 0x10(%rax), %rax
movq %rcx, 0x8(%rax)
movq 0x6e0(%rbx), %rdx
movq %rbx, %rdi
callq 0x3b366
movq 0x4b0(%rbx), %rax
movslq %r15d, %rcx
incl %r15d
movb %r12b, (%rax,%rcx)
cmpl $0xa, %r13d
movq %r14, %r13
jl 0x97542
movq 0x4b0(%rbx), %rax
movslq %r15d, %rdx
movb %r12b, (%rax,%rdx)
incq %rdx
leal -0x64(%r12), %eax
cmpl $0x11, %eax
ja 0x97a16
movl $0x24021, %ecx          # imm = 0x24021
btl %eax, %ecx
jae 0x9796d
movq %rdx, 0x10(%rsp)
movq %r13, %rdi
callq 0x97c27
movl %eax, %r13d
cmpl $-0x1, %eax
jne 0x97707
movq 0x1908(%rbx), %rsi
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rbx)
leaq 0x880d0(%rip), %rcx     # 0x11f7b1
movq %rcx, 0x10(%rax)
movq $0x2a, 0x8(%rax)
movq 0x6d8(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x6d8(%rbx), %rdx
movq %rbx, %rdi
callq 0x3b366
movq 0x4b0(%rbx), %rax
movq 0x10(%rsp), %rcx
movb %r13b, (%rax,%rcx)
cmpl $0x28, %r13d
jne 0x97959
cmpq $0x7ff, %rbp            # imm = 0x7FF
ja 0x9788d
leaq 0xb721b(%rip), %rax     # 0x14e950
movq (%rax,%rbp,8), %rax
jmp 0x978c6
cmpl $0x74, %r15d
jg 0x9777b
cmpl $0x69, %r15d
je 0x97a1b
cmpl $0x72, %r15d
jne 0x97c00
movq %rbx, %rdi
movq %r13, %rsi
callq 0x974da
movl $0xe, %ecx
cmpl $0xb, %eax
je 0x97c0f
movl $0x72, %edi
jmp 0x97bf8
cmpl $0x75, %r15d
je 0x97a3e
cmpl $0x7c, %r15d
jne 0x97c00
movq 0x8(%r13), %rax
cmpl $0x0, 0x4(%rax)
je 0x97aca
movq 0x10(%r13), %r14
movq 0x20(%r13), %r12
addq %r14, %r12
movq %r13, %rbp
addq 0x18(%r13), %r14
leaq 0x8804f(%rip), %r13     # 0x11f805
movq %r12, %rdi
movl $0x7c, %esi
callq 0x91d0
movq %rax, %r15
testq %rax, %rax
je 0x977d0
cmpq %r14, %r15
jb 0x97822
movq 0x18(%rbp), %rax
movq %rax, 0x20(%rbp)
movq 0x1908(%rbx), %rsi
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rbx)
movq %r13, 0x10(%rax)
movq $0x28, 0x8(%rax)
movq 0x6d8(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x6d8(%rbx), %rdx
movq %rbx, %rdi
callq 0x3b366
leaq 0x1(%r15), %rdi
cmpb $0x23, 0x1(%r15)
jne 0x977b9
movq 0x20(%rbp), %rax
movq %r15, %rcx
subq %r12, %rcx
addq %rcx, %rax
addq $0x2, %rax
movq %rax, 0x20(%rbp)
movq %r12, %rdi
movl $0xa, %esi
callq 0x91d0
testq %rax, %rax
sete %cl
cmpq %r15, %rax
setae %dl
orb %cl, %dl
jne 0x97bad
movq 0x8(%rbp), %rcx
incl 0x20(%rcx)
incq %rax
movq %rax, %rdi
movl $0xa, %esi
callq 0x91d0
testq %rax, %rax
je 0x97bad
cmpq %r15, %rax
jb 0x97863
jmp 0x97bad
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x978a5
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movq $0xb, (%rax)
movq %rbp, 0x8(%rax)
movq %rax, 0x4d8(%rbx)
cmpl $0x64, %r12d
je 0x9794d
cmpl $0x75, %r12d
je 0x97946
cmpl $0x72, %r12d
jne 0x97954
movl $0xe, %ecx
jmp 0x97959
cmpl $-0x1, %r15d
jne 0x97c00
movq 0x1908(%rbx), %rsi
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rbx)
leaq 0x87e2c(%rip), %rcx     # 0x11f747
movq %rcx, 0x10(%rax)
movq $0x1e, 0x8(%rax)
movq 0x6d8(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x6d8(%rbx), %rdx
movq %rbx, %rdi
callq 0x3b366
jmp 0x97c00
movl $0xc, %ecx
jmp 0x97959
movl $0xb, %ecx
jmp 0x97959
movl $0xd, %ecx
cmpl $0x28, %r13d
jne 0x97963
xorl %ebp, %ebp
jmp 0x979a6
addl $0x2, %r15d
movl %r15d, %edx
movq %r14, %r13
movb $0x1, %bpl
cmpl $0x2, %edx
jl 0x979a6
movl %ecx, %r12d
movl %edx, %r14d
incq %r14
movq 0x8(%rsp), %r15
movq 0x4b0(%rbx), %rax
movsbl -0x2(%rax,%r14), %edi
movq %r13, %rsi
callq 0x1090a
decq %r14
cmpq $0x2, %r14
jg 0x97983
movl %r12d, %ecx
jmp 0x979ab
movq 0x8(%rsp), %r15
testb %bpl, %bpl
jne 0x97c00
jmp 0x97c0f
movq 0x1e0(%rbx), %rax
movq 0x10(%rax), %rax
cmpb $0x1, (%rax)
jne 0x97a9d
movq 0x8(%rax), %rcx
movq 0x8(%rcx), %rcx
cmpb $0x21, 0x8(%rcx)
jne 0x979c0
movq 0x4b0(%rbx), %rax
movb $0x21, (%rax)
jmp 0x97c0a
movq 0xb6f67(%rip), %rax     # 0x14e958
movq %rax, 0x4d8(%rbx)
movl $0xb, %ecx
jmp 0x97c0f
movq 0x4b0(%rbx), %rax
movb $0x3a, (%rax)
movl $0x4, %ecx
jmp 0x97c0f
jmp 0x9796d
movq %rbx, %rdi
movq %r13, %rsi
callq 0x974da
movl $0xd, %ecx
cmpl $0xb, %eax
je 0x97c0f
movl $0x69, %edi
jmp 0x97bf8
movq %rbx, %rdi
movq %r13, %rsi
callq 0x10898
movq 0xbb008(%rip), %rcx     # 0x152a58
cmpq 0x1c0(%rcx), %rax
jne 0x97bde
movq %r13, %rdi
callq 0x97c27
movl %eax, %ebp
movq %rbx, %rdi
movq %r13, %rsi
callq 0x10898
movq %rax, %r12
movq 0xbafdc(%rip), %rax     # 0x152a58
movq 0x140(%rax), %r14
cmpq %r14, %r12
je 0x97bc3
movsbl %bpl, %edi
movq %r13, %rsi
callq 0x1090a
jmp 0x97bd9
movl $0x20, %ebp
movq %r13, %rdi
callq 0x97c27
cmpl $-0x1, %eax
je 0x97b5c
movl %eax, %ecx
xorl $0x23, %ecx
movzbl %bpl, %edx
xorl $0x21, %edx
orl %ecx, %edx
movl %eax, %ebp
jne 0x97aa2
jmp 0x97bad
movl $0x20, %r15d
leaq 0x87d2e(%rip), %r14     # 0x11f805
movq 0x8(%r13), %rax
movq 0x8(%rax), %rdi
callq 0x9290
movl %eax, %ebp
cmpl $-0x1, %eax
jne 0x97b35
movq 0x1908(%rbx), %rsi
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rbx)
movq %r14, 0x10(%rax)
movq $0x28, 0x8(%rax)
movq 0x6d8(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x6d8(%rbx), %rdx
movq %rbx, %rdi
callq 0x3b366
movl %ebp, %eax
xorl $0x23, %eax
movzbl %r15b, %ecx
xorl $0x7c, %ecx
orl %eax, %ecx
je 0x97bad
movl %ebp, %r15d
cmpl $0xa, %ebp
jne 0x97ad7
movq 0x8(%r13), %rax
incl 0x20(%rax)
movl %ebp, %r15d
jmp 0x97ad7
movq 0x1908(%rbx), %rsi
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rbx)
leaq 0x87c55(%rip), %rcx     # 0x11f7dc
movq %rcx, 0x10(%rax)
movq $0x28, 0x8(%rax)
movq 0x6d8(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x6d8(%rbx), %rdx
movq %rbx, %rdi
callq 0x3b366
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x97376
movq %r13, %rdi
callq 0x97c27
movq 0xb6d86(%rip), %rax     # 0x14e958
movq %rax, 0x4d8(%rbx)
cmpq %r14, %r12
je 0x97c20
movq %rbx, %rdi
movq %r13, %rsi
callq 0x974da
movl $0xc, %ecx
cmpl $0xb, %eax
je 0x97c0f
movl $0x75, %edi
movq %r13, %rsi
callq 0x1090a
movq 0x4b0(%rbx), %rax
movb %r15b, (%rax)
movl $0xa, %ecx
movl %ecx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xc, %ecx
jmp 0x97c0f