// File: /workspace/github_c_makefile_star2_O3/BernardTatin[P]s7sh/s7.c
// Function: g_subvector
static s7_pointer g_subvector(s7_scheme *sc, s7_pointer args)
                {
#define H_subvector "(subvector original-vector new-dimensions (offset 0)) returns \
                    a vector that points to the same elements as the original-vector but with different dimensional info."
#define Q_subvector s7_make_signature(sc, 4, sc->is_subvector_symbol, sc->is_vector_symbol, s7_make_signature(sc, 2, sc->is_pair_symbol, sc->is_integer_symbol), sc->is_integer_symbol)

                    /* (let ((v1 #2d((1 2 3) (4 5 6)))) (let ((v2 (subvector v1 '(6)))) v2)) -> #(1 2 3 4 5 6)
                     * (let ((v1 #(1 2 3 4 5 6))) (let ((v2 (subvector v1 '(3 2)))) v2)) -> #2D((1 2) (3 4) (5 6))
                     */
                    s7_pointer orig, dims, x;
                    vdims_t *v;
                    s7_int new_len, orig_len, offset = 0;

                    orig = car(args);
                    if (!is_any_vector(orig))
                        return(method_or_bust(sc, orig, sc->subvector_symbol, args, T_VECTOR, 1));

                    orig_len = vector_length(orig);

                    if (!is_null(cddr(args)))
                    {
                        s7_pointer off;
                        off = caddr(args);
                        if (!s7_is_integer(off))
                            return(method_or_bust(sc, off, sc->subvector_symbol, args, T_INTEGER, 3));
                        offset = s7_integer(off);
                        if ((offset < 0) ||
                                (offset >= orig_len))  /* we need this if, for example, offset == 9223372036854775807 */
                            return(out_of_range(sc, sc->subvector_symbol, small_int(3), off, (offset < 0) ? its_negative_string : its_too_large_string));
                    }

                    dims = cadr(args);
                    if (is_t_integer(dims))
                    {
                        new_len = s7_integer(dims);
                        if ((new_len > orig_len) || (new_len > sc->max_vector_length)) /* (subvector (make-vector 3) most-positive-fixnum 1) ! */
                            return(out_of_range(sc, sc->subvector_symbol, small_int(2), dims, its_too_large_string));
                        if ((new_len < 0) ||
                                ((new_len + offset) > orig_len))
                            return(out_of_range(sc, sc->subvector_symbol, small_int(2), dims, (new_len < 0) ? its_negative_string : its_too_large_string));
                        v = NULL;
                    }
                    else
                    {
                        s7_pointer y;
                        s7_int i;
                        if ((is_null(dims)) ||
                                (!s7_is_proper_list(sc, dims)))
                            return(method_or_bust(sc, dims, sc->subvector_symbol, args, T_PAIR, 2));

                        for (y = dims; is_pair(y); y = cdr(y))
                            if ((!s7_is_integer(car(y)))        ||       /* (subvector v '((1 2) (3 4))) */
                                    (s7_integer(car(y)) > orig_len) ||
                                    (s7_integer(car(y)) < 0))
                                return(s7_error(sc, sc->wrong_type_arg_symbol,
                                            set_elist_1(sc, wrap_string(sc, "subvector: new dimensions should be a list of integers that fits the original vector", 84))));

                        v = list_to_dims(sc, dims);

                        new_len = vdims_dims(v)[0];
                        for (i = 1; i < vdims_rank(v); i++)
                            new_len *= vdims_dims(v)[i];
                        if ((new_len < 0) ||
                                ((new_len + offset) > vector_length(orig)))
                        {
                            liberate(sc, v);
                            return(out_of_range(sc, sc->subvector_symbol, small_int(2), dims,
                                        wrap_string(sc, "a subvector has to fit in the original vector", 45)));
                        }
                        vdims_original(v) = orig;
                    }

                    if (is_normal_vector(orig))
                        mark_function[T_VECTOR] = mark_vector_possibly_shared;
                    else mark_function[type(orig)] = mark_int_or_float_vector_possibly_shared; /* I think this works for byte-vectors also */

                    new_cell(sc, x, (typeflag(orig) & (~T_COLLECTED)) | T_SUBVECTOR | T_SAFE_PROCEDURE);

                    vector_block(x) = mallocate_vector(sc, 0);
                    vector_set_dimension_info(x, v);
                    if (!v) subvector_set_vector(x, orig);
                    vector_length(x) = new_len;                 /* might be less than original length */
                    if ((new_len == 0) && (is_normal_vector(orig))) set_has_simple_elements(x);
                    vector_getter(x) = vector_getter(orig);
                    vector_setter(x) = vector_setter(orig);

                    if (is_int_vector(orig))
                        int_vector_ints(x) = (s7_int *)(int_vector_ints(orig) + offset);
                    else
                    {
                        if (is_float_vector(orig))
                            float_vector_floats(x) = (s7_double *)(float_vector_floats(orig) + offset);
                        else
                        {
                            if (is_normal_vector(x))
                                vector_elements(x) = (s7_pointer *)(vector_elements(orig) + offset);
                            else byte_vector_bytes(x) = (uint8_t *)(byte_vector_bytes(orig) + offset);
                        }
                    }

                    add_multivector(sc, x);
                    return(x);
                }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r12
movq %rdi, %rbx
movq 0x8(%rsi), %r14
movzbl (%r14), %eax
leaq 0xd0992(%rip), %rcx     # 0x14ac20
cmpb $0x0, (%rax,%rcx)
je 0x7a327
movq 0x8(%r14), %r13
movq 0x10(%r12), %rdx
movq 0x10(%rdx), %rsi
movq 0x110(%rbx), %rcx
cmpq %rcx, %rsi
je 0x7a348
movq 0x8(%rsi), %rsi
cmpb $0xb, (%rsi)
jne 0x7a3dd
movq 0x8(%rsi), %r9
testq %r9, %r9
setns %dil
cmpq %r13, %r9
setl %r8b
testb %r8b, %dil
jne 0x7a34b
testq %r9, %r9
movq 0x1590(%rbx), %rax
movq 0x8(%rax), %rax
movq 0xcc67a(%rip), %rcx     # 0x146968
leaq 0xd0753(%rip), %rdx     # 0x14aa48
leaq 0xd0744(%rip), %rdi     # 0x14aa40
cmovsq %rdx, %rdi
movq (%rdi), %rdx
movq 0x1ee8(%rbx), %rdi
movq 0x10(%rdi), %rdi
movq %rax, 0x8(%rdi)
movq 0x10(%rdi), %rax
movq %rcx, 0x8(%rax)
movq 0x10(%rax), %rax
movq %rsi, 0x8(%rax)
jmp 0x7a3aa
movq 0x1590(%rbx), %rdx
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rcx
movl $0x15, %r8d
movl $0x1, %r9d
jmp 0x7a4a6
xorl %r9d, %r9d
movq 0x8(%rdx), %r15
movb (%r15), %bpl
cmpb $0xb, %bpl
jne 0x7a3fb
movq 0x8(%r15), %rbp
cmpq %r13, %rbp
jg 0x7a372
cmpq 0x2a0(%rbx), %rbp
jle 0x7a4b9
movq 0x1590(%rbx), %rax
movq 0x8(%rax), %rax
movq 0xcc5dc(%rip), %rcx     # 0x146960
movq 0xd06b5(%rip), %rdx     # 0x14aa40
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
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1590(%rbx), %rdx
movq %rbx, %rdi
movq %r12, %rcx
movl $0xb, %r8d
movl $0x3, %r9d
jmp 0x7a4a6
cmpq %rcx, %r15
je 0x7a48a
movq %rbx, %rdi
movq %r15, %rsi
movq %r9, (%rsp)
callq 0x39d6f
testb %al, %al
je 0x7a48a
cmpb $0x1, %bpl
jne 0x7a44c
movq %r15, %rax
movq 0x8(%rax), %rcx
cmpb $0xb, (%rcx)
jne 0x7a4fe
movq 0x8(%rcx), %rcx
cmpq %r13, %rcx
jg 0x7a4fe
testq %rcx, %rcx
js 0x7a4fe
movq 0x10(%rax), %rax
cmpb $0x1, (%rax)
je 0x7a420
movq %rbx, %rdi
movq %r15, %rsi
callq 0x99fb8
movq %rax, %r12
movq (%rax), %rax
movq 0x10(%r12), %rcx
movq (%rax), %rbp
cmpq $0x2, %rcx
jl 0x7a54c
movl $0x1, %edx
movq (%rsp), %r9
imulq (%rax,%rdx,8), %rbp
incq %rdx
cmpq %rdx, %rcx
jne 0x7a478
jmp 0x7a550
movq 0x1590(%rbx), %rdx
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rcx
movl $0x1, %r8d
movl $0x2, %r9d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe42d
testq %rbp, %rbp
js 0x7a4cf
leaq (%r9,%rbp), %rcx
cmpq %r13, %rcx
jg 0x7a4cf
xorl %r12d, %r12d
jmp 0x7a5ce
testq %rbp, %rbp
movq 0x1590(%rbx), %rax
movq 0x8(%rax), %rax
movq 0xcc47c(%rip), %rcx     # 0x146960
leaq 0xd055d(%rip), %rdx     # 0x14aa48
leaq 0xd054e(%rip), %rsi     # 0x14aa40
cmovsq %rdx, %rsi
movq (%rsi), %rdx
jmp 0x7a38b
movq 0x1940(%rbx), %r15
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rbx)
leaq 0xa153b(%rip), %rcx     # 0x11ba64
movq %rcx, 0x10(%rax)
movq $0x54, 0x8(%rax)
movq 0x6d8(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x6d8(%rbx), %rdx
jmp 0x7a3c0
movq (%rsp), %r9
testq %rbp, %rbp
js 0x7a55f
leaq (%r9,%rbp), %rax
cmpq 0x8(%r14), %rax
jle 0x7a5c6
movq %rbx, %rdi
movq %r12, %rsi
callq 0x9a12
movq 0x1590(%rbx), %rax
movq 0x8(%rax), %rsi
movq 0xcc3e4(%rip), %rdx     # 0x146960
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %r8
leal 0x1(%rcx), %eax
andl $0x7, %eax
movl %eax, 0x7dc(%rbx)
leaq 0xa1518(%rip), %rax     # 0x11bab9
movq %rax, 0x10(%r8)
movq $0x2d, 0x8(%r8)
movq %rbx, %rdi
movq %r15, %rcx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe1fe
movq %r14, 0x20(%r12)
movb (%r14), %al
cmpb $0x15, %al
jne 0x7a5e2
leaq 0x5c0ce(%rip), %rax     # 0xd66a7
movq %rax, 0xcc238(%rip)     # 0x146818
jmp 0x7a5f7
movzbl %al, %eax
leaq 0xcc184(%rip), %rcx     # 0x146770
leaq 0x5c0f7(%rip), %rdx     # 0xd66ea
movq %rdx, (%rcx,%rax,8)
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x7a61c
movq %rbx, %rdi
movq %r9, %r15
callq 0xa550
movq %r15, %r9
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r15
movq $-0x20220001, %rax      # imm = 0xDFDDFFFF
andq (%r14), %rax
orq $0x20200000, %rax       # imm = 0x20200000
movq %rax, (%r15)
movq 0x838(%rbx), %rax
testq %rax, %rax
jne 0x7a68f
movq %r9, %r13
movl $0x2800, %edi           # imm = 0x2800
callq 0x8480
movq %rax, 0x838(%rbx)
movq %rax, %rcx
addq $0x28, %rcx
movl $0xff, %edx
movq %rcx, -0x10(%rcx)
movl $0x0, -0x20(%rcx)
addq $0x28, %rcx
decl %edx
jne 0x7a66a
movq $0x0, -0x10(%rcx)
movl $0x0, -0x20(%rcx)
movq %r13, %r9
movq 0x18(%rax), %rcx
movq %rcx, 0x838(%rbx)
movl $0x0, 0x8(%rax)
movq $0x0, (%rax)
movq %rax, 0x18(%r15)
movq %r12, 0x20(%rax)
testq %r12, %r12
jne 0x7a6bd
movq 0x18(%r15), %rax
movq %r14, 0x18(%rax)
movq %rbp, 0x8(%r15)
testq %rbp, %rbp
jne 0x7a6d1
cmpb $0x15, (%r14)
jne 0x7a6d1
orb $0x1, 0x7(%r15)
movq 0x20(%r14), %rax
movq %rax, 0x20(%r15)
movq 0x28(%r14), %rax
movq %rax, 0x28(%r15)
movzbl (%r14), %eax
cmpl $0x17, %eax
je 0x7a6ef
cmpl $0x16, %eax
jne 0x7a6fd
shlq $0x3, %r9
addq 0x10(%r14), %r9
movq %r9, 0x10(%r15)
jmp 0x7a714
cmpb $0x15, (%r15)
movq 0x10(%r14), %rax
jne 0x7a70d
leaq (%rax,%r9,8), %rax
jmp 0x7a710
addq %r9, %rax
movq %rax, 0x10(%r15)
movq 0x790(%rbx), %rbx
movq (%rbx), %rax
movq 0x10(%rbx), %rsi
cmpq 0x8(%rbx), %rsi
jne 0x7a743
leaq (%rsi,%rsi), %rcx
movq %rcx, 0x8(%rbx)
shlq $0x4, %rsi
movq %rax, %rdi
callq 0x8510
movq %rax, (%rbx)
movq 0x10(%rbx), %rsi
leaq 0x1(%rsi), %rcx
movq %rcx, 0x10(%rbx)
movq %r15, (%rax,%rsi,8)
jmp 0x7a3cb