// File: /workspace/github_c_makefile_star2_O1/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 0x7d015
leaq 0x93c18(%rip), %rax     # 0x110bc8
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
testb $0x1, 0x3(%rbx)
jne 0x7d23b
movq 0x8(%rbx), %rcx
cmpq $0x2, %rcx
jl 0x7d231
movq 0x10(%rbx), %rdx
movl %ecx, %eax
addq %rdx, %rcx
testb $0x1f, %al
je 0x7d3fa
decq %rcx
movb $0x1, %al
cmpq %rcx, %rdx
jae 0x7d38a
incq %rdx
movb -0x1(%rdx), %sil
movb (%rcx), %dil
movb %dil, -0x1(%rdx)
movb %sil, (%rcx)
decq %rcx
leaq 0x1(%rdx), %rsi
cmpq %rcx, %rdx
movq %rsi, %rdx
jb 0x7cff3
jmp 0x7d38a
cmpl $0x1, %eax
je 0x7d284
cmpl $0x2, %eax
jne 0x7d02f
movq 0x110(%r14), %r15
jmp 0x7d391
testb $0x1, 0x3(%rbx)
movzbl (%rbx), %eax
leaq 0xddb43(%rip), %rcx     # 0x15ab80
movb (%rax,%rcx), %al
jne 0x7d2e7
testb %al, %al
je 0x7d062
testb $0x40, 0x3(%rbx)
je 0x7d3a0
cmpb $0x0, 0x24c(%r14)
je 0x7d3a0
movq 0x1488(%r14), %r15
movq 0x90(%r14), %rax
movq 0x110(%r14), %r12
cmpq 0x98(%r14), %rax
ja 0x7d088
movq %r14, %rdi
callq 0xb389
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 0xd5b5c(%rip), %r8      # 0x152c10
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x103001
testb $0x1, 0x3(%rbx)
jne 0x7d23b
movq 0x8(%rbx), %rsi
cmpq $0x2, %rsi
jl 0x7d231
movq 0x10(%rbx), %rcx
leaq (%rcx,%rsi,8), %rdx
addq $-0x8, %rdx
movb $0x1, %al
testb $0xf, %sil
je 0x7d1b5
cmpq %rdx, %rcx
jae 0x7d38a
leaq (%rcx,%rsi,8), %rdx
addq $-0x10, %rdx
movq (%rcx), %rsi
movq 0x8(%rdx), %rdi
movq %rdi, (%rcx)
addq $0x8, %rcx
movq %rsi, 0x8(%rdx)
leaq -0x8(%rdx), %rsi
cmpq %rdx, %rcx
movq %rsi, %rdx
jb 0x7d10e
jmp 0x7d38a
movq (%rcx), %rsi
movq (%rdx), %rdi
movq %rdi, (%rcx)
movq %rsi, (%rdx)
movq 0x8(%rcx), %rsi
movq -0x8(%rdx), %rdi
movq %rdi, 0x8(%rcx)
movq %rsi, -0x8(%rdx)
movq 0x10(%rcx), %rsi
movq -0x10(%rdx), %rdi
movq %rdi, 0x10(%rcx)
movq %rsi, -0x10(%rdx)
movq 0x18(%rcx), %rsi
movq -0x18(%rdx), %rdi
movq %rdi, 0x18(%rcx)
movq %rsi, -0x18(%rdx)
movq 0x20(%rcx), %rsi
movq -0x20(%rdx), %rdi
movq %rdi, 0x20(%rcx)
movq %rsi, -0x20(%rdx)
movq 0x28(%rcx), %rsi
movq -0x28(%rdx), %rdi
movq %rdi, 0x28(%rcx)
movq %rsi, -0x28(%rdx)
movq 0x30(%rcx), %rsi
movq -0x30(%rdx), %rdi
movq %rdi, 0x30(%rcx)
movq %rsi, -0x30(%rdx)
movq 0x38(%rcx), %rsi
movq -0x38(%rdx), %rdi
movq %rdi, 0x38(%rcx)
addq $0x40, %rcx
movq %rsi, -0x38(%rdx)
addq $-0x40, %rdx
cmpq %rdx, %rcx
jb 0x7d131
jmp 0x7d38a
testb $0x1, 0x3(%rbx)
jne 0x7d23b
movq 0x8(%rbx), %rax
cmpq $0x2, %rax
jl 0x7d231
movq 0x10(%rbx), %rcx
leaq (%rcx,%rax,8), %rdx
addq $-0x8, %rdx
testb $0xf, %al
je 0x7d485
movb $0x1, %al
cmpq %rdx, %rcx
jae 0x7d38a
addq $0x8, %rcx
movsd -0x8(%rcx), %xmm0
movsd (%rdx), %xmm1
movsd %xmm1, -0x8(%rcx)
movsd %xmm0, (%rdx)
addq $-0x8, %rdx
leaq 0x8(%rcx), %rsi
cmpq %rdx, %rcx
movq %rsi, %rcx
jb 0x7d1f6
jmp 0x7d38a
testb $0x1, 0x3(%rbx)
jne 0x7d23b
movq 0x8(%rbx), %rax
cmpq $0x2, %rax
jge 0x7d34d
xorl %eax, %eax
movq %rbx, %r15
jmp 0x7d38a
movq 0xd5726(%rip), %rax     # 0x152968
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), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x3b366
xorl %eax, %eax
jmp 0x7d38a
testb $0x1, 0x3(%rbx)
jne 0x7d2eb
movq 0x110(%r14), %rax
cmpq %rbx, %rax
je 0x7d44b
movq 0x10(%rbx), %rdi
movq 0x110(%r14), %r15
movq %rbx, %r8
movq %rax, %r9
movq %rbx, %r10
cmpq %r15, %rdi
setne %cl
je 0x7d2ca
cmpb $0x1, (%rdi)
jne 0x7d2d9
testb $0x1, 0x3(%rdi)
movq %rdi, %r8
movq %rbx, %r9
movq %rdx, %r10
jne 0x7d2d9
movq %rax, 0x10(%rbx)
movq %r8, %rbx
movq %r9, %rax
movq %r10, %r15
jmp 0x7d2db
xorl %ecx, %ecx
movq %r15, %rdx
testb %cl, %cl
jne 0x7d29a
jmp 0x7d44e
testb %al, %al
je 0x7d32f
movq 0xd5676(%rip), %rax     # 0x152968
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), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x3b366
jmp 0x7d391
movq 0x1488(%r14), %rax
movq 0x8(%rax), %rsi
movq 0x140(%r14), %rcx
movq 0xd58c8(%rip), %r8      # 0x152c10
jmp 0x7d3e4
movq 0x10(%rbx), %rcx
leaq (%rcx,%rax,8), %rdx
addq $-0x8, %rdx
testb $0xf, %al
je 0x7d539
movb $0x1, %al
cmpq %rdx, %rcx
jae 0x7d38a
addq $0x8, %rcx
movq -0x8(%rcx), %rsi
movq (%rdx), %rdi
movq %rdi, -0x8(%rcx)
movq %rsi, (%rdx)
addq $-0x8, %rdx
leaq 0x8(%rcx), %rsi
cmpq %rdx, %rcx
movq %rsi, %rcx
jb 0x7d36c
testb %al, %al
je 0x7d391
movq %rbx, %r15
movq %r15, %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 0x820(%r14), %rax
movslq 0x7dc(%r14), %rdx
movq (%rax,%rdx,8), %r8
leal 0x1(%rdx), %eax
andl $0x7, %eax
movl %eax, 0x7dc(%r14)
leaq 0xa7481(%rip), %rax     # 0x124859
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 0xfac8
addq $-0x4, %rcx
movb $0x1, %al
cmpq %rcx, %rdx
jae 0x7d38a
movl (%rdx), %esi
movl (%rcx), %edi
bswapl %edi
movl %edi, (%rdx)
bswapl %esi
movl %esi, (%rcx)
movl 0x4(%rdx), %esi
movl -0x4(%rcx), %edi
bswapl %edi
movl %edi, 0x4(%rdx)
bswapl %esi
movl %esi, -0x4(%rcx)
movl 0x8(%rdx), %esi
movl -0x8(%rcx), %edi
bswapl %edi
movl %edi, 0x8(%rdx)
bswapl %esi
movl %esi, -0x8(%rcx)
movl 0xc(%rdx), %esi
movl -0xc(%rcx), %edi
bswapl %edi
movl %edi, 0xc(%rdx)
addq $0x10, %rdx
bswapl %esi
movl %esi, -0xc(%rcx)
addq $-0x10, %rcx
jmp 0x7d400
movq %rax, %r15
cmpq 0x110(%r14), %r15
jne 0x7d391
movq 0x8(%rsi), %rcx
leaq 0x9da7a(%rip), %rsi     # 0x11aee0
leaq 0xa73d5(%rip), %r8      # 0x124842
movl $0x1, %edx
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xe25f
movb $0x1, %al
cmpq %rdx, %rcx
jae 0x7d38a
movsd (%rcx), %xmm0
movsd (%rdx), %xmm1
movsd %xmm1, (%rcx)
movsd %xmm0, (%rdx)
movsd 0x8(%rcx), %xmm0
movsd -0x8(%rdx), %xmm1
movsd %xmm1, 0x8(%rcx)
movsd %xmm0, -0x8(%rdx)
movsd 0x10(%rcx), %xmm0
movsd -0x10(%rdx), %xmm1
movsd %xmm1, 0x10(%rcx)
movsd %xmm0, -0x10(%rdx)
movsd 0x18(%rcx), %xmm0
movsd -0x18(%rdx), %xmm1
movsd %xmm1, 0x18(%rcx)
movsd %xmm0, -0x18(%rdx)
movsd 0x20(%rcx), %xmm0
movsd -0x20(%rdx), %xmm1
movsd %xmm1, 0x20(%rcx)
movsd %xmm0, -0x20(%rdx)
movsd 0x28(%rcx), %xmm0
movsd -0x28(%rdx), %xmm1
movsd %xmm1, 0x28(%rcx)
movsd %xmm0, -0x28(%rdx)
movsd 0x30(%rcx), %xmm0
movsd -0x30(%rdx), %xmm1
movsd %xmm1, 0x30(%rcx)
movsd %xmm0, -0x30(%rdx)
movsd 0x38(%rcx), %xmm0
movsd -0x38(%rdx), %xmm1
movsd %xmm1, 0x38(%rcx)
addq $0x40, %rcx
movsd %xmm0, -0x38(%rdx)
addq $-0x40, %rdx
jmp 0x7d487
movb $0x1, %al
cmpq %rdx, %rcx
jae 0x7d38a
movq (%rcx), %rsi
movq (%rdx), %rdi
movq %rdi, (%rcx)
movq %rsi, (%rdx)
movq 0x8(%rcx), %rsi
movq -0x8(%rdx), %rdi
movq %rdi, 0x8(%rcx)
movq %rsi, -0x8(%rdx)
movq 0x10(%rcx), %rsi
movq -0x10(%rdx), %rdi
movq %rdi, 0x10(%rcx)
movq %rsi, -0x10(%rdx)
movq 0x18(%rcx), %rsi
movq -0x18(%rdx), %rdi
movq %rdi, 0x18(%rcx)
movq %rsi, -0x18(%rdx)
movq 0x20(%rcx), %rsi
movq -0x20(%rdx), %rdi
movq %rdi, 0x20(%rcx)
movq %rsi, -0x20(%rdx)
movq 0x28(%rcx), %rsi
movq -0x28(%rdx), %rdi
movq %rdi, 0x28(%rcx)
movq %rsi, -0x28(%rdx)
movq 0x30(%rcx), %rsi
movq -0x30(%rdx), %rdi
movq %rdi, 0x30(%rcx)
movq %rsi, -0x30(%rdx)
movq 0x38(%rcx), %rsi
movq -0x38(%rdx), %rdi
movq %rdi, 0x38(%rcx)
addq $0x40, %rcx
movq %rsi, -0x38(%rdx)
addq $-0x40, %rdx
jmp 0x7d53b