// File: /workspace/github_c_makefile_star2_O3/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, %r12d
movq %r8, %rbp
movq %rcx, 0x60(%rsp)
movq %rdx, 0x38(%rsp)
movq %rsi, %r15
movq %rdi, %r9
incl 0xa88(%rdi)
jne 0x430c8
movl $0x1, 0xa88(%r9)
incl 0xa8c(%r9)
movq 0x50(%r9), %rcx
movq 0x198(%r9), %rdx
subq 0x48(%r9), %rcx
sarq $0x3, %rcx
leaq 0x3(%rcx), %rdi
testq %rcx, %rcx
movq %rcx, %r14
cmovsq %rdi, %r14
sarq $0x2, %r14
movq 0x10(%rdx), %rdx
cmpq 0x8(%r9), %rdx
movq %r9, 0x8(%rsp)
je 0x4313c
cmpq $0x4, %rcx
jl 0x4316c
movq 0x38(%r9), %rcx
movq 0x10(%rcx), %rcx
leaq 0x4(,%r14,4), %rsi
cmpq %rdx, -0x30(%rcx,%rsi,8)
je 0x4313c
addq $-0x4, %rsi
cmpq $0x5, %rsi
jge 0x43112
xorl %eax, %eax
cmpq $0x1f0, -0x20(%rcx,%rdi,8) # imm = 0x1F0
je 0x4313c
addq $-0x4, %rdi
cmpq $0x6, %rdi
jg 0x43125
jmp 0x4316e
movq 0x1b0(%r9), %rax
movq 0x10(%rax), %r13
cmpb $0x1, (%r13)
jne 0x43175
movq %r9, %rdi
movq %r13, %rsi
movq %r9, %rbx
callq 0x38d93
testb %al, %al
je 0x4317e
xorl %eax, %eax
xorl %edi, %edi
movq %rbx, %r9
jmp 0x43248
xorl %eax, %eax
xorl %edi, %edi
jmp 0x43286
xorl %eax, %eax
xorl %edi, %edi
jmp 0x43248
movq %rbx, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x37a4c
movq %rax, %r9
movq 0x198(%rbx), %rax
movq 0x10(%rax), %rdx
movb (%rdx), %al
cmpb $0x1c, %al
movq %rbx, %rdi
movq %rbp, 0x30(%rsp)
jne 0x431c9
movq 0x150(%rdi), %rsi
movq %rdx, %rcx
cmpq %rcx, %rsi
je 0x431c9
testb $0x20, 0x3(%rcx)
jne 0x436ee
movq 0x10(%rcx), %rcx
cmpb $0x1c, (%rcx)
je 0x431b1
leaq 0x120(%rdi), %rcx
movq (%rcx), %rbp
cmpb $0x1c, %al
jne 0x43217
cmpq 0x150(%rdi), %rdx
je 0x43217
subq $0x8, %rsp
movzbl %r12b, %eax
movq %r13, %rsi
xorl %ecx, %ecx
movq 0x40(%rsp), %r8
movq %r9, %rbx
movq 0x68(%rsp), %r9
pushq $0x0
pushq %rax
pushq 0x48(%rsp)
callq 0x9bcc2
movq %rbx, %r9
movq 0x28(%rsp), %rdi
addq $0x20, %rsp
movq %rax, %r8
jmp 0x4321a
xorl %r8d, %r8d
movq 0x10(%r9), %rcx
subq $0x8, %rsp
movzbl %r12b, %eax
movq %rbp, %rsi
movq %r13, %rdx
movq 0x40(%rsp), %r9
pushq %rax
callq 0x9c006
movq 0x18(%rsp), %r9
addq $0x10, %rsp
movq (%rax), %rdi
movq 0x30(%rsp), %rbp
movq 0x50(%r9), %rsi
subq 0x48(%r9), %rsi
sarq $0x3, %rsi
cmpq $0x4, %rsi
jl 0x43286
movq 0x38(%r9), %rcx
movq 0x10(%rcx), %rcx
cmpq $0x1f0, -0x8(%rcx,%rsi,8) # imm = 0x1F0
je 0x4327f
leaq -0x4(%rsi), %rdx
decq %rsi
cmpq $0x6, %rsi
movq %rdx, %rsi
jg 0x43262
jmp 0x43286
shrq $0x2, %rsi
movq %rsi, %r14
xorl %ecx, %ecx
testq %r15, %r15
cmovgq %r15, %rcx
cmpq $0x2, %r14
jl 0x4368b
movq %rcx, 0x68(%rsp)
movq %rax, 0x18(%rsp)
movl %r12d, 0x4c(%rsp)
leaq 0x120(%r9), %rax
movq %rax, 0x40(%rsp)
leaq 0x838(%r9), %rax
movq %rax, 0x28(%rsp)
leaq 0xd4261(%rip), %r12     # 0x117528
leaq 0xd4263(%rip), %rsi     # 0x117531
movq $0x0, 0x58(%rsp)
movq %rbp, 0x30(%rsp)
movq %rdi, 0x70(%rsp)
movq %r14, %r13
decq %r14
movq 0x38(%r9), %rax
movq 0x10(%rax), %rax
movq %r13, %rcx
shlq $0x5, %rcx
movq -0x20(%rax,%rcx), %r15
cmpb $0x1, (%r15)
jne 0x433be
movq %r9, %rdi
movq %rsi, %rbx
movq %r15, %rsi
callq 0x38d93
movq 0x8(%rsp), %r9
movq %rbx, %rsi
testb %al, %al
jne 0x433be
movq %r9, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x37a4c
movq 0x8(%rsp), %r9
movq %rbx, %rsi
cmpq $0x0, 0x8(%rax)
jle 0x433be
leaq (,%r13,4), %rdi
movq 0x10(%rax), %rbp
xorl %eax, %eax
movb (%rbp,%rax), %cl
movb (%rax,%r12), %dl
testb %cl, %cl
je 0x43360
incq %rax
cmpb %dl, %cl
je 0x4334d
cmpb %dl, %cl
je 0x433be
xorl %eax, %eax
movb (%rbp,%rax), %cl
movb (%rax,%rsi), %dl
testb %cl, %cl
je 0x43378
incq %rax
cmpb %dl, %cl
je 0x43366
cmpb %dl, %cl
je 0x433be
movq %rdi, 0x10(%rsp)
movq %rbp, %rdi
leaq 0xd41ab(%rip), %rsi     # 0x117536
callq 0x8700
movq 0x8(%rsp), %r9
movq %rbx, %rsi
testq %rax, %rax
jne 0x433be
movq %rbp, %rdi
leaq 0xd419c(%rip), %rsi     # 0x117543
callq 0x8700
movq 0x10(%rsp), %rcx
movq 0x8(%rsp), %r9
movq %rbx, %rsi
testq %rax, %rax
je 0x433cd
cmpq $0x2, %r13
jg 0x432e1
jmp 0x43690
movq 0x38(%r9), %rax
movq 0x10(%rax), %rax
movq -0x18(%rax,%rcx,8), %rdx
movb (%rdx), %cl
movq 0x40(%rsp), %rax
movb %cl, 0x7(%rsp)
cmpb $0x1c, %cl
jne 0x43413
movq 0x150(%r9), %rcx
movq %rdx, %rax
cmpq %rax, %rcx
je 0x43408
testb $0x20, 0x3(%rax)
jne 0x4340f
movq 0x10(%rax), %rax
cmpb $0x1c, (%rax)
je 0x433f4
movq 0x40(%rsp), %rax
jmp 0x43413
addq $0x20, %rax
movq %rdx, 0x50(%rsp)
movq (%rax), %rax
movq %rax, 0x10(%rsp)
cmpb $0xa, (%rax)
jne 0x434b5
movq %r9, %rdi
movq 0x10(%rsp), %rsi
callq 0x9a93
movq 0x8(%rsp), %r9
movzbl (%rax), %edx
leaq 0x108eeb(%rip), %rcx    # 0x14c330
cmpb $0x0, (%rdx,%rcx)
jne 0x43456
cmpb $0x14, %dl
jne 0x434b5
testb $0x20, 0x2(%rax)
je 0x434b5
movq 0x208(%r9), %rdi
movzbl (%rdi), %ecx
leaq 0x108ec9(%rip), %rdx    # 0x14c330
cmpb $0x0, (%rcx,%rdx)
jne 0x43478
cmpb $0x14, %cl
jne 0x434b5
testb $0x20, 0x2(%rdi)
je 0x434b5
movq 0x18e0(%r9), %rsi
movq 0x18(%rdi), %rdx
movq %rax, 0x20(%rsp)
movq %r9, %rdi
callq 0xbe9a
movq 0x20(%rsp), %rcx
movq 0x8(%rsp), %r9
cmpb $0x1, (%rax)
jne 0x434b5
movq %rbx, %rsi
cmpq %rcx, 0x8(%rax)
je 0x433be
movq 0x10(%rax), %rax
cmpb $0x1, (%rax)
je 0x434a2
movq 0x58(%rsp), %rax
cmpq 0x68(%rsp), %rax
je 0x436f7
movzbl 0x4c(%rsp), %eax
cmpb $0x1c, 0x7(%rsp)
jne 0x43519
movq 0x50(%rsp), %rdx
cmpq 0x150(%r9), %rdx
je 0x43519
subq $0x8, %rsp
movq %r9, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
movq 0x40(%rsp), %r8
movq 0x68(%rsp), %r9
pushq $0x0
pushq %rax
pushq 0x48(%rsp)
movq %rax, 0x40(%rsp)
callq 0x9bcc2
movq 0x28(%rsp), %r9
addq $0x20, %rsp
movq %rax, %r8
movq 0x20(%rsp), %rax
jmp 0x4351c
xorl %r8d, %r8d
subq $0x8, %rsp
movq %r9, %rdi
movq 0x18(%rsp), %rsi
movq %r15, %rdx
movq %rbp, %rcx
movq %r8, %r15
movq 0x40(%rsp), %r9
pushq %rax
callq 0x9c006
movq %r15, %rdi
addq $0x10, %rsp
movq %rax, 0x10(%rsp)
movq (%rax), %r15
testq %rdi, %rdi
movq 0x50(%rsp), %rcx
je 0x43572
cmpq %r15, %rdi
je 0x43572
cmpb $0x1c, (%rcx)
jne 0x43572
movq 0x8(%rsp), %rax
cmpq 0x150(%rax), %rcx
je 0x43572
callq 0x8050
movq %r15, 0x20(%rsp)
movq %r15, %rdi
callq 0x81a0
movq %rax, %r15
movq 0x70(%rsp), %rbp
testq %rbp, %rbp
je 0x43596
movq %rbp, %rdi
callq 0x81a0
jmp 0x4359f
leaq 0xd8f31(%rip), %rbp     # 0x11c4ce
xorl %eax, %eax
incq %r15
addq %rax, %r15
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x9357
movq %rax, %r15
movq (%rax), %rdi
movq %rbp, %rsi
movq 0x20(%rsp), %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0xc442
movq 0x10(%rsp), %rbp
movslq 0x8(%rbp), %rax
cmpq $0x11, %rax
jne 0x435fc
movq (%rbp), %rdi
testq %rdi, %rdi
je 0x435ee
callq 0x8050
movq $0x0, (%rbp)
movl $0x0, 0x8(%rbp)
movq 0x28(%rsp), %rax
jmp 0x43605
movq 0x28(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
movq (%rax), %rcx
movq %rcx, 0x18(%rbp)
movq %rbp, (%rax)
movq 0x18(%rsp), %rdx
testq %rdx, %rdx
movq %rbx, %rsi
movq 0x8(%rsp), %r9
je 0x43672
movslq 0x8(%rdx), %rax
cmpq $0x11, %rax
jne 0x4365f
movq (%rdx), %rdi
testq %rdi, %rdi
je 0x43651
movq %rdx, 0x18(%rsp)
callq 0x8050
movq 0x18(%rsp), %rdx
movq 0x8(%rsp), %r9
movq %rbx, %rsi
movq $0x0, (%rdx)
movl $0x0, 0x8(%rdx)
movq 0x28(%rsp), %rax
jmp 0x43668
movq 0x28(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
movq (%rax), %rcx
movq %rcx, 0x18(%rdx)
movq %rdx, (%rax)
incq 0x58(%rsp)
movq (%r15), %rdi
movq %r15, 0x18(%rsp)
cmpq $0x2, %r13
jg 0x432dc
jmp 0x4369d
movq %rax, %r15
jmp 0x43695
movq 0x18(%rsp), %r15
testq %r15, %r15
je 0x436d4
movq (%r15), %rdi
testq %rdi, %rdi
je 0x436b9
cmpb $0x0, (%rdi)
je 0x436b9
xorl %eax, %eax
leaq 0x1(%rax), %rdx
cmpb $0x0, 0x1(%rdi,%rax)
movq %rdx, %rax
jne 0x436a9
jmp 0x436bb
xorl %edx, %edx
movq %r9, %rdi
movq %r15, %rsi
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x37ebe
movq %r9, %rdi
xorl %esi, %esi
xorl %edx, %edx
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xeab0
addq $0x20, %rcx
jmp 0x431d0
movq 0x18(%rsp), %rsi
movq (%rsi), %rax
testq %rax, %rax
je 0x4371b
cmpb $0x0, (%rax)
je 0x4371b
xorl %edx, %edx
cmpb $0x0, 0x1(%rax,%rdx)
leaq 0x1(%rdx), %rdx
jne 0x4370b
movq %r9, %rdi
jmp 0x436c1
movq %r9, %rdi
xorl %edx, %edx
jmp 0x436c1