// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x148, %rsp            # imm = 0x148
movb %r9b, %al
movq %rdi, 0x138(%rsp)
movq %rsi, 0x130(%rsp)
movq %rdx, 0x128(%rsp)
movq %rcx, 0x120(%rsp)
movq %r8, 0x118(%rsp)
andb $0x1, %al
movb %al, 0x117(%rsp)
movq $0x0, 0x108(%rsp)
movq $0x0, 0x100(%rsp)
movq $0x0, 0xe8(%rsp)
movq 0x138(%rsp), %rdi
callq 0xdd1b0
movq 0x138(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x138(%rsp), %rcx
movq 0x48(%rcx), %rcx
subq %rcx, %rax
sarq $0x3, %rax
movl $0x4, %ecx
cqto
idivq %rcx
movq %rax, 0xf0(%rsp)
movq 0x138(%rsp), %rdi
movq 0xf0(%rsp), %rsi
callq 0xdd200
testb $0x1, %al
jne 0x4489b
jmp 0x44a74
movq 0x138(%rsp), %rax
movq 0x1b0(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, 0xe0(%rsp)
movq 0xe0(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x1, %eax
jne 0x44a34
movq 0x138(%rsp), %rdi
movq 0xe0(%rsp), %rsi
callq 0x2f870
testb $0x1, %al
jne 0x44a34
movq $0x0, 0xd8(%rsp)
movq 0x138(%rsp), %rdi
movq 0xe0(%rsp), %rsi
xorl %edx, %edx
callq 0x2cd00
movq %rax, 0xc0(%rsp)
movq 0x138(%rsp), %rax
movq 0x198(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, 0xd0(%rsp)
movq 0x138(%rsp), %rdi
movq 0xd0(%rsp), %rsi
callq 0xdd280
movq %rax, 0xc8(%rsp)
movq 0xd0(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x1c, %eax
jne 0x449d1
movq 0xd0(%rsp), %rax
movq 0x138(%rsp), %rcx
cmpq 0x150(%rcx), %rax
je 0x449d1
movq 0x138(%rsp), %rdi
movq 0xe0(%rsp), %rsi
movq 0xd0(%rsp), %rdx
movq 0x128(%rsp), %r8
movq 0x120(%rsp), %r9
movq 0x118(%rsp), %r10
movb 0x117(%rsp), %al
xorl %ecx, %ecx
xorl %r11d, %r11d
andb $0x1, %al
movq %r10, (%rsp)
movzbl %al, %eax
movl %eax, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0xdd310
movq %rax, 0xd8(%rsp)
movq 0x138(%rsp), %rdi
movq 0xc8(%rsp), %rsi
movq 0xe0(%rsp), %rdx
movq 0xc0(%rsp), %rax
movq 0x10(%rax), %rcx
movq 0xd8(%rsp), %r8
movq 0x128(%rsp), %r9
movb 0x117(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, (%rsp)
callq 0xddb40
movq %rax, 0x100(%rsp)
movq 0x100(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x108(%rsp)
movq 0x138(%rsp), %rdi
callq 0xddf10
movq %rax, 0xf8(%rsp)
cmpq $0x0, 0xf8(%rsp)
jle 0x44a72
movq 0xf8(%rsp), %rax
addq $0x1, %rax
movl $0x4, %ecx
cqto
idivq %rcx
movq %rax, 0xf0(%rsp)
jmp 0x44a74
movq 0xf0(%rsp), %rax
subq $0x1, %rax
movq %rax, 0xf8(%rsp)
cmpq $0x0, 0xf8(%rsp)
jle 0x44f0c
movq 0xf8(%rsp), %rax
addq $0x1, %rax
shlq $0x2, %rax
subq $0x1, %rax
movq %rax, 0xb0(%rsp)
movq 0x138(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x10(%rax), %rax
movq 0xb0(%rsp), %rcx
subq $0x3, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0xb8(%rsp)
movq 0xb8(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x1, %eax
jne 0x44ef1
movq 0x138(%rsp), %rdi
movq 0xb8(%rsp), %rsi
callq 0x2f870
testb $0x1, %al
jne 0x44ef1
movq 0x138(%rsp), %rdi
movq 0xb8(%rsp), %rsi
xorl %edx, %edx
callq 0x2cd00
movq %rax, 0xa8(%rsp)
movq 0xa8(%rsp), %rax
cmpq $0x0, 0x8(%rax)
jle 0x44eef
movq 0xa8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0xa0(%rsp)
movq 0xa0(%rsp), %rdi
leaq 0x1aa487(%rip), %rsi    # 0x1eefe8
callq 0xc0a00
testb $0x1, %al
jne 0x44eed
movq 0xa0(%rsp), %rdi
leaq 0x1aa474(%rip), %rsi    # 0x1eeff1
callq 0xc0a00
testb $0x1, %al
jne 0x44eed
movq 0xa0(%rsp), %rdi
leaq 0x1aa45d(%rip), %rsi    # 0x1eeff6
callq 0x9700
cmpq $0x0, %rax
jne 0x44eed
movq 0xa0(%rsp), %rdi
leaq 0x1aa44c(%rip), %rsi    # 0x1ef003
callq 0x9700
cmpq $0x0, %rax
jne 0x44eed
movq 0x138(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x10(%rax), %rax
movq 0xb0(%rsp), %rcx
subq $0x2, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x98(%rsp)
movq 0x138(%rsp), %rdi
movq 0x98(%rsp), %rsi
callq 0xdd280
movq %rax, 0x90(%rsp)
movq 0x138(%rsp), %rdi
movq 0x90(%rsp), %rsi
callq 0xddf90
testb $0x1, %al
jne 0x44eeb
movq $0x0, 0x88(%rsp)
movq 0xe8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xe8(%rsp)
movq 0xe8(%rsp), %rax
cmpq 0x130(%rsp), %rax
jle 0x44ca3
movq 0x138(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x100(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x100(%rsp), %rax
movq (%rax), %rdi
callq 0xa430
movq 0x50(%rsp), %rdi
movq 0x58(%rsp), %rsi
movq %rax, %rdx
callq 0x2d220
movq %rax, 0x140(%rsp)
jmp 0x44f78
movq 0x98(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x1c, %eax
jne 0x44d2a
movq 0x98(%rsp), %rax
movq 0x138(%rsp), %rcx
cmpq 0x150(%rcx), %rax
je 0x44d2a
movq 0x138(%rsp), %rdi
movq 0xb8(%rsp), %rsi
movq 0x98(%rsp), %rdx
movq 0x128(%rsp), %r8
movq 0x120(%rsp), %r9
movq 0x118(%rsp), %r10
movb 0x117(%rsp), %al
xorl %ecx, %ecx
xorl %r11d, %r11d
andb $0x1, %al
movq %r10, (%rsp)
movzbl %al, %eax
movl %eax, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0xdd310
movq %rax, 0x88(%rsp)
movq 0x138(%rsp), %rdi
movq 0x90(%rsp), %rsi
movq 0xb8(%rsp), %rdx
movq 0xa0(%rsp), %rcx
movq 0x88(%rsp), %r8
movq 0x128(%rsp), %r9
movb 0x117(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, (%rsp)
callq 0xddb40
movq %rax, 0x70(%rsp)
movq 0x70(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x80(%rsp)
cmpq $0x0, 0x88(%rsp)
je 0x44dd6
movq 0x88(%rsp), %rax
cmpq 0x80(%rsp), %rax
je 0x44dd6
movq 0x98(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x1c, %eax
jne 0x44dd6
movq 0x98(%rsp), %rax
movq 0x138(%rsp), %rcx
cmpq 0x150(%rcx), %rax
je 0x44dd6
movq 0x88(%rsp), %rdi
callq 0x9050
movq 0x80(%rsp), %rdi
callq 0x91a0
addq $0x1, %rax
movq %rax, 0x48(%rsp)
cmpq $0x0, 0x108(%rsp)
je 0x44e0b
movq 0x108(%rsp), %rdi
callq 0x91a0
movq %rax, 0x40(%rsp)
jmp 0x44e14
xorl %eax, %eax
movq %rax, 0x40(%rsp)
jmp 0x44e14
movq 0x48(%rsp), %rax
movq 0x40(%rsp), %rcx
addq %rcx, %rax
movq %rax, 0x60(%rsp)
movq 0x138(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0xaa80
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x108(%rsp)
je 0x44e6e
movq 0x108(%rsp), %rax
movq %rax, 0x30(%rsp)
jmp 0x44e7c
leaq 0x1af644(%rip), %rax    # 0x1f44b9
movq %rax, 0x30(%rsp)
jmp 0x44e7c
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq 0x80(%rsp), %rdx
xorl %eax, %eax
movl %eax, %ecx
movb $0x0, %al
callq 0x10540
movq 0x138(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0xb230
cmpq $0x0, 0x100(%rsp)
je 0x44ecb
movq 0x138(%rsp), %rdi
movq 0x100(%rsp), %rsi
callq 0xb230
movq 0x68(%rsp), %rax
movq %rax, 0x100(%rsp)
movq 0x100(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x108(%rsp)
jmp 0x44eed
jmp 0x44eef
jmp 0x44ef1
jmp 0x44ef3
movq 0xf8(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0xf8(%rsp)
jmp 0x44a88
cmpq $0x0, 0x100(%rsp)
je 0x44f5d
movq 0x138(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x100(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x100(%rsp), %rax
movq (%rax), %rdi
callq 0xa430
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq %rax, %rdx
callq 0x2d220
movq %rax, 0x140(%rsp)
jmp 0x44f78
movq 0x138(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x146a0
movq %rax, 0x140(%rsp)
movq 0x140(%rsp), %rax
addq $0x148, %rsp            # imm = 0x148
retq
nopl (%rax,%rax)