// File: /workspace/github_c_makefile_star2_O3/BernardTatin[P]s7sh/s7.c
// Function: g_reverse_in_place
static s7_pointer g_reverse_in_place(s7_scheme *sc, s7_pointer args)
                {
                    s7_pointer p;
#define H_reverse_in_place "(reverse! lst) reverses lst in place"
#define Q_reverse_in_place Q_reverse

                    p = car(args);
                    switch (type(p))
                    {
                        case T_NIL:
                            return(sc->nil);

                        case T_PAIR:
                            {
                                s7_pointer np;
                                if (is_immutable_pair(p))
                                    return(immutable_object_error(sc, set_elist_3(sc, immutable_error_string, sc->reverseb_symbol, p)));
                                np = reverse_in_place(sc, sc->nil, p);
                                if (is_null(np))
                                    return(s7_wrong_type_arg_error(sc, "reverse!", 1, car(args), "a mutable, proper list"));
                                return(np);
                            }
                            /* (reverse! p) is supposed to change p directly and lisp programmers expect reverse! to be fast
                             * so in a sense this is different from the other cases: it assumes (set! p (reverse! p))
                             * To make (reverse! p) direct:
                             *    for (l = p, r = cdr(p); is_pair(r); l = r, r = cdr(r)) opt1(r) = l;
                             *    if (!is_null(r)) return(simple_wrong_type_argument_with_type(sc, sc->reverseb_symbol, p, a_proper_list_string));
                             *    for (r = l, l = p; l != r; l = cdr(l)) {t = car(l); set_car(l, car(r)); set_car(r, t); if (cdr(l) != r) r = opt1(r);}
                             * immutable check is needed else (reverse! (catch #t 1 cons)) clobbers sc->wrong_type_arg_info
                             */

                        case T_BYTE_VECTOR:
                        case T_STRING:
                            {
                                s7_int len;
                                uint8_t *bytes;
                                if (is_immutable(p))
                                    return(immutable_object_error(sc, set_elist_3(sc, immutable_error_string, sc->reverseb_symbol, p)));

                                if (is_string(p))
                                {
                                    len = string_length(p);
                                    bytes = (uint8_t *)string_value(p);
                                }
                                else
                                {
                                    len = byte_vector_length(p);
                                    bytes = byte_vector_bytes(p);
                                }
                                if (len < 2) return(p);

#if __linux__ /* need byteswp.h */
                                /* this code (from StackOverflow) is much faster: */
                                if ((len & 0x1f) == 0)
                                {
#include <byteswap.h>
                                    uint32_t *dst = (uint32_t *)(bytes + len - 4);
                                    uint32_t *src = (uint32_t *)bytes;
                                    while (src < dst)
                                    {
                                        uint32_t a, b;
                                        LOOP_4(a = *src; b = *dst; *src++ = bswap_32(b); *dst-- = bswap_32(a));
                                    }
                                }
                                else
#endif
                                {
                                    char *s1, *s2;
                                    s1 = (char *)bytes;
                                    s2 = (char *)(s1 + len - 1);
                                    while (s1 < s2) {char c; c = *s1; *s1++ = *s2; *s2-- = c;}
                                }
                            }
                            break;

                        case T_INT_VECTOR:
                            {
                                s7_int len;
                                s7_int *s1, *s2;
                                if (is_immutable_vector(p))
                                    return(immutable_object_error(sc, set_elist_3(sc, immutable_error_string, sc->reverseb_symbol, p)));
                                len = vector_length(p);
                                if (len < 2) return(p);
                                s1 = int_vector_ints(p);
                                s2 = (s7_int *)(s1 + len - 1);
                                if ((len & 0xf) == 0) /* not 0x7 -- odd multiple of 8 will leave center ints unreversed */
                                {
                                    while (s1 < s2)
                                    {
                                        s7_int c;
                                        LOOP_8(c = *s1; *s1++ = *s2; *s2-- = c);
                                    }
                                }
                                else while (s1 < s2) {s7_int c; c = *s1; *s1++ = *s2; *s2-- = c;}
                            }
                            break;

                        case T_FLOAT_VECTOR:
                            {
                                s7_int len;
                                s7_double *s1, *s2;
                                if (is_immutable_vector(p))
                                    return(immutable_object_error(sc, set_elist_3(sc, immutable_error_string, sc->reverseb_symbol, p)));
                                len = vector_length(p);
                                if (len < 2) return(p);
                                s1 = float_vector_floats(p);
                                s2 = (s7_double *)(s1 + len - 1);
                                if ((len & 0xf) == 0)
                                {
                                    while (s1 < s2)
                                    {
                                        s7_double c;
                                        LOOP_8(c = *s1; *s1++ = *s2; *s2-- = c);
                                    }
                                }
                                else while (s1 < s2) {s7_double c; c = *s1; *s1++ = *s2; *s2-- = c;}
                            }
                            break;

                        case T_VECTOR:
                            {
                                s7_int len;
                                s7_pointer *s1, *s2;
                                if (is_immutable_vector(p))
                                    return(immutable_object_error(sc, set_elist_3(sc, immutable_error_string, sc->reverseb_symbol, p)));
                                len = vector_length(p);
                                if (len < 2) return(p);
                                s1 = vector_elements(p);
                                s2 = (s7_pointer *)(s1 + len - 1);
                                if ((len & 0xf) == 0)
                                {
                                    while (s1 < s2)
                                    {
                                        s7_pointer c;
                                        LOOP_8(c = *s1; *s1++ = *s2; *s2-- = c);
                                    }
                                }
                                else while (s1 < s2) {s7_pointer c; c = *s1; *s1++ = *s2; *s2-- = c;}
                            }
                            break;

                        default:
                            if (is_immutable(p))
                            {
                                if (is_simple_sequence(p))
                                    return(immutable_object_error(sc, set_elist_3(sc, immutable_error_string, sc->reverseb_symbol, p)));
                                return(simple_wrong_type_argument_with_type(sc, sc->reverseb_symbol, p, a_sequence_string));
                            }
                            if ((is_simple_sequence(p)) &&
                                    (!has_active_methods(sc, p)))
                                return(simple_wrong_type_argument_with_type(sc, sc->reverseb_symbol, p, wrap_string(sc, "a vector, string, or list", 25)));
                            return(method_or_bust_with_type_one_arg(sc, p, sc->reverseb_symbol, list_1(sc, p), a_sequence_string));
                    }
                    return(p);
                }

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
movq 0x8(%rsi), %rbx
movzbl (%rbx), %eax
leal -0x13(%rax), %ecx
cmpl $0x5, %ecx
ja 0x77337
leaq 0x9096a(%rip), %rax     # 0x107c48
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
testb $0x1, 0x3(%rbx)
jne 0x7767f
movq 0x8(%rbx), %rax
cmpq $0x2, %rax
jl 0x776c1
movq 0x10(%rbx), %rcx
movl %eax, %edx
addq %rcx, %rax
testb $0x1f, %dl
je 0x77745
decq %rax
incq %rcx
movb -0x1(%rcx), %dl
movb (%rax), %sil
movb %sil, -0x1(%rcx)
movb %dl, (%rax)
decq %rax
leaq 0x1(%rcx), %rdx
cmpq %rax, %rcx
movq %rdx, %rcx
jb 0x77317
jmp 0x776c1
cmpl $0x1, %eax
je 0x7762a
cmpl $0x2, %eax
jne 0x77351
movq 0x110(%r14), %rbx
jmp 0x776c1
movq (%rbx), %rax
btl $0x18, %eax
movzbl %al, %ecx
leaq 0xdb81e(%rip), %rdx     # 0x152b80
movb (%rcx,%rdx), %cl
jb 0x7767b
testb %cl, %cl
je 0x77387
btl $0x1e, %eax
jae 0x776eb
cmpb $0x0, 0x24c(%r14)
je 0x776eb
movq 0x1488(%r14), %r15
movq 0x90(%r14), %rax
movq 0x110(%r14), %r12
cmpq 0x98(%r14), %rax
ja 0x773b4
movq %r14, %rdi
callq 0xa550
movq 0x90(%r14), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%r14)
movq -0x8(%rax), %rcx
movq $0x200001, (%rcx)       # imm = 0x200001
movq %rbx, 0x8(%rcx)
movq %r12, 0x10(%rcx)
movq 0xd3837(%rip), %r8      # 0x14ac10
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xfa261
testb $0x1, 0x3(%rbx)
jne 0x7767f
movq 0x8(%rbx), %rcx
cmpq $0x2, %rcx
jl 0x776c1
movq 0x10(%rbx), %rax
testb $0xf, %cl
je 0x77798
leaq (%rax,%rcx,8), %rcx
addq $-0x10, %rcx
movq (%rax), %rdx
movq 0x8(%rcx), %rsi
movq %rsi, (%rax)
addq $0x8, %rax
movq %rdx, 0x8(%rcx)
leaq -0x8(%rcx), %rdx
cmpq %rcx, %rax
movq %rdx, %rcx
jb 0x7741f
jmp 0x776c1
testb $0x1, 0x3(%rbx)
jne 0x7767f
movq 0x8(%rbx), %rdx
cmpq $0x2, %rdx
jl 0x776c1
movq 0x10(%rbx), %rcx
leaq (%rcx,%rdx,8), %rax
addq $-0x8, %rax
testb $0xf, %dl
je 0x77496
addq $0x8, %rcx
movsd -0x8(%rcx), %xmm0
movsd (%rax), %xmm1
movsd %xmm1, -0x8(%rcx)
movsd %xmm0, (%rax)
addq $-0x8, %rax
leaq 0x8(%rcx), %rdx
cmpq %rax, %rcx
movq %rdx, %rcx
jb 0x7746f
jmp 0x776c1
movsd (%rcx), %xmm0
movsd (%rax), %xmm1
movsd %xmm1, (%rcx)
movsd %xmm0, (%rax)
movsd 0x8(%rcx), %xmm0
movsd -0x8(%rax), %xmm1
movsd %xmm1, 0x8(%rcx)
movsd %xmm0, -0x8(%rax)
movsd 0x10(%rcx), %xmm0
movsd -0x10(%rax), %xmm1
movsd %xmm1, 0x10(%rcx)
movsd %xmm0, -0x10(%rax)
movsd 0x18(%rcx), %xmm0
movsd -0x18(%rax), %xmm1
movsd %xmm1, 0x18(%rcx)
movsd %xmm0, -0x18(%rax)
movsd 0x20(%rcx), %xmm0
movsd -0x20(%rax), %xmm1
movsd %xmm1, 0x20(%rcx)
movsd %xmm0, -0x20(%rax)
movsd 0x28(%rcx), %xmm0
movsd -0x28(%rax), %xmm1
movsd %xmm1, 0x28(%rcx)
movsd %xmm0, -0x28(%rax)
movsd 0x30(%rcx), %xmm0
movsd -0x30(%rax), %xmm1
movsd %xmm1, 0x30(%rcx)
movsd %xmm0, -0x30(%rax)
movsd 0x38(%rcx), %xmm0
movsd -0x38(%rax), %xmm1
movsd %xmm1, 0x38(%rcx)
addq $0x40, %rcx
movsd %xmm0, -0x38(%rax)
addq $-0x40, %rax
cmpq %rax, %rcx
jb 0x77496
jmp 0x776c1
testb $0x1, 0x3(%rbx)
jne 0x7767f
movq 0x8(%rbx), %rdx
cmpq $0x2, %rdx
jl 0x776c1
movq 0x10(%rbx), %rcx
leaq (%rcx,%rdx,8), %rax
addq $-0x8, %rax
testb $0xf, %dl
je 0x77598
addq $0x8, %rcx
movq -0x8(%rcx), %rdx
movq (%rax), %rsi
movq %rsi, -0x8(%rcx)
movq %rdx, (%rax)
addq $-0x8, %rax
leaq 0x8(%rcx), %rdx
cmpq %rax, %rcx
movq %rdx, %rcx
jb 0x77575
jmp 0x776c1
movq (%rcx), %rdx
movq (%rax), %rsi
movq %rsi, (%rcx)
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq -0x8(%rax), %rsi
movq %rsi, 0x8(%rcx)
movq %rdx, -0x8(%rax)
movq 0x10(%rcx), %rdx
movq -0x10(%rax), %rsi
movq %rsi, 0x10(%rcx)
movq %rdx, -0x10(%rax)
movq 0x18(%rcx), %rdx
movq -0x18(%rax), %rsi
movq %rsi, 0x18(%rcx)
movq %rdx, -0x18(%rax)
movq 0x20(%rcx), %rdx
movq -0x20(%rax), %rsi
movq %rsi, 0x20(%rcx)
movq %rdx, -0x20(%rax)
movq 0x28(%rcx), %rdx
movq -0x28(%rax), %rsi
movq %rsi, 0x28(%rcx)
movq %rdx, -0x28(%rax)
movq 0x30(%rcx), %rdx
movq -0x30(%rax), %rsi
movq %rsi, 0x30(%rcx)
movq %rdx, -0x30(%rax)
movq 0x38(%rcx), %rdx
movq -0x38(%rax), %rsi
movq %rsi, 0x38(%rcx)
addq $0x40, %rcx
movq %rdx, -0x38(%rax)
addq $-0x40, %rax
cmpq %rax, %rcx
jb 0x77598
jmp 0x776c1
testb $0x1, 0x3(%rbx)
jne 0x7767f
movq %rsi, %r15
movq 0x110(%r14), %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0xe8985
movq %rax, %rbx
cmpq 0x110(%r14), %rax
jne 0x776c1
movq 0x8(%r15), %rcx
leaq 0x9a994(%rip), %rsi     # 0x111ff0
leaq 0xa42ef(%rip), %r8      # 0x11b952
movl $0x1, %edx
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xd4e5
testb %cl, %cl
je 0x776d0
movq 0xd32e2(%rip), %rax     # 0x14a968
movq 0x1488(%r14), %rcx
movq 0x6e8(%r14), %rdx
movq %rax, 0x8(%rdx)
movq 0x10(%rdx), %rax
movq %rcx, 0x8(%rax)
movq 0x10(%rax), %rax
movq %rbx, 0x8(%rax)
movq 0x6e8(%r14), %rdx
movq 0xea8(%r14), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x38dfa
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0x1488(%r14), %rax
movq 0x8(%rax), %rsi
movq 0x140(%r14), %rcx
movq 0xd3527(%rip), %r8      # 0x14ac10
jmp 0x7772f
movq 0x1488(%r14), %rax
movq 0x8(%rax), %rsi
movq 0x140(%r14), %rcx
movq 0x820(%r14), %rax
movslq 0x7dc(%r14), %rdx
movq (%rax,%rdx,8), %r8
leal 0x1(%rdx), %eax
andl $0x7, %eax
movl %eax, 0x7dc(%r14)
leaq 0xa4246(%rip), %rax     # 0x11b969
movq %rax, 0x10(%r8)
movq $0x19, 0x8(%r8)
movq %r14, %rdi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xed2a
addq $-0x4, %rax
cmpq %rax, %rcx
jae 0x776c1
movl (%rcx), %edx
movl (%rax), %esi
bswapl %esi
movl %esi, (%rcx)
bswapl %edx
movl %edx, (%rax)
movl 0x4(%rcx), %edx
movl -0x4(%rax), %esi
bswapl %esi
movl %esi, 0x4(%rcx)
bswapl %edx
movl %edx, -0x4(%rax)
movl 0x8(%rcx), %edx
movl -0x8(%rax), %esi
bswapl %esi
movl %esi, 0x8(%rcx)
bswapl %edx
movl %edx, -0x8(%rax)
movl 0xc(%rcx), %edx
movl -0xc(%rax), %esi
bswapl %esi
movl %esi, 0xc(%rcx)
addq $0x10, %rcx
bswapl %edx
movl %edx, -0xc(%rax)
addq $-0x10, %rax
jmp 0x77749
leaq (%rax,%rcx,8), %rcx
addq $-0x8, %rcx
movq (%rax), %rdx
movq (%rcx), %rsi
movq %rsi, (%rax)
movq %rdx, (%rcx)
movq 0x8(%rax), %rdx
movq -0x8(%rcx), %rsi
movq %rsi, 0x8(%rax)
movq %rdx, -0x8(%rcx)
movq 0x10(%rax), %rdx
movq -0x10(%rcx), %rsi
movq %rsi, 0x10(%rax)
movq %rdx, -0x10(%rcx)
movq 0x18(%rax), %rdx
movq -0x18(%rcx), %rsi
movq %rsi, 0x18(%rax)
movq %rdx, -0x18(%rcx)
movq 0x20(%rax), %rdx
movq -0x20(%rcx), %rsi
movq %rsi, 0x20(%rax)
movq %rdx, -0x20(%rcx)
movq 0x28(%rax), %rdx
movq -0x28(%rcx), %rsi
movq %rsi, 0x28(%rax)
movq %rdx, -0x28(%rcx)
movq 0x30(%rax), %rdx
movq -0x30(%rcx), %rsi
movq %rsi, 0x30(%rax)
movq %rdx, -0x30(%rcx)
movq 0x38(%rax), %rdx
movq -0x38(%rcx), %rsi
movq %rsi, 0x38(%rax)
addq $0x40, %rax
movq %rdx, -0x38(%rcx)
addq $-0x40, %rcx
cmpq %rcx, %rax
jb 0x777a0
jmp 0x776c1