// File: /workspace/github_c_makefile_star2_O3/BernardTatin[P]s7sh/s7.c
// Function: read_error_1
static s7_pointer read_error_1(s7_scheme *sc, const char *errmsg, bool string_error)
                {
                    /* reader errors happen before the evaluator gets involved, so forms such as:
                     *   (catch #t (lambda () (car '( . ))) (lambda arg 'error))
                     * do not catch the error if we simply signal an error when we encounter it.
                     */
                    char *msg;
                    s7_int len;
                    s7_pointer pt;

                    pt = sc->input_port;
                    if (!string_error)
                    {
                        /* make an heroic effort to find where we slid off the tracks */

                        if (is_string_port(sc->input_port))
                        {
#define QUOTE_SIZE 40
                            s7_int i, j, start = 0, end, slen, size;
                            char *recent_input = NULL;
                            s7_pointer p;

                            /* we can run off the end in cases like (eval-string "(. . ,.)") or (eval-string " (@ . ,.)") */
                            if (port_position(pt) >= port_data_size(pt))
                                port_position(pt) = port_data_size(pt) - 1;

                            /* start at current position and look back a few chars */
                            for (i = port_position(pt), j = 0; (i > 0) && (j < QUOTE_SIZE); i--, j++)
                                if ((port_data(pt)[i] == '\0') ||
                                        (port_data(pt)[i] == '\n') ||
                                        (port_data(pt)[i] == '\r'))
                                    break;
                            start = i;

                            /* start at current position and look ahead a few chars */
                            size = port_data_size(pt);
                            for (i = port_position(pt), j = 0; (i < size) && (j < QUOTE_SIZE); i++, j++)
                                if ((port_data(pt)[i] == '\0') ||
                                        (port_data(pt)[i] == '\n') ||
                                        (port_data(pt)[i] == '\r'))
                                    break;

                            end = i;
                            slen = end - start;
                            /* hopefully this is more or less the current line where the read error happened */

                            if (slen > 0)
                            {
                                recent_input = (char *)calloc(slen + 9, 1);
                                for (i = 0; i < (slen + 8); i++) recent_input[i] = '.';
                                recent_input[3] = ' ';
                                recent_input[slen + 4] = ' ';
                                for (i = 0; i < slen; i++) recent_input[i + 4] = port_data(pt)[start + i];
                            }

                            if ((port_line_number(pt) > 0) &&
                                    (port_filename(pt)))
                            {
                                len = safe_strlen(recent_input) + safe_strlen(errmsg) + port_filename_length(pt) + safe_strlen(sc->current_file) + 64;
                                p = make_empty_string(sc, len, '\0');
                                msg = string_value(p);
                                len = snprintf(msg, len, "%s: %s %s[%u], last top-level form at: %s[%" print_s7_int "]",
                                        errmsg, (recent_input) ? recent_input : "", port_filename(pt), port_line_number(pt),
                                        sc->current_file, sc->current_line);
                            }
                            else
                            {
                                len = safe_strlen(recent_input) + safe_strlen(errmsg) + safe_strlen(sc->current_file) + 64;
                                p = make_empty_string(sc, len, '\0');
                                msg = string_value(p);
                                if ((sc->current_file) &&
                                        (sc->current_line >= 0))
                                    len = snprintf(msg, len, "%s: %s, last top-level form at %s[%" print_s7_int "]",
                                            errmsg, (recent_input) ? recent_input : "",
                                            sc->current_file, sc->current_line);
                                else len = snprintf(msg, len, "%s: %s", errmsg, (recent_input) ? recent_input : "");
                            }

                            string_length(p) = len;
                            if (recent_input) free(recent_input);
                            return(s7_error(sc, sc->read_error_symbol, set_elist_1(sc, p)));
                        }
                    }

                    if ((port_line_number(pt) > 0) &&
                            (port_filename(pt)))
                    {
                        s7_pointer p;
                        len = safe_strlen(errmsg) + port_filename_length(pt) + safe_strlen(sc->current_file) + 128;
                        p = make_empty_string(sc, len, '\0');
                        msg = string_value(p);
                        if (string_error)
                            len = snprintf(msg, len, "%s %s[%u],\n;  possible culprit: \"%s...\"\n;  last top-level form at %s[%" print_s7_int "]",
                                    errmsg, port_filename(pt), port_line_number(pt),
                                    sc->strbuf, sc->current_file, sc->current_line);
                        else len = snprintf(msg, len, "%s %s[%u], last top-level form at %s[%" print_s7_int "]",
                                errmsg, port_filename(pt), port_line_number(pt),
                                sc->current_file, sc->current_line);
                        string_length(p) = len;
                        return(s7_error(sc, sc->read_error_symbol, set_elist_1(sc, p)));
                    }
                    return(s7_error(sc, (string_error) ? sc->string_read_error_symbol : sc->read_error_symbol, set_elist_1(sc, s7_make_string_wrapper(sc, (char *)errmsg))));
                }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x170(%rdi), %r13
movq 0x8(%r13), %rcx
testl %edx, %edx
jne 0x9cf7d
cmpl $0x1, 0x4(%rcx)
jne 0x9cf7d
movq %rcx, 0x8(%rsp)
movq 0x18(%r13), %rax
movq 0x20(%r13), %r12
cmpq %rax, %r12
jl 0x9ce9a
leaq -0x1(%rax), %r12
movq %r12, 0x20(%r13)
movq %r12, %rbp
testq %r12, %r12
jle 0x9ced9
leaq -0x1(%r12), %rdx
cmpq $0x27, %rdx
movl $0x27, %ecx
cmovbq %rdx, %rcx
movq 0x10(%r13), %rdx
incq %rcx
movl $0x2401, %esi           # imm = 0x2401
movq %r12, %rbp
movzbl (%rdx,%rbp), %edi
cmpl $0xd, %edi
ja 0x9ced1
btl %edi, %esi
jb 0x9ced9
decq %rbp
decq %rcx
jne 0x9cec3
cmpq %rax, %r12
jge 0x9cf0d
movq 0x10(%r13), %rcx
xorl %esi, %esi
movl $0x2401, %edx           # imm = 0x2401
movzbl (%rcx,%r12), %edi
cmpl $0xd, %edi
ja 0x9cef8
btl %edi, %edx
jb 0x9cf0d
incq %r12
cmpq %rax, %r12
jge 0x9cf0d
leaq 0x1(%rsi), %rdi
cmpq $0x27, %rsi
movq %rdi, %rsi
jb 0x9cee9
subq %rbp, %r12
jle 0x9d0d6
leaq 0x9(%r12), %rdi
movl $0x1, %esi
callq 0x8360
movq %rax, %r15
leaq 0x7(%r12), %rdx
movq %r13, 0x10(%rsp)
xorl %r13d, %r13d
testq %rdx, %rdx
cmovleq %r13, %rdx
incq %rdx
movq %rax, %rdi
movl $0x2e, %esi
callq 0x8270
movb $0x20, %al
movb %al, 0x3(%r15)
movb %al, 0x4(%r15,%r12)
movq 0x10(%rsp), %rax
movq %rax, %rcx
addq 0x10(%rax), %rbp
movb (%rbp,%r13), %al
movb %al, 0x4(%r15,%r13)
incq %r13
cmpq %r13, %r12
jne 0x9cf63
movq %rcx, %r13
jmp 0x9d0d9
cmpl $0x0, 0x20(%rcx)
je 0x9cfd6
cmpq $0x0, 0x10(%rcx)
je 0x9cfd6
movl $0x80, %r15d
testq %r14, %r14
je 0x9cfaf
cmpb $0x0, (%r14)
je 0x9cfaf
movl $0x80, %eax
leaq 0x1(%rax), %r15
cmpb $0x0, -0x7f(%r14,%rax)
movq %r15, %rax
jne 0x9cfa0
movq 0x30(%rcx), %rax
movq 0x6a8(%rbx), %rdx
testq %rdx, %rdx
je 0x9d037
cmpb $0x0, (%rdx)
je 0x9d037
xorl %esi, %esi
leaq 0x1(%rsi), %rcx
cmpb $0x0, 0x1(%rdx,%rsi)
movq %rcx, %rsi
jne 0x9cfc6
jmp 0x9d039
movzbl %bpl, %eax
movq 0x1908(%rbx,%rax,8), %r15
testq %r14, %r14
je 0x9d000
cmpb $0x0, (%r14)
je 0x9d000
xorl %ecx, %ecx
leaq 0x1(%rcx), %rax
cmpb $0x0, 0x1(%r14,%rcx)
movq %rax, %rcx
jne 0x9cfef
jmp 0x9d002
xorl %eax, %eax
movq 0x820(%rbx), %rcx
movslq 0x7dc(%rbx), %rdx
movq (%rcx,%rdx,8), %rcx
incl %edx
andl $0x7, %edx
movl %edx, 0x7dc(%rbx)
movq %r14, 0x10(%rcx)
movq %rax, 0x8(%rcx)
movq 0x6d8(%rbx), %rax
movq %rcx, 0x8(%rax)
jmp 0x9d2de
xorl %ecx, %ecx
addq %rax, %r15
addq %rcx, %r15
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0xeab0
movq %rax, %r12
movq 0x10(%rax), %rdi
movq 0x8(%r13), %rax
movq 0x10(%rax), %r8
movl 0x20(%rax), %r9d
testb %bpl, %bpl
je 0x9d094
subq $0x8, %rsp
leaq 0x7a62d(%rip), %rdx     # 0x11769c
movq %r15, %rsi
movq %r14, %rcx
xorl %eax, %eax
pushq 0x690(%rbx)
pushq 0x6a8(%rbx)
pushq 0x4b0(%rbx)
callq 0x8210
addq $0x20, %rsp
jmp 0x9d0b8
leaq 0x7a64b(%rip), %rdx     # 0x1176e6
movq %r15, %rsi
movq %r14, %rcx
xorl %eax, %eax
pushq 0x690(%rbx)
pushq 0x6a8(%rbx)
callq 0x8210
addq $0x10, %rsp
cltq
movq %rax, 0x8(%r12)
movq 0x1908(%rbx), %r15
movq 0x6d8(%rbx), %rax
movq %r12, 0x8(%rax)
jmp 0x9d2de
xorl %r15d, %r15d
movq 0x8(%rsp), %rdx
cmpl $0x0, 0x20(%rdx)
je 0x9d139
cmpq $0x0, 0x10(%rdx)
je 0x9d139
movl $0x40, %r12d
testq %r15, %r15
je 0x9d110
cmpb $0x0, (%r15)
je 0x9d110
movl $0x40, %eax
leaq 0x1(%rax), %r12
cmpb $0x0, -0x3f(%r15,%rax)
movq %r12, %rax
jne 0x9d101
testq %r14, %r14
je 0x9d22d
cmpb $0x0, (%r14)
je 0x9d22d
xorl %ecx, %ecx
leaq 0x1(%rcx), %rax
cmpb $0x0, 0x1(%r14,%rcx)
movq %rax, %rcx
jne 0x9d125
jmp 0x9d22f
movl $0x40, %r12d
testq %r15, %r15
je 0x9d15e
cmpb $0x0, (%r15)
je 0x9d15e
movl $0x40, %eax
leaq 0x1(%rax), %r12
cmpb $0x0, -0x3f(%r15,%rax)
movq %r12, %rax
jne 0x9d14f
testq %r14, %r14
je 0x9d17c
cmpb $0x0, (%r14)
je 0x9d17c
xorl %ecx, %ecx
leaq 0x1(%rcx), %rax
cmpb $0x0, 0x1(%r14,%rcx)
movq %rax, %rcx
jne 0x9d16b
jmp 0x9d17e
xorl %eax, %eax
movq 0x6a8(%rbx), %rdx
testq %rdx, %rdx
je 0x9d1a1
cmpb $0x0, (%rdx)
je 0x9d1a1
xorl %esi, %esi
leaq 0x1(%rsi), %rcx
cmpb $0x0, 0x1(%rdx,%rsi)
movq %rcx, %rsi
jne 0x9d191
jmp 0x9d1a3
xorl %ecx, %ecx
addq %rax, %r12
addq %rcx, %r12
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0xeab0
movq %rax, %rbp
movq 0x10(%rax), %rdi
movq 0x6a8(%rbx), %r9
testq %r9, %r9
je 0x9d206
movq 0x690(%rbx), %r10
testq %r10, %r10
js 0x9d206
testq %r15, %r15
leaq 0x7f2ef(%rip), %r8      # 0x11c4ce
cmovneq %r15, %r8
subq $0x8, %rsp
leaq 0x7a480(%rip), %rdx     # 0x11766e
movq %r12, %rsi
movq %r14, %rcx
xorl %eax, %eax
pushq %r10
callq 0x8210
addq $0x10, %rsp
jmp 0x9d2b9
testq %r15, %r15
leaq 0x7f2be(%rip), %r8      # 0x11c4ce
cmovneq %r15, %r8
leaq 0x7a47a(%rip), %rdx     # 0x117695
movq %r12, %rsi
movq %r14, %rcx
xorl %eax, %eax
callq 0x8210
jmp 0x9d2b9
xorl %eax, %eax
movq 0x30(%rdx), %rcx
movq 0x6a8(%rbx), %rsi
testq %rsi, %rsi
je 0x9d256
cmpb $0x0, (%rsi)
je 0x9d256
xorl %edi, %edi
leaq 0x1(%rdi), %rdx
cmpb $0x0, 0x1(%rsi,%rdi)
movq %rdx, %rdi
jne 0x9d246
jmp 0x9d258
xorl %edx, %edx
addq %rax, %r12
addq %rcx, %r12
addq %rdx, %r12
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0xeab0
movq %rax, %rbp
testq %r15, %r15
leaq 0x7f253(%rip), %r8      # 0x11c4ce
cmovneq %r15, %r8
movq 0x10(%rax), %rdi
movq 0x8(%r13), %rax
movq 0x10(%rax), %r9
movl 0x20(%rax), %r10d
subq $0x8, %rsp
leaq 0x7a3a5(%rip), %rdx     # 0x11763f
movq %r12, %rsi
movq %r14, %rcx
xorl %eax, %eax
pushq 0x690(%rbx)
pushq 0x6a8(%rbx)
pushq %r10
callq 0x8210
addq $0x20, %rsp
cltq
movq %rax, 0x8(%rbp)
testq %r15, %r15
je 0x9d2cc
movq %r15, %rdi
callq 0x8050
movq 0x1908(%rbx), %r15
movq 0x6d8(%rbx), %rax
movq %rbp, 0x8(%rax)
movq 0x6d8(%rbx), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x38dfa
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq