// File: /workspace/github_c_makefile_star2_O1/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
pushq %rax
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r13
movq 0x170(%rdi), %rbx
testl %edx, %edx
jne 0xa39f6
movq 0x8(%rbx), %rax
cmpl $0x1, 0x4(%rax)
jne 0xa39f6
movq %r13, (%rsp)
movq 0x18(%rbx), %rax
cmpq %rax, 0x20(%rbx)
jl 0xa3919
decq %rax
movq %rax, 0x20(%rbx)
movq 0x20(%rbx), %r12
movq %r12, %r13
testq %r12, %r12
jle 0xa395d
leaq -0x1(%r12), %rcx
cmpq $0x27, %rcx
movl $0x27, %eax
cmovbq %rcx, %rax
movq 0x10(%rbx), %rcx
incq %rax
movl $0x2401, %edx           # imm = 0x2401
movq %r12, %r13
movzbl (%rcx,%r13), %esi
cmpl $0xd, %esi
ja 0xa3955
btl %esi, %edx
jb 0xa395d
decq %r13
decq %rax
jne 0xa3946
movq 0x18(%rbx), %rax
cmpq %rax, %r12
jge 0xa3995
movq 0x10(%rbx), %rcx
xorl %esi, %esi
movl $0x2401, %edx           # imm = 0x2401
movzbl (%rcx,%r12), %edi
cmpl $0xd, %edi
ja 0xa3980
btl %edi, %edx
jb 0xa3995
incq %r12
cmpq %rax, %r12
jge 0xa3995
leaq 0x1(%rsi), %rdi
cmpq $0x27, %rsi
movq %rdi, %rsi
jb 0xa3971
subq %r13, %r12
jle 0xa3b49
leaq 0x9(%r12), %rdi
movl $0x1, %esi
callq 0x9360
movq %rax, %r15
leaq 0x7(%r12), %rdx
xorl %ebp, %ebp
testq %rdx, %rdx
cmovleq %rbp, %rdx
incq %rdx
movq %rax, %rdi
movl $0x2e, %esi
callq 0x9270
movb $0x20, %al
movb %al, 0x3(%r15)
movb %al, 0x4(%r15,%r12)
movq 0x10(%rbx), %rax
addq %r13, %rax
movb (%rbp,%rax), %al
movb %al, 0x4(%r15,%rbp)
incq %rbp
cmpq %rbp, %r12
jne 0xa39d9
jmp 0xa3b4c
movq 0x8(%rbx), %rax
cmpl $0x0, 0x20(%rax)
je 0xa3a58
cmpq $0x0, 0x10(%rax)
je 0xa3a58
movl $0x80, %r15d
testq %r14, %r14
je 0xa3a2c
cmpb $0x0, (%r14)
je 0xa3a2c
movl $0x7f, %ecx
leaq 0x1(%rcx), %r15
cmpb $0x0, -0x7f(%r14,%rcx)
movq %r15, %rcx
jne 0xa3a1d
movq 0x30(%rax), %rax
movq 0x6a8(%r13), %rdx
testq %rdx, %rdx
je 0xa3ab7
cmpb $0x0, (%rdx)
je 0xa3ab7
movq $-0x1, %rsi
leaq 0x1(%rsi), %rcx
cmpb $0x0, 0x1(%rdx,%rsi)
movq %rcx, %rsi
jne 0xa3a48
jmp 0xa3ab9
movzbl %bpl, %eax
testq %r14, %r14
je 0xa3a7f
cmpb $0x0, (%r14)
je 0xa3a7f
movq $-0x1, %rdx
leaq 0x1(%rdx), %rcx
cmpb $0x0, 0x1(%r14,%rdx)
movq %rcx, %rdx
jne 0xa3a6e
jmp 0xa3a81
xorl %ecx, %ecx
movq 0x1908(%r13,%rax,8), %rsi
movq 0x820(%r13), %rax
movslq 0x7dc(%r13), %rdx
movq (%rax,%rdx,8), %r12
leal 0x1(%rdx), %eax
andl $0x7, %eax
movl %eax, 0x7dc(%r13)
movq %r14, 0x10(%r12)
movq %rcx, 0x8(%r12)
jmp 0xa3d6d
xorl %ecx, %ecx
addq %rax, %r15
addq %rcx, %r15
movq %r13, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0xf83b
movq %rax, %r12
movq 0x10(%rax), %rdi
movq 0x8(%rbx), %rax
movq 0x10(%rax), %r8
movl 0x20(%rax), %r9d
testb %bpl, %bpl
je 0xa3b17
subq $0x8, %rsp
leaq 0x7ca9d(%rip), %rdx     # 0x12058c
movq %r15, %rsi
movq %r14, %rcx
xorl %eax, %eax
pushq 0x690(%r13)
pushq 0x6a8(%r13)
pushq 0x4b0(%r13)
callq 0x9210
addq $0x20, %rsp
jmp 0xa3b3d
leaq 0x7cab8(%rip), %rdx     # 0x1205d6
movq %r15, %rsi
movq %r14, %rcx
xorl %eax, %eax
pushq 0x690(%r13)
pushq 0x6a8(%r13)
callq 0x9210
addq $0x10, %rsp
cltq
movq %rax, 0x8(%r12)
jmp 0xa3d66
xorl %r15d, %r15d
movq 0x8(%rbx), %rax
cmpl $0x0, 0x20(%rax)
je 0xa3bb0
cmpq $0x0, 0x10(%rax)
je 0xa3bb0
movl $0x40, %r13d
testq %r15, %r15
je 0xa3b82
cmpb $0x0, (%r15)
je 0xa3b82
movl $0x3f, %ecx
leaq 0x1(%rcx), %r13
cmpb $0x0, -0x3f(%r15,%rcx)
movq %r13, %rcx
jne 0xa3b73
testq %r14, %r14
je 0xa3cb6
cmpb $0x0, (%r14)
je 0xa3cb6
movq $-0x1, %rdx
leaq 0x1(%rdx), %rcx
cmpb $0x0, 0x1(%r14,%rdx)
movq %rcx, %rdx
jne 0xa3b9c
jmp 0xa3cb8
movl $0x40, %r13d
testq %r15, %r15
je 0xa3bd5
cmpb $0x0, (%r15)
je 0xa3bd5
movl $0x3f, %eax
leaq 0x1(%rax), %r13
cmpb $0x0, -0x3f(%r15,%rax)
movq %r13, %rax
jne 0xa3bc6
testq %r14, %r14
je 0xa3bf8
cmpb $0x0, (%r14)
je 0xa3bf8
movq $-0x1, %rcx
leaq 0x1(%rcx), %rax
cmpb $0x0, 0x1(%r14,%rcx)
movq %rax, %rcx
jne 0xa3be7
jmp 0xa3bfa
xorl %eax, %eax
movq (%rsp), %rcx
movq 0x6a8(%rcx), %rdx
testq %rdx, %rdx
je 0xa3c26
cmpb $0x0, (%rdx)
je 0xa3c26
movq $-0x1, %rsi
leaq 0x1(%rsi), %rcx
cmpb $0x0, 0x1(%rdx,%rsi)
movq %rcx, %rsi
jne 0xa3c16
jmp 0xa3c28
xorl %ecx, %ecx
addq %rax, %r13
addq %rcx, %r13
movq (%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xf83b
movq %rax, %r12
movq 0x10(%rax), %rdi
movq 0x6a8(%rbx), %r9
testq %r9, %r9
je 0xa3c8c
movq 0x690(%rbx), %r10
testq %r10, %r10
js 0xa3c8c
testq %r15, %r15
leaq 0x81756(%rip), %r8      # 0x1253be
cmovneq %r15, %r8
subq $0x8, %rsp
leaq 0x7c8e7(%rip), %rdx     # 0x12055e
movq %r13, %rsi
movq %r14, %rcx
xorl %eax, %eax
pushq %r10
callq 0x9210
addq $0x10, %rsp
jmp 0xa3cae
testq %r15, %r15
leaq 0x81728(%rip), %r8      # 0x1253be
cmovneq %r15, %r8
leaq 0x7c8e4(%rip), %rdx     # 0x120585
movq %r13, %rsi
movq %r14, %rcx
xorl %eax, %eax
callq 0x9210
movq %rbx, %r13
jmp 0xa3d52
xorl %ecx, %ecx
movq 0x30(%rax), %rax
movq (%rsp), %rdx
movq 0x6a8(%rdx), %rsi
testq %rsi, %rsi
je 0xa3ce8
cmpb $0x0, (%rsi)
je 0xa3ce8
movq $-0x1, %rdi
leaq 0x1(%rdi), %rdx
cmpb $0x0, 0x1(%rsi,%rdi)
movq %rdx, %rdi
jne 0xa3cd8
jmp 0xa3cea
xorl %edx, %edx
addq %rcx, %r13
addq %rax, %r13
addq %rdx, %r13
movq (%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xf83b
movq %rax, %r12
testq %r15, %r15
leaq 0x816ad(%rip), %r8      # 0x1253be
cmovneq %r15, %r8
movq 0x10(%rax), %rdi
movq 0x8(%rbx), %rax
movq 0x10(%rax), %r9
movl 0x20(%rax), %r10d
subq $0x8, %rsp
leaq 0x7c7ff(%rip), %rdx     # 0x12052f
movq %r13, %rsi
movq %rbp, %r13
movq %r14, %rcx
xorl %eax, %eax
pushq 0x690(%rbp)
pushq 0x6a8(%rbp)
pushq %r10
callq 0x9210
addq $0x20, %rsp
cltq
movq %rax, 0x8(%r12)
testq %r15, %r15
je 0xa3d66
movq %r15, %rdi
callq 0x9050
movq 0x1908(%r13), %rsi
movq 0x6d8(%r13), %rax
movq %r12, 0x8(%rax)
movq 0x6d8(%r13), %rdx
movq %r13, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3b366