// File: /workspace/github_c_makefile_star2_O2/BernardTatin[P]s7sh/s7.c
// Function: g_multivector
static s7_pointer g_multivector(s7_scheme *sc, s7_int dims, s7_pointer data)
                {
                    /* get the dimension bounds from data, make the new vector, fill it from data
                     * dims needs to be s7_int so we can at least give correct error messages.
                     */
                    s7_pointer vec, x;
                    s7_int i, err, vec_loc;
                    s7_int *sizes;

                    /* (#2d((1 2 3) (4 5 6)) 0 0) -> 1
                     * (#2d((1 2 3) (4 5 6)) 1 1) -> 5
                     * (#3d(((1 2) (3 4)) ((5 6) (7 8))) 1 1 0) -> 7
                     * #3d(((1 2) (3 4)) ((5 6) (7))) -> error, #3d(((1 2) (3 4)) ((5 6) (7 8 9))), #3d(((1 2) (3 4)) (5 (7 8 9))) etc
                     * but a special case: #nd() is an n-dimensional empty vector
                     */

                    if (dims <= 0)      /* #0d(...) #2147483649D() [if dims is int32_t this is negative] */
                        return(s7_out_of_range_error(sc, "#nD(...) dimensions", 1, wrap_integer1(sc, dims), "must be 1 or more"));
                    if (dims > sc->max_vector_dimensions)
                        return(s7_out_of_range_error(sc, "#nD(...) dimensions", 1, wrap_integer1(sc, dims), "must be < 512")); /* sc->max_vector_dimensions=512 currently */

                    sc->w = sc->nil;
                    if (is_null(data))  /* dims are already 0 (calloc above) */
                        return(g_make_vector(sc, set_plist_1(sc, protected_make_list(sc, dims, small_int(0)))));

                    sizes = (s7_int *)calloc(dims, sizeof(s7_int));
                    for (x = data, i = 0; i < dims; i++)
                    {
                        sizes[i] = safe_list_length(x);
                        sc->w = cons(sc, make_integer(sc, sizes[i]), sc->w);
                        x = car(x);
                        if ((i < (dims - 1)) &&
                                (!is_pair(x)))
                        {
                            free(sizes);
                            return(s7_multivector_error(sc, "we need a list that fully specifies the vector's elements", data));
                        }
                    }

                    vec = g_make_vector(sc, set_plist_1(sc, sc->w = safe_reverse_in_place(sc, sc->w)));
                    vec_loc = s7_gc_protect_1(sc, vec);
                    sc->w = sc->nil;

                    /* now fill the vector checking that all the lists match */
                    err = traverse_vector_data(sc, vec, 0, 0, dims, sizes, data);

                    free(sizes);
                    s7_gc_unprotect_at(sc, vec_loc);
                    if (err < 0)
                        return(s7_multivector_error(sc, (err == MULTIVECTOR_TOO_MANY_ELEMENTS) ? "found too many elements" : "not enough elements found", data));

                    return(vec);
                }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r15
movq %rdi, %rbx
testq %rsi, %rsi
jle 0xb95b4
cmpq %r15, 0x2b8(%rbx)
jge 0xb95ed
movq 0x1f00(%rbx), %rax
movq %r15, 0x8(%rax)
movq 0x1f00(%rbx), %rcx
leaq 0x2c194(%rip), %rsi     # 0xe573f
leaq 0x2c1b3(%rip), %r8      # 0xe5765
jmp 0xb95d4
movq 0x1f00(%rbx), %rax
movq %r15, 0x8(%rax)
movq 0x1f00(%rbx), %rcx
leaq 0x2c172(%rip), %rsi     # 0xe573f
leaq 0x2c17f(%rip), %r8      # 0xe5753
pushq $0x1
popq %rdx
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x35a50
movq %rdx, %r13
movq 0x110(%rbx), %rbp
movq %rbp, 0x4d8(%rbx)
cmpq %rdx, %rbp
je 0xb97a4
pushq $0x8
popq %rsi
movq %r15, %rdi
callq 0x8360
movq %rax, 0x8(%rsp)
leaq -0x1(%r15), %rax
movq %rax, 0x20(%rsp)
xorl %r12d, %r12d
movq %r13, 0x10(%rsp)
movq %r15, 0x18(%rsp)
cmpq %r12, %r15
je 0xb970b
movq %r13, %rdi
callq 0x313be
movq %rax, %r14
movq 0x8(%rsp), %rax
movq %r14, (%rax,%r12,8)
cmpq $0x7ff, %r14            # imm = 0x7FF
ja 0xb9663
leaq 0x5c2f6(%rip), %rax     # 0x115950
movq (%rax,%r14,8), %r15
movq %rbp, %r14
jmp 0xb96a3
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xb9682
movq %rbx, %rdi
callq 0x9c27
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r15
movq $0xb, (%r15)
movq %r14, 0x8(%r15)
movq 0x4d8(%rbx), %r14
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xb96c2
movq %rbx, %rdi
callq 0x9c27
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rbp
movq $0x200001, (%rbp)       # imm = 0x200001
movq %r15, 0x8(%rbp)
movq %r14, 0x10(%rbp)
movq %rbp, 0x4d8(%rbx)
movq 0x8(%r13), %r13
cmpq 0x20(%rsp), %r12
jge 0xb96fe
cmpb $0x1, (%r13)
jne 0xb97de
incq %r12
movq 0x18(%rsp), %r15
jmp 0xb962d
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xa833
movq %rax, 0x4d8(%rbx)
movq 0x700(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x700(%rbx), %rsi
movq %rbx, %rdi
callq 0x2f65f
movq %rax, %r13
movq %rbx, %rdi
movq %rax, %rsi
callq 0x89a9
movq %rax, %r14
movq 0x110(%rbx), %rax
movq %rax, 0x4d8(%rbx)
movq %r15, %r8
movq 0x10(%rsp), %r15
movq %r15, (%rsp)
movq %rbx, %rdi
movq %r13, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq 0x8(%rsp), %r12
movq %r12, %r9
callq 0xb98d9
movl %eax, %ebp
movq %r12, %rdi
callq 0x8050
movq %rbx, %rdi
movq %r14, %rsi
callq 0x8b00
testl %ebp, %ebp
js 0xb97f9
movq %r13, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x5c1a5(%rip), %rdx     # 0x115950
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7d146
movq 0x700(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x700(%rbx), %rsi
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2f65f
movq 0x8(%rsp), %rdi
callq 0x8050
leaq 0x2bf84(%rip), %rsi     # 0xe5773
movq %rbx, %rdi
movq 0x10(%rsp), %rdx
jmp 0xb9814
cmpl $-0x1, %ebp
leaq 0x2bfaa(%rip), %rax     # 0xe57ad
leaq 0x2bfbb(%rip), %rsi     # 0xe57c5
cmoveq %rax, %rsi
movq %rbx, %rdi
movq %r15, %rdx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xb9854