// File: /workspace/github_c_makefile_star2_O2/BernardTatin[P]s7sh/s7.c
// Function: univect_ref
static s7_pointer univect_ref(s7_scheme *sc, s7_pointer args, s7_pointer caller, int32_t typ)
                {
                    s7_pointer v, index;
                    s7_int ind;

                    v = car(args);
                    if (type(v) != typ)
                        return(method_or_bust(sc, v, caller, args, typ, 1));

                    if (vector_rank(v) == 1)
                    {
                        index = cadr(args);
                        if (!s7_is_integer(index))
                            return(method_or_bust(sc, index, caller, args, T_INTEGER, 2));
                        ind = s7_integer(index);
                        if ((ind < 0) || (ind >= vector_length(v)))
                            return(simple_out_of_range(sc, caller, index, (ind < 0) ? its_negative_string : its_too_large_string));
                        if (!is_null(cddr(args)))
                            return(out_of_range(sc, caller, small_int(2), cdr(args), too_many_indices_string));
                    }
                    else
                    {
                        s7_int i;
                        s7_pointer x;
                        ind = 0;
                        for (x = cdr(args), i = 0; (is_not_null(x)) && (i < vector_ndims(v)); x = cdr(x), i++)
                        {
                            s7_int n;
                            index = car(x);
                            if (!s7_is_integer(index))
                                return(method_or_bust(sc, index, caller, args, T_INTEGER, i + 2));
                            n = s7_integer(index);
                            if ((n < 0) ||
                                    (n >= vector_dimension(v, i)))
                                return(out_of_range(sc, caller, wrap_integer1(sc, i + 2), index, (n < 0) ? its_negative_string : its_too_large_string));
                            ind += n * vector_offset(v, i);
                        }
                        if (is_not_null(x))
                            return(out_of_range(sc, caller, small_int(2), cdr(args), too_many_indices_string));

                        /* if not enough indices, return a subvector covering whatever is left */
                        if (i < vector_ndims(v))
                            return(subvector(sc, v, i, ind));
                    }
                    if (typ == T_FLOAT_VECTOR)
                        return(make_real(sc, float_vector(v, ind)));
                    if (typ == T_INT_VECTOR)
                        return(make_integer(sc, int_vector(v, ind)));
                    return(small_int(byte_vector(v, ind)));
                }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rax
movq %rdi, %rbx
movq 0x8(%rsi), %rsi
movzbl (%rsi), %edi
cmpl %ecx, %edi
jne 0xa949e
movq 0x18(%rsi), %rdi
movq 0x20(%rdi), %rdi
testq %rdi, %rdi
je 0xa9451
movq 0x10(%rdi), %r11
cmpq $0x1, %r11
jne 0xa94cf
movq 0x10(%rax), %r10
movq 0x8(%r10), %r11
cmpb $0xb, (%r11)
jne 0xa94ab
movq 0x8(%r11), %r8
testq %r8, %r8
js 0xa9536
cmpq 0x8(%rsi), %r8
jge 0xa9536
movq 0x10(%r10), %rax
cmpq 0x110(%rbx), %rax
je 0xa95c5
movq 0x8(%rdx), %rsi
movq 0x6c4ce(%rip), %rdx     # 0x115960
movq 0x7af57(%rip), %r8      # 0x1243f0
jmp 0xa9599
movzbl %cl, %r8d
pushq $0x1
popq %r9
movq %rbx, %rdi
jmp 0xa94b9
pushq $0xb
popq %r8
pushq $0x2
popq %r9
movq %rbx, %rdi
movq %r11, %rsi
movq %rax, %rcx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xcd70
leaq 0x10(%rax), %r14
movq 0x110(%rbx), %r15
pushq $0x2
popq %r9
xorl %r8d, %r8d
movq %r14, %r12
leaq -0x2(%r9), %r10
movq (%r12), %r12
cmpq %r15, %r12
je 0xa95a4
cmpq %r11, %r10
jge 0xa962a
movq 0x8(%r12), %r10
cmpb $0xb, (%r10)
jne 0xa9655
movq 0x8(%r10), %r13
testq %r13, %r13
js 0xa956b
movq (%rdi), %rbp
cmpq -0x10(%rbp,%r9,8), %r13
jge 0xa956b
movq 0x18(%rdi), %r10
imulq -0x10(%r10,%r9,8), %r13
addq %r13, %r8
addq $0x10, %r12
incq %r9
jmp 0xa94e4
testq %r8, %r8
movq 0x8(%rdx), %rsi
leaq 0x70504(%rip), %rax     # 0x119a48
leaq 0x704f5(%rip), %rcx     # 0x119a40
cmovsq %rax, %rcx
movq (%rcx), %rcx
movq %rbx, %rdi
movq %r11, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x35b47
testq %r13, %r13
movq 0x8(%rdx), %rsi
movq 0x1f00(%rbx), %rax
movq %r9, 0x8(%rax)
movq 0x1f00(%rbx), %rdx
leaq 0x704bd(%rip), %rax     # 0x119a48
leaq 0x704ae(%rip), %rcx     # 0x119a40
cmovsq %rax, %rcx
movq (%rcx), %r8
movq %rbx, %rdi
movq %r10, %rcx
jmp 0xa9642
cmpq %r11, %r10
jge 0xa95c5
movq %rbx, %rdi
movq %r10, %rdx
movq %r8, %rcx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa9292
movq 0x10(%rsi), %rax
cmpl $0x16, %ecx
je 0xa9667
cmpl $0x17, %ecx
jne 0xa9681
movsd (%rax,%r8,8), %xmm0
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xa960a
movq %rbx, %rdi
movsd %xmm0, (%rsp)
callq 0x9c27
movsd (%rsp), %xmm0
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movq $0xd, (%rax)
movsd %xmm0, 0x8(%rax)
jmp 0xa96cc
movq 0x8(%rdx), %rsi
movq 0x6c32b(%rip), %rdx     # 0x115960
movq (%r14), %rcx
movq 0x7adb1(%rip), %r8      # 0x1243f0
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xcb8f
pushq $0xb
popq %r8
movq %rbx, %rdi
movq %r10, %rsi
movq %rax, %rcx
jmp 0xa94bc
movq (%rax,%r8,8), %r14
cmpq $0x7ff, %r14            # imm = 0x7FF
ja 0xa9693
leaq 0x6c2d5(%rip), %rax     # 0x115950
movq (%rax,%r14,8), %rax
jmp 0xa96cc
movzbl (%rax,%r8), %eax
leaq 0x6c2c3(%rip), %rcx     # 0x115950
movq (%rcx,%rax,8), %rax
jmp 0xa96cc
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xa96b2
movq %rbx, %rdi
callq 0x9c27
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movq $0xb, (%rax)
movq %r14, 0x8(%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq