// File: /workspace/github_c_makefile_star2_O3/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, %r12
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rax
movl %eax, %edx
andl $0x10000ff, %edx        # imm = 0x10000FF
cmpl $0x1, %edx
jne 0xe6f82
movq 0x8(%r12), %r15
cmpl $0x3, %ecx
jl 0xe6ef6
movq 0x10(%r12), %rdx
cmpq 0x110(%rbx), %rdx
je 0xe7177
cmpb $0xb, (%r15)
jne 0xe70df
movq 0x8(%r15), %rsi
testq %rsi, %rsi
js 0xe7061
cmpq 0x2b0(%rbx), %rsi
jg 0xe7061
movq %r14, %rdx
testq %rsi, %rsi
je 0xe6f38
cmpb $0x1, (%rdx)
jne 0xe6fe6
movq 0x10(%rdx), %rdx
decq %rsi
jne 0xe6f22
movb (%rdx), %al
jmp 0xe6f3b
movq %r14, %rdx
cmpb $0x1, %al
jne 0xe6fe6
movq 0x10(%r12), %r13
movq 0x10(%r13), %rax
cmpq 0x110(%rbx), %rax
je 0xe7146
movq 0x8(%rdx), %r14
cmpb $0x1, (%r14)
jne 0xe715c
incl %ecx
movq (%r14), %rax
movl %eax, %edx
andl $0x10000ff, %edx        # imm = 0x10000FF
movq %r13, %r12
cmpl $0x1, %edx
je 0xe6eda
jmp 0xe6f85
movq %r12, %r13
movq 0x1260(%rbx), %r15
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xe6fab
movq %rbx, %rdi
callq 0xa550
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 %r13, 0x10(%rcx)
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movl $0x1, %r8d
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xe7180
movq 0x1260(%rbx), %rax
movq 0x8(%rax), %rsi
cmpq 0x110(%rbx), %rdx
je 0xe7023
movq 0x5f957(%rip), %rdx     # 0x146958
movq 0x140(%rbx), %r8
movq 0x6bc09(%rip), %r9      # 0x152c18
movq %rbx, %rdi
movq %r14, %rcx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xa4e4
movslq %ecx, %rax
leaq 0x5f923(%rip), %rcx     # 0x146950
movq (%rcx,%rax,8), %rax
movq 0x63a08(%rip), %rcx     # 0x14aa40
movq 0x1ee8(%rbx), %rdx
movq 0x10(%rdx), %rdx
movq %rsi, 0x8(%rdx)
movq 0x10(%rdx), %rdx
movq %rax, 0x8(%rdx)
movq 0x10(%rdx), %rax
movq %r15, 0x8(%rax)
movq 0x10(%rax), %rax
movq %rcx, 0x8(%rax)
jmp 0xe70b9
testq %rsi, %rsi
movq 0x1260(%rbx), %rax
movq 0x8(%rax), %rax
movslq %ecx, %rcx
leaq 0x5f8d7(%rip), %rdx     # 0x146950
movq (%rdx,%rcx,8), %rcx
leaq 0x639c4(%rip), %rdx     # 0x14aa48
leaq 0x639b5(%rip), %rsi     # 0x14aa40
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 %r15, 0x8(%rax)
movq 0x10(%rax), %rax
movq %rdx, 0x8(%rax)
movq 0x1948(%rbx), %r15
movq 0x1ee8(%rbx), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x38dfa
movq %r15, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x1260(%rbx), %r13
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xe7105
movq %rbx, %rdi
callq 0xa550
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 %r12, 0x10(%rcx)
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
movl $0xb, %r8d
movl $0x2, %r9d
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xe42d
movq 0x8(%r13), %rax
movq %rax, 0x8(%rdx)
movq 0x10(%r12), %rax
movq 0x8(%rax), %r15
jmp 0xe70d2
leaq 0x31749(%rip), %rsi     # 0x1188ac
movq %rbx, %rdi
movq %r12, %rdx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x3a657
movq %r15, 0x8(%r14)
jmp 0xe70d2