// File: /workspace/github_c_makefile_star2_O2/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 $0x78, %rsp
movl %r9d, %r14d
movq %r8, 0x58(%rsp)
movq %rcx, 0x50(%rsp)
movq %rdx, 0x38(%rsp)
movq %rsi, 0x70(%rsp)
movq %rdi, %rbx
callq 0x7c981
movq 0x50(%rbx), %rax
movq 0x198(%rbx), %rcx
subq 0x48(%rbx), %rax
sarq $0x3, %rax
pushq $0x4
popq %rsi
cqto
idivq %rsi
movq %rax, %r13
movq 0x10(%rcx), %rax
movzbl %r14b, %ecx
movl %ecx, 0x24(%rsp)
cmpq 0x8(%rbx), %rax
je 0x35635
leaq (,%r13,4), %rcx
testq %rcx, %rcx
jle 0x35624
movq 0x38(%rbx), %rdx
movq 0x10(%rdx), %rdx
leaq -0x4(%rcx), %rsi
cmpq %rax, -0x10(%rdx,%rcx,8)
movq %rsi, %rcx
jne 0x35607
jmp 0x35635
movq %rbx, %rdi
callq 0x7cef4
testq %rax, %rax
jle 0x356d0
movq 0x1b0(%rbx), %rax
movq 0x10(%rax), %r14
cmpb $0x1, (%r14)
jne 0x35655
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2cd63
testb %al, %al
je 0x3565f
xorl %r14d, %r14d
xorl %eax, %eax
jmp 0x3570c
xorl %ebp, %ebp
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2b7ea
movq %rax, 0x30(%rsp)
movq 0x198(%rbx), %rax
movq 0x10(%rax), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7c99a
movq %rax, %r12
cmpb $0x1c, (%r15)
jne 0x356e0
cmpq 0x150(%rbx), %r15
je 0x356de
andl $0x0, 0x10(%rsp)
movl 0x24(%rsp), %eax
movl %eax, 0x8(%rsp)
movq 0x58(%rsp), %rax
movq %rax, (%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
movq 0x38(%rsp), %r8
movq 0x50(%rsp), %r9
callq 0x7c9c8
movq %rax, %rbp
jmp 0x356e0
xorl %r14d, %r14d
movq $0x0, 0x40(%rsp)
jmp 0x35728
xorl %ebp, %ebp
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rcx
movl 0x24(%rsp), %eax
movl %eax, (%rsp)
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %rbp, %r8
movq 0x38(%rsp), %r9
callq 0x7cd1f
movq %rax, %r14
movq (%rax), %rax
movq %rax, 0x40(%rsp)
movq %rbx, %rdi
callq 0x7cef4
leaq 0x1(%rax), %rcx
shrq $0x2, %rcx
testq %rax, %rax
cmovgq %rcx, %r13
movq %r13, %rbp
shlq $0x5, %rbp
movq $0x0, 0x30(%rsp)
cmpq $0x2, %r13
jl 0x359c8
movq 0x38(%rbx), %rax
movq 0x10(%rax), %rax
movq -0x20(%rax,%rbp), %r15
cmpb $0x1, (%r15)
jne 0x359bc
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2cd63
testb %al, %al
jne 0x359bc
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x2b7ea
cmpq $0x0, 0x8(%rax)
jle 0x359bc
movq 0x10(%rax), %r12
movq %r12, %rdi
leaq 0xadd36(%rip), %rsi     # 0xe34c8
callq 0x70b07
testb %al, %al
jne 0x359bc
movq %r12, %rdi
leaq 0xadd28(%rip), %rsi     # 0xe34d1
callq 0x70b07
testb %al, %al
jne 0x359bc
movq %r12, %rdi
leaq 0xadd16(%rip), %rsi     # 0xe34d6
callq 0x8700
testq %rax, %rax
jne 0x359bc
movq %r12, %rdi
leaq 0xadd0b(%rip), %rsi     # 0xe34e3
callq 0x8700
testq %rax, %rax
jne 0x359bc
movq 0x38(%rbx), %rax
movq 0x10(%rax), %rax
movq -0x18(%rax,%rbp), %rsi
movq %rbx, %rdi
movq %rsi, 0x48(%rsp)
callq 0x7c99a
movq %rax, %r8
cmpb $0xa, (%rax)
jne 0x35892
movq %rbx, %rdi
movq %r8, %rsi
movq %r8, 0x28(%rsp)
callq 0x94b4
movq 0x28(%rsp), %r8
movzbl (%rax), %edx
leaq 0xe5b05(%rip), %rcx     # 0x11b330
cmpb $0x0, (%rdx,%rcx)
je 0x3587a
movq 0x208(%rbx), %rsi
movzbl (%rsi), %edx
leaq 0xe5aee(%rip), %rcx     # 0x11b330
cmpb $0x0, (%rdx,%rcx)
je 0x35887
movq %rax, 0x60(%rsp)
movq %rbx, %rdi
callq 0x97c7
movq 0x60(%rsp), %rdi
movq 0x28(%rsp), %r8
cmpb $0x1, (%rax)
jne 0x35892
movq %rax, %rsi
callq 0x7cf28
movq 0x28(%rsp), %r8
testb %al, %al
je 0x35892
jmp 0x359bc
cmpb $0x14, %dl
jne 0x35892
testb $0x20, 0x2(%rax)
jne 0x35831
jmp 0x35892
cmpb $0x14, %dl
jne 0x35892
testb $0x20, 0x2(%rsi)
jne 0x35848
movq 0x30(%rsp), %rax
cmpq 0x70(%rsp), %rax
jge 0x359cd
movq 0x48(%rsp), %rdx
cmpb $0x1c, (%rdx)
movq %r14, 0x68(%rsp)
jne 0x358f2
cmpq 0x150(%rbx), %rdx
je 0x358f2
andl $0x0, 0x10(%rsp)
movl 0x24(%rsp), %eax
movl %eax, 0x8(%rsp)
movq 0x58(%rsp), %rax
movq %rax, (%rsp)
movq %rbx, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
movq %r8, %r14
movq 0x38(%rsp), %r8
movq 0x50(%rsp), %r9
callq 0x7c9c8
movq %r14, %r8
movq %rax, %r14
jmp 0x358f5
xorl %r14d, %r14d
movl 0x24(%rsp), %eax
movl %eax, (%rsp)
movq %rbx, %rdi
movq %r8, %rsi
movq %r15, %rdx
movq %r12, %rcx
movq %r14, %r8
movq 0x38(%rsp), %r9
callq 0x7cd1f
movq %rax, 0x28(%rsp)
movq (%rax), %r12
testq %r14, %r14
movq 0x48(%rsp), %rax
je 0x35942
cmpq %r12, %r14
je 0x35942
cmpb $0x1c, (%rax)
jne 0x35942
cmpq 0x150(%rbx), %rax
je 0x35942
movq %r14, %rdi
callq 0x8050
movq %r12, %rdi
callq 0x81a0
movq %rax, %r14
movq 0x40(%rsp), %r15
testq %r15, %r15
je 0x35961
movq %r15, %rdi
callq 0x81a0
jmp 0x3596a
leaq 0xb2b06(%rip), %r15     # 0xe846e
xorl %eax, %eax
incq %r14
addq %rax, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x9037
movq %rax, %r14
movq (%rax), %rdi
movq %r15, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0xb3a5
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
callq 0x9439
movq 0x68(%rsp), %rsi
testq %rsi, %rsi
je 0x359af
movq %rbx, %rdi
callq 0x9439
incq 0x30(%rsp)
movq (%r14), %rax
movq %rax, 0x40(%rsp)
addq $-0x20, %rbp
decq %r13
jmp 0x35738
testq %r14, %r14
je 0x359f1
movq (%r14), %rdi
callq 0x8d06
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2bf22
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xd239