// File: /workspace/github_c_makefile_star2_O3/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, %rcx
movq %rdi, %rbx
testq %rsi, %rsi
jle 0xe8ff1
cmpq %rcx, 0x2b8(%rbx)
jge 0xe902c
movq 0x1f00(%rbx), %rax
movq %rcx, 0x8(%rax)
movq 0x1f00(%rbx), %rcx
leaq 0x307b7(%rip), %rsi     # 0x11979f
leaq 0x307d6(%rip), %r8      # 0x1197c5
jmp 0xe9011
movq 0x1f00(%rbx), %rax
movq %rcx, 0x8(%rax)
movq 0x1f00(%rbx), %rcx
leaq 0x30795(%rip), %rsi     # 0x11979f
leaq 0x307a2(%rip), %r8      # 0x1197b3
movl $0x1, %edx
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x437a3
movq %rdx, %r12
movq 0x110(%rbx), %r13
movq %r13, 0x4d8(%rbx)
cmpq %rdx, %r13
je 0xe91ce
movl $0x8, %esi
movq %rcx, %rdi
movq %rcx, 0x8(%rsp)
callq 0x8360
movq 0x8(%rsp), %rdx
movq %rax, 0x10(%rsp)
leaq -0x1(%rdx), %rax
movq %rax, 0x20(%rsp)
xorl %r14d, %r14d
movq %r12, 0x18(%rsp)
cmpb $0x1, (%r12)
jne 0xe90ec
movq $-0x1, %rax
movq %r12, %rcx
movq 0x10(%rcx), %rcx
incq %rax
cmpb $0x1, (%rcx)
je 0xe9084
leaq 0x1(%rax), %rbp
movq 0x10(%rsp), %rcx
movq %rbp, (%rcx,%r14,8)
cmpq $0x7fe, %rax            # imm = 0x7FE
jbe 0xe90fb
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xe90c9
movq %rbx, %rdi
callq 0xa550
movq 0x8(%rsp), %rdx
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r15
movq $0xb, (%r15)
movq %rbp, 0x8(%r15)
movq 0x4d8(%rbx), %rbp
jmp 0xe9109
movq 0x10(%rsp), %rax
movq $0x0, (%rax,%r14,8)
xorl %ebp, %ebp
leaq 0x5d84e(%rip), %rax     # 0x146950
movq (%rax,%rbp,8), %r15
movq %r13, %rbp
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xe912d
movq %rbx, %rdi
callq 0xa550
movq 0x8(%rsp), %rdx
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r13
movq $0x200001, (%r13)       # imm = 0x200001
movq %r15, 0x8(%r13)
movq %rbp, 0x10(%r13)
movq %r13, 0x4d8(%rbx)
movq 0x8(%r12), %r12
cmpq 0x20(%rsp), %r14
jge 0xe916a
cmpb $0x1, (%r12)
jne 0xe9215
incq %r14
cmpq %rdx, %r14
jne 0xe9073
movq 0x110(%rbx), %rsi
movq %rbx, %rdi
movq %r13, %rdx
callq 0x9975a
movq %rax, 0x4d8(%rbx)
movq 0x700(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x700(%rbx), %rsi
movq 0x1318(%rbx), %rdx
movq %rbx, %rdi
callq 0x3c722
movq %rax, %r13
cmpq $0x0, 0x108(%rbx)
js 0xe9233
movq 0xe8(%rbx), %rax
movq 0x18(%rsp), %r15
jmp 0xe92ed
movq 0x5d77b(%rip), %rdx     # 0x146950
movq %rbx, %rdi
movl %ecx, %esi
callq 0x3a029
movq %rax, 0x520(%rbx)
movq 0x700(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x700(%rbx), %rsi
movq 0x1318(%rbx), %rdx
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3c722
movq 0x10(%rsp), %rdi
callq 0x8050
leaq 0x305ad(%rip), %rsi     # 0x1197d3
movq %rbx, %rdi
movq 0x18(%rsp), %rdx
jmp 0xe93c2
movq 0xd0(%rbx), %rax
movq 0xf0(%rbx), %r14
leaq (%r14,%r14), %r15
movq 0x18(%rax), %rsi
movq %r14, %rbp
shlq $0x4, %rbp
movq %rbx, %rdi
movq %rbp, %rdx
callq 0x9fd6
movq $0x0, 0x20(%rax)
movq 0xd0(%rbx), %rcx
movq %rax, 0x18(%rcx)
movq (%rax), %rax
movq 0xd0(%rbx), %rcx
movq %rax, 0x10(%rcx)
movq 0xd0(%rbx), %rax
movq %r15, 0x8(%rax)
movq %r15, 0xf0(%rbx)
movq 0xe8(%rbx), %rdi
movq %rbp, %rsi
callq 0x8510
movq %rax, 0xe8(%rbx)
cmpq %r15, %r14
movq 0x18(%rsp), %r15
jge 0xe92ed
movq 0x140(%rbx), %rcx
movq %r14, %rdx
movq 0xd0(%rbx), %rax
movq 0x10(%rax), %rax
movq %rcx, (%rax,%rdx,8)
movq 0xe8(%rbx), %rax
movq 0x108(%rbx), %rsi
leaq 0x1(%rsi), %rdi
movq %rdi, 0x108(%rbx)
movq %rdx, 0x8(%rax,%rsi,8)
incq %rdx
decq %r14
jne 0xe92b8
movq 0xd0(%rbx), %rcx
movq 0x108(%rbx), %rdx
leaq -0x1(%rdx), %rsi
movq %rsi, 0x108(%rbx)
movq (%rax,%rdx,8), %r14
movq 0x10(%rcx), %rax
movq %r13, (%rax,%r14,8)
movq 0x110(%rbx), %rax
movq %rax, 0x4d8(%rbx)
movq %r15, (%rsp)
movq %rbx, %rdi
movq %r13, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq 0x8(%rsp), %r8
movq 0x10(%rsp), %r12
movq %r12, %r9
callq 0xe947f
movl %eax, %ebp
movq %r12, %rdi
callq 0x8050
cmpq %r14, 0xf0(%rbx)
jle 0xe9391
movq 0xd0(%rbx), %rcx
movq 0x140(%rbx), %rax
movq 0x10(%rcx), %rdx
cmpq %rax, (%rdx,%r14,8)
je 0xe938d
movq 0xe8(%rbx), %rdx
movq 0x108(%rbx), %rsi
leaq 0x1(%rsi), %rdi
movq %rdi, 0x108(%rbx)
movq %r14, 0x8(%rdx,%rsi,8)
movq 0x10(%rcx), %rdx
movq %rax, (%rdx,%r14,8)
testl %ebp, %ebp
js 0xe93a7
movq %r13, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $-0x1, %ebp
leaq 0x3045c(%rip), %rax     # 0x11980d
leaq 0x3046d(%rip), %rsi     # 0x119825
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 0xe93d2