// File: /workspace/github_c_makefile_star2_O2/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 0x6052a
leaq 0x7374d(%rip), %rax     # 0xd3c28
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
testb $0x1, 0x3(%rbx)
jne 0x608de
movq 0x8(%rbx), %rcx
cmpq $0x2, %rcx
jl 0x608cb
movq 0x10(%rbx), %rax
testb $0x1f, %cl
je 0x60996
addq %rax, %rcx
decq %rcx
cmpq %rcx, %rax
jae 0x608cb
movb (%rax), %dl
movb (%rcx), %sil
movb %sil, (%rax)
incq %rax
movb %dl, (%rcx)
decq %rcx
jmp 0x6050f
cmpl $0x1, %eax
je 0x608a0
cmpl $0x2, %eax
jne 0x60544
movq 0x110(%r14), %rbx
jmp 0x608cb
movq (%rbx), %rax
btl $0x18, %eax
movzbl %al, %ecx
leaq 0xc162b(%rip), %rdx     # 0x121b80
movb (%rcx,%rdx), %cl
jb 0x608da
testb %cl, %cl
je 0x6057a
btl $0x1e, %eax
jae 0x6093c
cmpb $0x0, 0x24c(%r14)
je 0x6093c
movq 0x1488(%r14), %r15
movq 0x90(%r14), %rax
movq 0x110(%r14), %r12
cmpq 0x98(%r14), %rax
ja 0x605a7
movq %r14, %rdi
callq 0x9c27
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 0xb9644(%rip), %r8      # 0x119c10
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xc736d
testb $0x1, 0x3(%rbx)
jne 0x608de
movq 0x8(%rbx), %rdx
cmpq $0x2, %rdx
jl 0x608cb
movq 0x10(%rbx), %rax
leaq (%rax,%rdx,8), %rcx
addq $-0x8, %rcx
testb $0xf, %dl
je 0x606b5
cmpq %rcx, %rax
jae 0x608cb
movq (%rax), %rdx
movq (%rcx), %rsi
movq %rsi, (%rax)
addq $0x8, %rax
movq %rdx, (%rcx)
addq $-0x8, %rcx
jmp 0x60612
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 0x60631
jmp 0x608cb
testb $0x1, 0x3(%rbx)
jne 0x608de
movq 0x8(%rbx), %rdx
cmpq $0x2, %rdx
jl 0x608cb
movq 0x10(%rbx), %rax
leaq (%rax,%rdx,8), %rcx
addq $-0x8, %rcx
testb $0xf, %dl
je 0x607b7
cmpq %rcx, %rax
jae 0x608cb
movsd (%rax), %xmm0
movsd (%rcx), %xmm1
movsd %xmm1, (%rax)
addq $0x8, %rax
movsd %xmm0, (%rcx)
addq $-0x8, %rcx
jmp 0x606f0
movsd (%rax), %xmm0
movsd (%rcx), %xmm1
movsd %xmm1, (%rax)
movsd %xmm0, (%rcx)
movsd 0x8(%rax), %xmm0
movsd -0x8(%rcx), %xmm1
movsd %xmm1, 0x8(%rax)
movsd %xmm0, -0x8(%rcx)
movsd 0x10(%rax), %xmm0
movsd -0x10(%rcx), %xmm1
movsd %xmm1, 0x10(%rax)
movsd %xmm0, -0x10(%rcx)
movsd 0x18(%rax), %xmm0
movsd -0x18(%rcx), %xmm1
movsd %xmm1, 0x18(%rax)
movsd %xmm0, -0x18(%rcx)
movsd 0x20(%rax), %xmm0
movsd -0x20(%rcx), %xmm1
movsd %xmm1, 0x20(%rax)
movsd %xmm0, -0x20(%rcx)
movsd 0x28(%rax), %xmm0
movsd -0x28(%rcx), %xmm1
movsd %xmm1, 0x28(%rax)
movsd %xmm0, -0x28(%rcx)
movsd 0x30(%rax), %xmm0
movsd -0x30(%rcx), %xmm1
movsd %xmm1, 0x30(%rax)
movsd %xmm0, -0x30(%rcx)
movsd 0x38(%rax), %xmm0
movsd -0x38(%rcx), %xmm1
movsd %xmm1, 0x38(%rax)
addq $0x40, %rax
movsd %xmm0, -0x38(%rcx)
addq $-0x40, %rcx
cmpq %rcx, %rax
jb 0x60713
jmp 0x608cb
testb $0x1, 0x3(%rbx)
jne 0x608de
movq 0x8(%rbx), %rdx
cmpq $0x2, %rdx
jl 0x608cb
movq 0x10(%rbx), %rax
leaq (%rax,%rdx,8), %rcx
addq $-0x8, %rcx
testb $0xf, %dl
je 0x60895
cmpq %rcx, %rax
jae 0x608cb
movq (%rax), %rdx
movq (%rcx), %rsi
movq %rsi, (%rax)
addq $0x8, %rax
movq %rdx, (%rcx)
addq $-0x8, %rcx
jmp 0x607f2
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 0x60811
jmp 0x608cb
testb $0x1, 0x3(%rbx)
jne 0x608de
movq %rsi, %r15
movq 0x110(%r14), %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0xb8f9c
movq %rax, %rbx
cmpq 0x110(%r14), %rax
je 0x609ec
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
testb %cl, %cl
je 0x60921
movq 0xb9083(%rip), %rax     # 0x119968
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), %rsi
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x972b
movq 0x1488(%r14), %rax
movq 0x8(%rax), %rsi
movq 0x140(%r14), %rcx
movq 0xb92d6(%rip), %r8      # 0x119c10
jmp 0x60980
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 0x86f95(%rip), %rax     # 0xe7909
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 0xd456
addq %rax, %rcx
addq $-0x4, %rcx
cmpq %rcx, %rax
jae 0x608cb
movl (%rax), %edx
movl (%rcx), %esi
bswapl %esi
movl %esi, (%rax)
bswapl %edx
movl %edx, (%rcx)
movl 0x4(%rax), %edx
movl -0x4(%rcx), %esi
bswapl %esi
movl %esi, 0x4(%rax)
bswapl %edx
movl %edx, -0x4(%rcx)
movl 0x8(%rax), %edx
movl -0x8(%rcx), %esi
bswapl %esi
movl %esi, 0x8(%rax)
bswapl %edx
movl %edx, -0x8(%rcx)
movl 0xc(%rax), %edx
movl -0xc(%rcx), %esi
bswapl %esi
movl %esi, 0xc(%rax)
addq $0x10, %rax
bswapl %edx
movl %edx, -0xc(%rcx)
addq $-0x10, %rcx
jmp 0x6099d
movq 0x8(%r15), %rcx
leaq 0x7d599(%rip), %rsi     # 0xddf90
leaq 0x86ef4(%rip), %r8      # 0xe78f2
pushq $0x1
popq %rdx
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xc2b0