// File: /workspace/github_c_makefile_star2_O1/BernardTatin[P]s7sh/s7.c
// Function: stacktrace_1
static s7_pointer stacktrace_1(s7_scheme *sc, s7_int frames_max, s7_int code_cols, s7_int total_cols, s7_int notes_start_col, bool as_comment)
                {
                    char *str = NULL;
                    block_t *strp = NULL;
                    int64_t loc, top, frames = 0;

                    clear_symbol_list(sc);
                    top = (sc->stack_end - sc->stack_start) / 4; /* (*s7* 'stack_top), not s7_stack_top! */

                    if (stacktrace_in_error_handler(sc, top))
                    {
                        s7_pointer err_code;
                        err_code = slot_value(sc->error_code);
                        if ((is_pair(err_code)) &&
                                (!tree_is_cyclic(sc, err_code)))
                        {
                            char *notes = NULL;
                            s7_pointer cur_env, f, errstr;

                            errstr = s7_object_to_string(sc, err_code, false);
                            cur_env = outlet(sc->owlet);
                            f = stacktrace_find_caller(sc, cur_env); /* this is a symbol */
                            if ((is_let(cur_env)) &&
                                    (cur_env != sc->rootlet))
                                notes = stacktrace_walker(sc, err_code, cur_env, NULL, code_cols, total_cols, notes_start_col, as_comment, 0);
                            strp = stacktrace_add_func(sc, f, err_code, string_value(errstr), notes, code_cols, as_comment);
                            str = (char *)block_data(strp);
                        }

                        /* now if OP_ERROR_HOOK_QUIT is in the stack, jump past it! */
                        loc = stacktrace_find_error_hook_quit(sc);
                        if (loc > 0) top = (loc + 1) / 4;
                    }

                    for (loc = top - 1; loc > 0; loc--)
                    {
                        s7_pointer code;
                        s7_int true_loc;

                        true_loc = (loc + 1) * 4 - 1;
                        code = stack_code(sc->stack, true_loc);
                        if ((is_pair(code)) &&
                                (!tree_is_cyclic(sc, code)))
                        {
                            s7_pointer codep;
                            codep = s7_object_to_string(sc, code, false);
                            if (string_length(codep) > 0)
                            {
                                char *codestr;
                                codestr = string_value(codep);
                                if ((!local_strcmp(codestr, "(result)")) &&
                                        (!local_strcmp(codestr, "(#f)")) &&
                                        (!strstr(codestr, "(stacktrace)")) &&
                                        (!strstr(codestr, "(stacktrace ")))
                                {
                                    s7_pointer e, f;

                                    e = stack_let(sc->stack, true_loc);
                                    f = stacktrace_find_caller(sc, e);
                                    if (!stacktrace_error_hook_function(sc, f))
                                    {
                                        char *notes = NULL, *newstr, *catstr;
                                        block_t *newp, *catp;
                                        s7_int newlen;

                                        frames++;
                                        if (frames > frames_max)
                                            return(block_to_string(sc, strp, safe_strlen((char *)block_data(strp))));

                                        if ((is_let(e)) && (e != sc->rootlet))
                                            notes = stacktrace_walker(sc, code, e, NULL, code_cols, total_cols, notes_start_col, as_comment, 0);
                                        newp = stacktrace_add_func(sc, f, code, codestr, notes, code_cols, as_comment);
                                        newstr = (char *)block_data(newp);

                                        if ((notes) && (notes != newstr) && (is_let(e)) && (e != sc->rootlet))
                                            free(notes);

                                        newlen = strlen(newstr) + 1 + ((str) ? strlen(str) : 0);
                                        catp = mallocate(sc, newlen);
                                        catstr = (char *)block_data(catp);
                                        catstrs_direct(catstr, (str) ? str : "", newstr, NULL);
                                        liberate(sc, newp);
                                        if (strp) liberate(sc, strp);
                                        strp = catp;
                                        str = (char *)block_data(strp);
                                    }}}}}
                    if (strp)
                        return(block_to_string(sc, strp, safe_strlen((char *)block_data(strp))));
                    return(make_empty_string(sc, 0, 0));
                }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %r9d, 0x1c(%rsp)
movq %r8, 0x48(%rsp)
movq %rcx, 0x40(%rsp)
movq %rdx, 0x38(%rsp)
movq %rsi, 0x60(%rsp)
movq %rdi, %rbp
incl 0xa88(%rdi)
jne 0x45bf0
movl $0x1, 0xa88(%rbp)
incl 0xa8c(%rbp)
movq 0x50(%rbp), %rbx
movq 0x198(%rbp), %rax
subq 0x48(%rbp), %rbx
sarq $0x3, %rbx
leaq 0x3(%rbx), %r12
testq %rbx, %rbx
cmovnsq %rbx, %r12
sarq $0x2, %r12
movq 0x10(%rax), %rdx
cmpq 0x8(%rbp), %rdx
movq %rbp, (%rsp)
je 0x45c68
leaq (,%r12,4), %rsi
movq %rbp, %rdi
callq 0xa2c3c
testb %al, %al
jne 0x45c68
cmpq $0x4, %rbx
jl 0x45c98
decq %rbx
movq 0x38(%rbp), %rax
movq 0x10(%rax), %rax
cmpq $0x1f0, (%rax,%rbx,8)   # imm = 0x1F0
je 0x45c63
leaq -0x4(%rbx), %rcx
cmpq $0x6, %rbx
movq %rcx, %rbx
jg 0x45c45
movq $-0x1, %rbx
testq %rbx, %rbx
jle 0x45c98
movq 0x1b0(%rbp), %rax
movq 0x10(%rax), %r14
cmpb $0x1, (%r14)
jne 0x45c88
movq %rbp, %rdi
movq %r14, %rsi
callq 0x3b2ff
testb %al, %al
je 0x45caf
xorl %eax, %eax
movq $0x0, 0x8(%rsp)
jmp 0x45d5f
movq $0x0, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
jmp 0x45db3
xorl %r13d, %r13d
movq %rbp, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x39f84
movq %rax, 0x10(%rsp)
movq 0x198(%rbp), %rax
movq %rbp, %rbx
movq 0x10(%rax), %rbp
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xa26a0
movq %rax, %r15
cmpb $0x1c, (%rbp)
jne 0x45d25
cmpq 0x150(%rbx), %rbp
je 0x45d22
subq $0x8, %rsp
movzbl 0x24(%rsp), %eax
movq %rbx, %rdi
movq %r14, %rsi
movq %rbp, %rdx
xorl %ecx, %ecx
movq 0x40(%rsp), %r8
movq 0x48(%rsp), %r9
pushq $0x0
pushq %rax
pushq 0x60(%rsp)
callq 0xa26c7
addq $0x20, %rsp
movq %rax, %r13
jmp 0x45d25
xorl %r13d, %r13d
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rcx
subq $0x8, %rsp
movzbl 0x24(%rsp), %eax
movq 0x8(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %r13, %r8
movq 0x40(%rsp), %r9
pushq %rax
callq 0xa2a09
addq $0x10, %rsp
movq (%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x50(%rbp), %rcx
subq 0x48(%rbp), %rcx
sarq $0x3, %rcx
movq $-0x1, %rdi
cmpq $0x4, %rcx
jl 0x45d9f
decq %rcx
movq 0x38(%rbp), %rdx
movq 0x10(%rdx), %rdx
cmpq $0x1f0, (%rdx,%rcx,8)   # imm = 0x1F0
je 0x45d9c
leaq -0x4(%rcx), %rsi
cmpq $0x6, %rcx
movq %rsi, %rcx
jg 0x45d83
jmp 0x45d9f
movq %rcx, %rdi
movq %rax, 0x10(%rsp)
leaq 0x1(%rdi), %rcx
shrq $0x2, %rcx
testq %rdi, %rdi
cmovgq %rcx, %r12
leaq 0x838(%rbp), %rax
movq %rax, 0x30(%rsp)
leaq 0xda652(%rip), %r14     # 0x120418
xorl %ebx, %ebx
cmpq $0x2, %r12
jl 0x46169
movq 0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq %r12, %rcx
shlq $0x5, %rcx
movq -0x20(%rax,%rcx), %r15
movb $0x1, %al
cmpb $0x1, (%r15)
jne 0x45e8e
movq %rbp, %rdi
movq %r15, %rsi
callq 0x3b2ff
testb %al, %al
jne 0x45e93
movq %rbp, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x39f84
cmpq $0x0, 0x8(%rax)
jle 0x45e93
leaq (,%r12,4), %r13
movq 0x10(%rax), %rbp
xorl %eax, %eax
leaq 0xda5f3(%rip), %rsi     # 0x120421
movb (%rbp,%rax), %cl
movb (%rax,%r14), %dl
testb %cl, %cl
je 0x45e41
incq %rax
cmpb %dl, %cl
je 0x45e2e
cmpb %dl, %cl
je 0x45e85
xorl %eax, %eax
movb (%rbp,%rax), %cl
movb (%rax,%rsi), %dl
testb %cl, %cl
je 0x45e59
incq %rax
cmpb %dl, %cl
je 0x45e47
cmpb %dl, %cl
je 0x45e85
movq %rbp, %rdi
leaq 0xda5bf(%rip), %rsi     # 0x120426
callq 0x9700
testq %rax, %rax
jne 0x45e85
movq %rbp, %rdi
leaq 0xda5b8(%rip), %rsi     # 0x120433
callq 0x9700
testq %rax, %rax
je 0x45eab
movq %rbx, %r13
movq (%rsp), %rbp
jmp 0x45e96
movq %rbx, %r13
jmp 0x45e98
movq %rbx, %r13
movb $0x1, %al
decq %r12
movq %r13, %rbx
testb %al, %al
jne 0x45dc8
jmp 0x46197
movq (%rsp), %rdi
movq 0x38(%rdi), %rax
movq 0x10(%rax), %rax
movq -0x18(%rax,%r13,8), %rsi
movq %rsi, 0x28(%rsp)
callq 0xa26a0
movq %rax, %r13
cmpb $0xa, (%rax)
jne 0x45f56
movq (%rsp), %rdi
movq %r13, %rsi
callq 0xaa24
movq %rax, %rsi
movzbl (%rax), %eax
leaq 0x10e445(%rip), %rcx    # 0x154330
cmpb $0x0, (%rax,%rcx)
je 0x45f3f
movq (%rsp), %rax
movq 0x208(%rax), %rax
movzbl (%rax), %ecx
leaq 0x10e42a(%rip), %rdx    # 0x154330
cmpb $0x0, (%rcx,%rdx)
je 0x45f4b
movq (%rsp), %rdi
movq %rsi, 0x20(%rsp)
movq 0x18e0(%rdi), %rsi
movq 0x18(%rax), %rdx
callq 0xcd2c
movq 0x20(%rsp), %rcx
cmpb $0x1, (%rax)
jne 0x45f56
cmpq %rcx, 0x8(%rax)
je 0x45e85
movq 0x10(%rax), %rax
jmp 0x45f2a
cmpb $0x14, %al
jne 0x45f56
testb $0x20, 0x2(%rsi)
jne 0x45ef1
jmp 0x45f56
cmpb $0x14, %cl
jne 0x45f56
testb $0x20, 0x2(%rax)
jne 0x45f0c
movq %r13, 0x20(%rsp)
leaq 0x1(%rbx), %r13
cmpq 0x60(%rsp), %rbx
jge 0x45fb4
movq 0x28(%rsp), %rdx
cmpb $0x1c, (%rdx)
movzbl 0x1c(%rsp), %eax
jne 0x45fec
movq (%rsp), %rdi
cmpq 0x150(%rdi), %rdx
je 0x45fec
subq $0x8, %rsp
movq %r15, %rsi
xorl %ecx, %ecx
movq 0x40(%rsp), %r8
movq 0x48(%rsp), %r9
pushq $0x0
pushq %rax
pushq 0x60(%rsp)
movq %rax, 0x70(%rsp)
callq 0xa26c7
addq $0x20, %rsp
movq %rax, %rbx
movq 0x50(%rsp), %rax
jmp 0x45fee
movq 0x10(%rsp), %rsi
movq (%rsi), %rax
testq %rax, %rax
je 0x4606e
cmpb $0x0, (%rax)
movq (%rsp), %rbp
je 0x46153
movq $-0x1, %rcx
leaq 0x1(%rcx), %rdx
cmpb $0x0, 0x1(%rax,%rcx)
movq %rdx, %rcx
jne 0x45fd9
jmp 0x46155
xorl %ebx, %ebx
subq $0x8, %rsp
movq 0x8(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq %r15, %rdx
movq %rbp, %rcx
movq %rbx, %r8
movq 0x40(%rsp), %r9
pushq %rax
callq 0xa2a09
addq $0x10, %rsp
movq %rax, %r15
movq (%rax), %rbp
testq %rbx, %rbx
movq 0x28(%rsp), %rcx
je 0x46043
cmpq %rbp, %rbx
je 0x46043
cmpb $0x1c, (%rcx)
jne 0x46043
movq (%rsp), %rax
cmpq 0x150(%rax), %rcx
je 0x46043
movq %rbx, %rdi
callq 0x9050
movq %rbp, 0x20(%rsp)
movq %rbp, %rdi
callq 0x91a0
movq %rax, %rbp
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
movq 0x10(%rsp), %rbx
je 0x46079
movq %rdi, 0x8(%rsp)
callq 0x91a0
jmp 0x46087
xorl %edx, %edx
movq (%rsp), %rbp
jmp 0x46155
leaq 0xdf33e(%rip), %rax     # 0x1253be
movq %rax, 0x8(%rsp)
xorl %eax, %eax
incq %rbp
addq %rax, %rbp
movq (%rsp), %rdi
movq %rbp, %rsi
callq 0xa305
movq %rax, 0x28(%rsp)
movq (%rax), %rdi
movq 0x8(%rsp), %rsi
movq 0x20(%rsp), %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0xd1cb
movslq 0x8(%r15), %rax
cmpq $0x11, %rax
jne 0x460e1
movq (%r15), %rdi
testq %rdi, %rdi
je 0x460d2
callq 0x9050
movq $0x0, (%r15)
movl $0x0, 0x8(%r15)
movq 0x30(%rsp), %rax
jmp 0x460ea
movq 0x30(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
movq (%rsp), %rbp
movq (%rax), %rcx
movq %rcx, 0x18(%r15)
movq %r15, (%rax)
testq %rbx, %rbx
je 0x4613c
movslq 0x8(%rbx), %rax
cmpq $0x11, %rax
jne 0x46129
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x4611b
callq 0x9050
movq $0x0, (%rbx)
movl $0x0, 0x8(%rbx)
movq 0x30(%rsp), %rax
jmp 0x46132
movq 0x30(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
movq (%rax), %rcx
movq %rcx, 0x18(%rbx)
movq %rbx, (%rax)
movq 0x28(%rsp), %rcx
movq (%rcx), %rax
movq %rax, 0x8(%rsp)
movq %rcx, 0x10(%rsp)
jmp 0x45e96
xorl %edx, %edx
movq %rbp, %rdi
callq 0x3a419
movq %rax, 0x58(%rsp)
xorl %eax, %eax
jmp 0x45e98
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
je 0x461c3
movq (%rsi), %rax
testq %rax, %rax
je 0x461ab
cmpb $0x0, (%rax)
je 0x461ab
movq $-0x1, %rcx
leaq 0x1(%rcx), %rdx
cmpb $0x0, 0x1(%rax,%rcx)
movq %rdx, %rcx
jne 0x46187
jmp 0x461ad
movq 0x58(%rsp), %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %edx, %edx
movq %rbp, %rdi
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3a419
movq %rbp, %rdi
xorl %esi, %esi
xorl %edx, %edx
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xf83b