// File: /workspace/github_c_makefile_star2_O3/BernardTatin[P]s7sh/s7.c
// Function: stacktrace_walker
static char *stacktrace_walker(s7_scheme *sc, s7_pointer code, s7_pointer e, char *notes,
                        s7_int code_cols, s7_int total_cols, s7_int notes_start_col,
                        bool as_comment, int32_t depth)
                {
                    if (is_symbol(code))
                    {
                        if ((!symbol_is_in_list(sc, code)) &&
                                (!is_slot(global_slot(code))))
                        {
                            s7_pointer val;

                            add_symbol_to_list(sc, code);
                            val = s7_symbol_local_value(sc, code, e);
                            if ((val) &&
                                    (val != sc->undefined) &&
                                    (!is_any_macro(val)))
                            {
                                int32_t typ;

                                typ = type(val);
                                if (typ < T_CONTINUATION)
                                {
                                    char *objstr, *str;
                                    s7_pointer objp;
                                    const char *spaces;
                                    s7_int new_note_len, notes_max, spaces_len;
                                    bool new_notes_line = false, old_short_print;
                                    s7_int old_len, objlen;

                                    spaces = "                                                                                ";
                                    spaces_len = 80;

                                    if (notes_start_col < 0) notes_start_col = 50;
                                    if (notes_start_col > total_cols) notes_start_col = 0;
                                    notes_max = total_cols - notes_start_col;

                                    old_short_print = sc->short_print;
                                    sc->short_print = true;
                                    old_len = sc->print_length;
                                    if (sc->print_length > 4) sc->print_length = 4;
                                    objp = s7_object_to_string(sc, val, false);
                                    objstr = string_value(objp);
                                    objlen = string_length(objp);
                                    if ((objlen > notes_max) &&
                                            (notes_max > 5))
                                    {
                                        objstr[notes_max - 4] = '.';
                                        objstr[notes_max - 3] = '.';
                                        objstr[notes_max - 2] = '.';
                                        objstr[notes_max - 1] = '\0';
                                        objlen = notes_max;
                                    }
                                    sc->short_print = old_short_print;
                                    sc->print_length = old_len;

                                    new_note_len = symbol_name_length(code) + 3 + objlen;
                                    /* we want to append this much info to the notes, but does it need a new line? */
                                    if (notes_start_col < code_cols)
                                        new_notes_line = true;
                                    else
                                    {
                                        if (notes)
                                        {
                                            char *last_newline;
                                            s7_int cur_line_len;
                                            last_newline = strrchr(notes, (int)'\n'); /* returns ptr to end if none = nil if not found? */
                                            if (last_newline)
                                                cur_line_len = strlen(notes) - strlen(last_newline);
                                            else cur_line_len = strlen(notes);
                                            new_notes_line = ((cur_line_len + new_note_len) > notes_max);
                                        }
                                    }

                                    if (new_notes_line)
                                    {
                                        new_note_len += (4 + notes_start_col + ((notes) ? strlen(notes) : 0));
                                        str = (char *)malloc(new_note_len);
                                        /* str[0] = '\0'; */
                                        catstrs_direct(str,
                                                (notes) ? notes : "",
                                                "\n",
                                                (as_comment) ? "; " : "",
                                                (spaces_len >= notes_start_col) ? (char *)(spaces + spaces_len - notes_start_col) : "",
                                                (as_comment) ? "" : " ; ",
                                                symbol_name(code),
                                                ": ",
                                                objstr, NULL);
                                    }
                                    else
                                    {
                                        new_note_len += ((notes) ? strlen(notes) : 0) + 4;
                                        str = (char *)malloc(new_note_len);
                                        /* str[0] = '\0'; */
                                        catstrs_direct(str,
                                                (notes) ? notes : "",
                                                (notes) ? ", " : " ; ",
                                                symbol_name(code),
                                                ": ",
                                                objstr, NULL);
                                    }
                                    if (notes) free(notes);
                                    return(str);
                                }
                            }
                        }
                        return(notes);
                    }
                    if ((is_pair(code)) &&
                            (s7_list_length(sc, code) > 0) &&
                            (depth < 32))
                    {
                        notes = stacktrace_walker(sc, car(code), e, notes, code_cols, total_cols, notes_start_col, as_comment, depth + 1);
                        return(stacktrace_walker(sc, cdr(code), e, notes, code_cols, total_cols, notes_start_col, as_comment, depth + 2));
                    }
                    return(notes);
                }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, 0x10(%rsp)
movq %r8, 0x8(%rsp)
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %rbp
movl 0x60(%rsp), %ebx
movzbl 0x58(%rsp), %r12d
movzbl (%r13), %ecx
cmpl $0x1, %ecx
jne 0x9bd51
movq %rbp, %rdi
movq %r13, %rsi
callq 0x39d0d
cmpl $0x1f, %ebx
jg 0x9bff4
testq %rax, %rax
jle 0x9bff4
movq 0x8(%r13), %rsi
leal 0x1(%rbx), %eax
subq $0x8, %rsp
movq %rbp, %rdi
movq %r15, %rdx
movq %r14, %rcx
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %r9
pushq %rax
pushq %r12
pushq 0x68(%rsp)
callq 0x9bcc2
addq $0x20, %rsp
movq %rax, %r14
movq 0x10(%r13), %r13
addl $0x2, %ebx
jmp 0x9bcf0
cmpl $0xa, %ecx
jne 0x9bff4
movl 0xa88(%rbp), %edx
cmpl %edx, 0x2c(%r13)
jne 0x9bd7d
movq 0x8(%r13), %rcx
movq 0x20(%rcx), %rcx
movl 0xc(%rcx), %ecx
cmpl 0xa8c(%rbp), %ecx
je 0x9bff4
movq 0x10(%r13), %rcx
cmpb $0x20, (%rcx)
je 0x9bff4
movq %r14, (%rsp)
movl %edx, 0x2c(%r13)
movl 0xa8c(%rbp), %eax
movq 0x8(%r13), %rcx
movq 0x20(%rcx), %rcx
movl %eax, 0xc(%rcx)
movq %rbp, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0xbe9a
testq %rax, %rax
je 0x9be66
cmpq 0x128(%rbp), %rax
movq (%rsp), %r14
je 0x9bff4
movzbl (%rax), %ecx
cmpq $0x24, %rcx
ja 0x9bff4
leaq 0xb0591(%rip), %rdx     # 0x14c370
cmpb $0x0, (%rcx,%rdx)
jne 0x9bff4
movq 0x50(%rsp), %rdx
testq %rdx, %rdx
movl $0x32, %ecx
cmovnsq %rdx, %rcx
xorl %r15d, %r15d
movq 0x10(%rsp), %rbx
cmpq %rbx, %rcx
cmovleq %rcx, %r15
subq %r15, %rbx
movb 0x248(%rbp), %r14b
movb $0x1, 0x248(%rbp)
movq 0x280(%rbp), %r12
cmpq $0x5, %r12
jl 0x9be32
movq $0x4, 0x280(%rbp)
movq %rbp, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x37a4c
movq 0x8(%rax), %rcx
movq 0x10(%rax), %rdx
cmpq $0x6, %rbx
jl 0x9be6f
movq %rbx, %rax
cmpq %rbx, %rcx
movq (%rsp), %rdi
jle 0x9be73
movl $0x2e2e2e, -0x4(%rdx,%rax) # imm = 0x2E2E2E
movq %rax, %rcx
jmp 0x9be73
movq (%rsp), %r14
jmp 0x9bff4
movq (%rsp), %rdi
movb %r14b, 0x248(%rbp)
movq %r12, 0x280(%rbp)
movq 0x8(%r13), %r13
movq 0x8(%r13), %rax
leaq (%rcx,%rax), %rbp
addq $0x3, %rbp
cmpq 0x8(%rsp), %r15
movq %rdx, 0x10(%rsp)
jge 0x9beb1
leaq 0x4(%r15), %r14
testq %rdi, %rdi
jne 0x9bf03
leaq 0x80621(%rip), %r12     # 0x11c4ce
xorl %eax, %eax
jmp 0x9bf0b
movq %r13, 0x8(%rsp)
testq %rdi, %rdi
je 0x9bf81
movl $0xa, %esi
movq %rdi, %r14
callq 0x8220
movq %rax, %r13
movq %r14, %rdi
callq 0x81a0
movq %rax, %r12
testq %r13, %r13
je 0x9beea
movq %r13, %rdi
callq 0x81a0
subq %rax, %r12
addq %rbp, %r12
cmpq %rbx, %r12
movq (%rsp), %rdi
jle 0x9bf96
leaq 0x4(%r15), %r14
movq 0x8(%rsp), %r13
movq %rdi, %r12
callq 0x81a0
addq %rax, %r14
addq %rbp, %r14
movq %r14, %rdi
callq 0x8480
leaq 0x805ae(%rip), %rdx     # 0x11c4ce
leaq 0x7b629(%rip), %r8      # 0x117550
subq %r15, %r8
addq $0x50, %r8
cmpq $0x51, %r15
cmovaeq %rdx, %r8
leaq 0x7b665(%rip), %rcx     # 0x1175a2
cmpb $0x0, 0x58(%rsp)
cmoveq %rdx, %rcx
movq %rax, %r14
leaq 0x7b651(%rip), %r9      # 0x1175a1
cmovneq %rdx, %r9
leaq 0x6e1e6(%rip), %r10     # 0x10a141
leaq 0x8056b(%rip), %rdx     # 0x11c4cd
movq %rax, %rdi
movq %r12, %rsi
xorl %eax, %eax
pushq $0x0
pushq 0x18(%rsp)
pushq %r10
pushq 0x10(%r13)
callq 0xc442
addq $0x20, %rsp
jmp 0x9bfe6
movl $0x4, %edi
leaq 0x80541(%rip), %r13     # 0x11c4ce
leaq 0x7b60d(%rip), %r12     # 0x1175a1
jmp 0x9bfac
movq %rdi, %r13
callq 0x81a0
movq %rax, %rdi
addq $0x4, %rdi
leaq 0x7b5f9(%rip), %r12     # 0x1175a5
addq %rbp, %rdi
callq 0x8480
movq %rax, %r14
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rcx
subq $0x8, %rsp
leaq 0x6e176(%rip), %r8      # 0x10a141
movq %r14, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq 0x18(%rsp), %r9
xorl %eax, %eax
pushq $0x0
callq 0xc442
addq $0x10, %rsp
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x9bff4
callq 0x8050
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq