// File: /workspace/github_c_makefile_star2_O3/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
pushq %rax
movq %rsi, %r12
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x91aef
movl %eax, %r13d
cmpl $0x68, %eax
jg 0x915c3
leal -0x21(%r13), %eax
cmpl $0x19, %eax
ja 0x9182c
leaq 0x76b19(%rip), %rcx     # 0x107f20
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x4b0(%rbx), %rax
movb %r13b, (%rax)
movq %r13, (%rsp)
movl %r13d, %eax
leaq 0xc4238(%rip), %rcx     # 0x155660
movslq (%rcx,%rax,4), %rbp
movl $0x1, %r13d
movq $-0x8000, %r14          # imm = 0x8000
movq %r12, %r15
movq %r12, %rdi
callq 0x91aef
movl %eax, %r12d
cmpl $-0x1, %eax
jne 0x9149d
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 0x853ff(%rip), %rcx     # 0x116876
movq %rcx, 0x10(%rax)
movq $0x2b, 0x8(%rax)
movq 0x6d8(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x6d8(%rbx), %rdx
movq %rbx, %rdi
callq 0x38dfa
movslq %r12d, %rax
leaq 0xc41b9(%rip), %rcx     # 0x155660
movslq (%rcx,%rax,4), %rax
cmpq $0x9, %rax
jg 0x91555
leaq (,%rbp,4), %rcx
addq %rbp, %rcx
leaq (%rax,%rcx,2), %rbp
leaq (%r14,%rbp), %rax
cmpq %r14, %rax
ja 0x9153f
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 0x853aa(%rip), %rcx     # 0x1168a2
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 0x38dfa
movq 0x4b0(%rbx), %rax
movb %r12b, (%rax,%r13)
incq %r13
movq %r15, %r12
jmp 0x91439
movq 0x4b0(%rbx), %rax
leaq 0x1(%r13), %r14
movl %r13d, %ecx
movb %r12b, (%rax,%rcx)
leal -0x64(%r12), %eax
cmpl $0x11, %eax
ja 0x91672
movl $0x24021, %ecx          # imm = 0x24021
btl %eax, %ecx
jae 0x91672
movq %r15, %rdi
callq 0x91aef
cmpl $-0x1, %eax
je 0x91606
movq 0x4b0(%rbx), %rcx
movl %r14d, %edx
movb %al, (%rcx,%rdx)
cmpl $0x28, %eax
jne 0x9166b
cmpq $0x7ff, %rbp            # imm = 0x7FF
ja 0x917c4
leaq 0xb5396(%rip), %rax     # 0x146950
movq (%rax,%rbp,8), %rax
jmp 0x917fd
cmpl $0x74, %r13d
jg 0x916a9
cmpl $0x69, %r13d
je 0x918e9
cmpl $0x72, %r13d
jne 0x9197f
movq %rbx, %rdi
movq %r12, %rsi
callq 0x913ce
movl %eax, %ecx
movl $0xe, %eax
cmpl $0xb, %ecx
je 0x9198e
movl $0x72, %edi
jmp 0x91977
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 0x85290(%rip), %rcx     # 0x1168c1
movq %rcx, 0x10(%rax)
movq $0x2a, 0x8(%rax)
movq 0x6d8(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x6d8(%rbx), %rdx
movq %rbx, %rdi
callq 0x38dfa
movq 0x4b0(%rbx), %rax
addl $0x2, %r13d
movl %r14d, %ecx
movb $-0x1, (%rax,%rcx)
jmp 0x9166f
addq $0x2, %r13
movl %r13d, %r14d
cmpl $0x2, %r14d
movq (%rsp), %r13
jl 0x9197f
movl %r14d, %r14d
incq %r14
movq 0x4b0(%rbx), %rax
movsbl -0x2(%rax,%r14), %edi
movq %r15, %rsi
callq 0xfb07
decq %r14
cmpq $0x2, %r14
ja 0x91686
jmp 0x9197f
cmpl $0x75, %r13d
je 0x9190b
cmpl $0x7c, %r13d
jne 0x9197f
movq 0x8(%r12), %rax
cmpl $0x0, 0x4(%rax)
je 0x919d1
movq 0x10(%r12), %r14
movq %r12, %rax
movq 0x20(%r12), %r12
addq %r14, %r12
movq %rax, %rbp
addq 0x18(%rax), %r14
leaq 0x8522b(%rip), %r13     # 0x116915
movq %r12, %rdi
movl $0x7c, %esi
callq 0x81d0
movq %rax, %r15
testq %rax, %rax
je 0x91704
cmpq %r14, %r15
jb 0x91756
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 0x38dfa
leaq 0x1(%r15), %rdi
cmpb $0x23, 0x1(%r15)
jne 0x916ed
movq 0x20(%rbp), %rax
movq %r15, %rcx
subq %r12, %rcx
addq %rcx, %rax
addq $0x2, %rax
movq %rax, 0x20(%rbp)
movq %r12, %rdi
movq %rbp, %r14
movl $0xa, %esi
callq 0x81d0
testq %rax, %rax
sete %cl
cmpq %r15, %rax
setae %dl
orb %cl, %dl
jne 0x91ab9
movq 0x8(%r14), %rcx
incl 0x20(%rcx)
incq %rax
movq %rax, %rdi
movl $0xa, %esi
callq 0x81d0
testq %rax, %rax
je 0x91ab9
cmpq %r15, %rax
jb 0x9179a
jmp 0x91ab9
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x917e3
movq %rbx, %rdi
callq 0xa550
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 0x918cb
cmpl $0x75, %r12d
je 0x91ae5
cmpl $0x72, %r12d
jne 0x9199d
movl $0xe, %eax
jmp 0x9198e
cmpl $-0x1, %r13d
jne 0x9197f
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 0x84ff6(%rip), %rcx     # 0x116857
movq %rcx, 0x10(%rax)
movq $0x1e, 0x8(%rax)
movq 0x6d8(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x6d8(%rbx), %rdx
movq %rbx, %rdi
callq 0x38dfa
jmp 0x9197f
movq 0x1e0(%rbx), %rax
movq 0x10(%rax), %rax
cmpb $0x1, (%rax)
jne 0x919a4
movq 0x8(%rax), %rcx
movq 0x8(%rcx), %rcx
cmpb $0x21, 0x8(%rcx)
jne 0x91893
movq 0x4b0(%rbx), %rax
movb $0x21, (%rax)
jmp 0x91989
movq 0xb5094(%rip), %rax     # 0x146958
movq %rax, 0x4d8(%rbx)
movl $0xb, %eax
jmp 0x9198e
movq 0x4b0(%rbx), %rax
movb $0x3a, (%rax)
movl $0x4, %eax
jmp 0x9198e
movq %rbx, %rdi
movq %r12, %rsi
callq 0x913ce
movl %eax, %ecx
movl $0xd, %eax
cmpl $0xb, %ecx
je 0x9198e
movl $0x69, %edi
jmp 0x91977
movq %rbx, %rdi
movq %r12, %rsi
callq 0xfa95
movq 0xb913b(%rip), %rcx     # 0x14aa58
cmpq 0x1c0(%rcx), %rax
jne 0x9195b
movq %r12, %rdi
callq 0x91aef
movl %eax, %ebp
movq %rbx, %rdi
movq %r12, %rsi
callq 0xfa95
movq 0xb9116(%rip), %rcx     # 0x14aa58
cmpq 0x140(%rcx), %rax
je 0x91acf
movsbl %bpl, %edi
movq %r12, %rsi
callq 0xfb07
movq %rbx, %rdi
movq %r12, %rsi
callq 0x913ce
movl %eax, %ecx
movl $0xc, %eax
cmpl $0xb, %ecx
je 0x9198e
movl $0x75, %edi
movq %r12, %rsi
callq 0xfb07
movq 0x4b0(%rbx), %rax
movb %r13b, (%rax)
movl $0xa, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xd, %eax
jmp 0x9198e
movl $0x20, %ebp
movq %r12, %rdi
callq 0x91aef
cmpl $-0x1, %eax
je 0x91a68
movl %eax, %ecx
xorl $0x23, %ecx
movzbl %bpl, %edx
xorl $0x21, %edx
orl %ecx, %edx
movl %eax, %ebp
jne 0x919a9
jmp 0x91ab9
movl $0x20, %r15d
leaq 0x84f37(%rip), %r14     # 0x116915
movq 0x8(%rax), %rdi
callq 0x8290
movl %eax, %ebp
cmpl $-0x1, %eax
je 0x91a11
movl %ebp, %eax
xorl $0x23, %eax
movzbl %r15b, %ecx
xorl $0x7c, %ecx
orl %eax, %ecx
je 0x91ab9
cmpl $0xa, %ebp
jne 0x91a5b
movq 0x8(%r12), %rax
incl 0x20(%rax)
jmp 0x91a5b
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 0x38dfa
movq 0x8(%r12), %rax
movl %ebp, %r15d
jmp 0x919de
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 0x84e59(%rip), %rcx     # 0x1168ec
movq %rcx, 0x10(%rax)
movq $0x28, 0x8(%rax)
movq 0x6d8(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x6d8(%rbx), %rdx
movq %rbx, %rdi
callq 0x38dfa
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9126a
movq %r12, %rdi
callq 0x91aef
movq 0xb4e7a(%rip), %rax     # 0x146958
movq %rax, 0x4d8(%rbx)
movl $0xc, %eax
jmp 0x9198e