// File: /workspace/github_c_makefile_star2_O2/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 0xb7a5b
movq 0x8(%r15), %r12
cmpl $0x3, %ecx
jl 0xb7951
movq 0x10(%r15), %rdx
cmpq 0x110(%rbx), %rdx
je 0xb7b1d
cmpb $0xb, (%r12)
jne 0xb7aba
movq 0x8(%r12), %rsi
testq %rsi, %rsi
js 0xb7a16
cmpq 0x2b0(%rbx), %rsi
jg 0xb7a16
movq %r14, %rdx
movb (%rdx), %dil
subq $0x1, %rsi
jb 0xb798f
cmpb $0x1, %dil
jne 0xb79c2
movq 0x10(%rdx), %rdx
jmp 0xb797a
cmpb $0x1, %dil
jne 0xb79c2
movq 0x10(%r15), %rsi
movq 0x10(%rsi), %rdi
cmpq 0x110(%rbx), %rdi
je 0xb7b23
movq 0x8(%rdx), %r14
cmpb $0x1, (%r14)
jne 0xb7b40
incl %ecx
movq %rsi, %r15
jmp 0xb7929
movq 0x1260(%rbx), %rax
movq 0x8(%rax), %rsi
cmpq 0x110(%rbx), %rdx
je 0xb79ff
movq 0x5df7b(%rip), %rdx     # 0x115958
movq 0x140(%rbx), %r8
movq 0x6a22d(%rip), %r9      # 0x121c18
movq %rbx, %rdi
movq %r14, %rcx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x9bbb
movslq %ecx, %rax
leaq 0x5df47(%rip), %rcx     # 0x115950
movq (%rcx,%rax,8), %rdx
movq 0x6202c(%rip), %r8      # 0x119a40
jmp 0xb7a47
testq %rsi, %rsi
movq 0x1260(%rbx), %rax
movq 0x8(%rax), %rsi
movslq %ecx, %rax
leaq 0x5df22(%rip), %rcx     # 0x115950
movq (%rcx,%rax,8), %rdx
leaq 0x6200f(%rip), %rax     # 0x119a48
leaq 0x62000(%rip), %rcx     # 0x119a40
cmovsq %rax, %rcx
movq (%rcx), %r8
movq %rbx, %rdi
movq %r12, %rcx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xcb8f
movq 0x1260(%rbx), %r12
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xb7a81
movq %rbx, %rdi
callq 0x9c27
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)
pushq $0x1
popq %r8
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xb7b5b
movq 0x1260(%rbx), %r13
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xb7ae0
movq %rbx, %rdi
callq 0x9c27
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)
pushq $0xb
popq %r8
pushq $0x2
popq %r9
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xcd70
movq %r12, 0x8(%r14)
jmp 0xb7b33
movq 0x8(%rsi), %rax
movq %rax, 0x8(%rdx)
movq 0x10(%r15), %rax
movq 0x8(%rax), %r12
movq %r12, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x2cd05(%rip), %rsi     # 0xe484c
movq %rbx, %rdi
movq %r15, %rdx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x2e40a