// File: /workspace/github_c_makefile_star2_O1/BernardTatin[P]s7sh/s7.c
// Function: g_list_set_1
static s7_pointer g_list_set_1(s7_scheme *sc, s7_pointer lst, s7_pointer args, int32_t arg_num)
                {
#define H_list_set "(list-set! lst i ... val) sets the i-th element (0-based) of the list to val"
#define Q_list_set s7_make_circular_signature(sc, 3, 4, sc->T, sc->is_pair_symbol, sc->is_integer_symbol, sc->is_integer_or_any_at_end_symbol)

                    int32_t i;
                    s7_int index;
                    s7_pointer p, ind;
                    /* (let ((L '((1 2 3) (4 5 6)))) (list-set! L 1 2 32) L) */

                    if (!is_mutable_pair(lst))
                        return(mutable_method_or_bust(sc, lst, sc->list_set_symbol, cons(sc, lst, args), T_PAIR, 1));

                    ind = car(args);
                    if ((arg_num > 2) && (is_null(cdr(args))))
                    {
                        set_car(lst, ind);
                        return(ind);
                    }
                    if (!s7_is_integer(ind))
                        return(method_or_bust(sc, ind, sc->list_set_symbol, cons(sc, lst, args), T_INTEGER, 2));
                    index = s7_integer(ind);
                    if ((index < 0) || (index > sc->max_list_length))
                        return(out_of_range(sc, sc->list_set_symbol, small_int(arg_num), ind, (index < 0) ? its_negative_string : its_too_large_string));

                    for (i = 0, p = lst; (i < index) && is_pair(p); i++, p = cdr(p)) {}

                    if (!is_pair(p))
                    {
                        if (is_null(p))
                            return(out_of_range(sc, sc->list_set_symbol, small_int(arg_num), ind, its_too_large_string));
                        return(wrong_type_argument_with_type(sc, sc->list_set_symbol, 1, lst, a_proper_list_string));
                    }
                    if (is_null(cddr(args)))
                        set_car(p, cadr(args));
                    else
                    {
                        if (!s7_is_pair(car(p)))
                            return(s7_wrong_number_of_args_error(sc, "too many args for list-set!: ~S", args));
                        return(g_list_set_1(sc, car(p), cdr(args), arg_num + 1));
                    }
                    return(cadr(args));
                }

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movl $0x10000ff, %eax        # imm = 0x10000FF
movl (%r14), %edx
andl %eax, %edx
cmpl $0x1, %edx
jne 0xefdbf
movq 0x8(%r15), %r12
cmpl $0x3, %ecx
jl 0xefcdf
movq 0x10(%r15), %rdx
cmpq 0x110(%rbx), %rdx
je 0xefef1
cmpb $0xb, (%r12)
jne 0xefe20
movq 0x8(%r12), %rsi
testq %rsi, %rsi
js 0xefd49
cmpq 0x2b0(%rbx), %rsi
jg 0xefd49
movq %r14, %rdx
testq %rsi, %rsi
je 0xefd13
cmpb $0x1, (%rdx)
jne 0xefd13
movq 0x10(%rdx), %rdx
decq %rsi
jne 0xefd05
cmpb $0x1, (%rdx)
jne 0xefe87
movq 0x10(%r15), %rsi
movq 0x10(%rsi), %rdi
cmpq 0x110(%rbx), %rdi
je 0xefec4
movq 0x8(%rdx), %r14
cmpb $0x1, (%r14)
jne 0xefed6
incl %ecx
movq %rsi, %r15
jmp 0xefcb7
testq %rsi, %rsi
movq 0x1260(%rbx), %rax
movq 0x8(%rax), %rax
movslq %ecx, %rcx
leaq 0x5ebef(%rip), %rdx     # 0x14e950
movq (%rdx,%rcx,8), %rcx
leaq 0x62cdc(%rip), %rdx     # 0x152a48
leaq 0x62ccd(%rip), %rsi     # 0x152a40
cmovsq %rdx, %rsi
movq (%rsi), %rdx
movq 0x1ee8(%rbx), %rsi
movq 0x10(%rsi), %rsi
movq %rax, 0x8(%rsi)
movq 0x10(%rsi), %rax
movq %rcx, 0x8(%rax)
movq 0x10(%rax), %rax
movq %r12, 0x8(%rax)
movq 0x10(%rax), %rax
movq %rdx, 0x8(%rax)
movq 0x1948(%rbx), %r12
movq 0x1ee8(%rbx), %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3b366
jmp 0xefef5
movq 0x1260(%rbx), %r12
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xefdde
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rcx
movq $0x200001, (%rcx)       # imm = 0x200001
movq %r14, 0x8(%rcx)
movq %r15, 0x10(%rcx)
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
movl $0x1, %r8d
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xeff2b
movq 0x1260(%rbx), %r13
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xefe3f
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rcx
movq $0x200001, (%rcx)       # imm = 0x200001
movq %r14, 0x8(%rcx)
movq %r15, 0x10(%rcx)
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
movl $0xb, %r8d
movl $0x2, %r9d
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xf1ae
movq 0x1260(%rbx), %rax
movq 0x8(%rax), %rsi
cmpq 0x110(%rbx), %rdx
je 0xeff02
movq 0x5eab6(%rip), %rdx     # 0x14e958
movq 0x140(%rbx), %r8
movq 0x6ad68(%rip), %r9      # 0x15ac18
movq %rbx, %rdi
movq %r14, %rcx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xb31d
movq 0x8(%rsi), %rax
movq %rax, 0x8(%rdx)
movq 0x10(%r15), %rax
movq 0x8(%rax), %r12
jmp 0xefef5
leaq 0x318bf(%rip), %rsi     # 0x12179c
movq %rbx, %rdi
movq %r15, %rdx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x3cbe3
movq %r12, 0x8(%r14)
movq %r12, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movslq %ecx, %rax
leaq 0x5ea44(%rip), %rcx     # 0x14e950
movq (%rcx,%rax,8), %rdx
movq 0x62b29(%rip), %r8      # 0x152a40
movq %rbx, %rdi
movq %r12, %rcx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xef7f