// File: /workspace/github_c_makefile_star2_O3/BernardTatin[P]s7sh/s7.c
// Function: g_reverse
static s7_pointer g_reverse(s7_scheme *sc, s7_pointer args)
                {
#define H_reverse "(reverse lst) returns a list with the elements of lst in reverse order.  reverse \
                    also accepts a string or vector argument."
#define Q_reverse s7_make_signature(sc, 2, sc->is_sequence_symbol, sc->is_sequence_symbol)

                    s7_pointer p, np;

                    p = car(args);
                    sc->temp3 = p;
                    np = sc->nil;

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

                        case T_PAIR:
                            return(s7_reverse(sc, p));

                        case T_STRING:
                            {
                                char *source, *dest, *end;
                                s7_int len;
                                len = string_length(p);
                                source = string_value(p);
                                end = (char *)(source + len);
                                np = make_empty_string(sc, len, '\0');
                                dest = (char *)(string_value(np) + len);
                                while (source < end) *(--dest) = *source++;
                            }
                            break;

                        case T_BYTE_VECTOR:
                            {
                                uint8_t *source, *dest, *end;
                                s7_int len;
                                len = byte_vector_length(p);
                                source = byte_vector_bytes(p);
                                end = (uint8_t *)(source + len);
                                np = make_simple_byte_vector(sc, len);
                                dest = (uint8_t *)(byte_vector_bytes(np) + len);
                                while (source < end) *(--dest) = *source++;
                            }
                            break;

                        case T_INT_VECTOR:
                            {
                                s7_int *source, *dest, *end;
                                s7_int len;
                                len = vector_length(p);
                                if (vector_rank(p) > 1)
                                    np = g_make_vector_1(sc, set_plist_2(sc, g_vector_dimensions(sc, set_plist_1(sc, p)), small_int(0)), sc->make_int_vector_symbol);
                                else np = make_simple_int_vector(sc, len);
                                source = int_vector_ints(p);
                                end = (s7_int *)(source + len);
                                dest = (s7_int *)(int_vector_ints(np) + len);
                                while (source < end) *(--dest) = *source++;
                            }
                            break;

                        case T_FLOAT_VECTOR:
                            {
                                s7_double *source, *dest, *end;
                                s7_int len;
                                len = vector_length(p);
                                if (vector_rank(p) > 1)
                                    np = g_make_vector_1(sc, set_plist_2(sc, g_vector_dimensions(sc, set_plist_1(sc, p)), real_zero), sc->make_float_vector_symbol);
                                else np = make_simple_float_vector(sc, len);
                                source = float_vector_floats(p);
                                end = (s7_double *)(source + len);
                                dest = (s7_double *)(float_vector_floats(np) + len);
                                while (source < end) *(--dest) = *source++;
                            }
                            break;

                        case T_VECTOR:
                            {
                                s7_pointer *source, *dest, *end;
                                s7_int len;
                                len = vector_length(p);
                                if (vector_rank(p) > 1)
                                    np = g_make_vector(sc, set_plist_1(sc, g_vector_dimensions(sc, set_plist_1(sc, p))));
                                else np = make_simple_vector(sc, len);
                                source = vector_elements(p);
                                end = (s7_pointer *)(source + len);
                                dest = (s7_pointer *)(vector_elements(np) + len);
                                while (source < end) *(--dest) = *source++;
                            }
                            break;

                        case T_HASH_TABLE:
                            return(hash_table_reverse(sc, p));

                        case T_C_OBJECT:
                            check_method(sc, p, sc->reverse_symbol, args);
                            if (c_object_reverse(sc, p))
                                return((*(c_object_reverse(sc, p)))(sc, args));
                            eval_error(sc, "attempt to reverse ~S?", 22, p);

                        case T_LET:
                            check_method(sc, p, sc->reverse_symbol, args);
                            return(s7_error(sc, sc->wrong_type_arg_symbol, set_elist_2(sc, wrap_string(sc, "can't reverse let: ~S", 21), p)));

                        default:
                            return(method_or_bust_with_type_one_arg(sc, p, sc->reverse_symbol, args, a_sequence_string));
                    }
                    return(np);
                }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %r15
movq 0x8(%rsi), %rbx
movq %rbx, 0x508(%rdi)
movzbl (%rbx), %eax
leal -0x13(%rax), %ecx
cmpl $0x9, %ecx
ja 0x76aba
leaq 0x911b2(%rip), %rax     # 0x107c20
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq 0x8(%rbx), %r12
movq 0x10(%rbx), %rbx
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0xeab0
movq %rax, %r14
testq %r12, %r12
jle 0x772ab
leaq (%rbx,%r12), %rax
movq 0x10(%r14), %rcx
addq %r12, %rcx
decq %rcx
movb (%rbx), %dl
incq %rbx
movb %dl, (%rcx)
decq %rcx
cmpq %rax, %rbx
jb 0x76aa6
jmp 0x772ab
cmpl $0x1, %eax
je 0x76dc7
cmpl $0x2, %eax
jne 0x76ad4
movq 0x110(%r15), %r14
jmp 0x772ab
movq 0x1480(%r15), %rdx
movq 0xd412e(%rip), %r8      # 0x14ac10
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rcx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xfa261
movq 0x8(%rbx), %r12
movq 0x10(%rbx), %rbx
movq %r15, %rdi
movq %r12, %rsi
callq 0x3cd0e
movq %rax, %r14
testq %r12, %r12
jle 0x772ab
leaq (%rbx,%r12), %rax
movq 0x10(%r14), %rcx
addq %r12, %rcx
decq %rcx
movb (%rbx), %dl
incq %rbx
movb %dl, (%rcx)
decq %rcx
cmpq %rax, %rbx
jb 0x76b2b
jmp 0x772ab
movq 0x8(%rbx), %r13
leaq 0x1(%r13), %rsi
movq %r15, %rdi
callq 0x366fb
movq %rax, %r14
cmpq $0x0, 0x108(%r15)
js 0x76ed1
movq 0xe8(%r15), %rax
jmp 0x76f93
testb $0x40, 0x3(%rbx)
je 0x76ba2
cmpb $0x1, 0x24c(%r15)
jne 0x76ba2
movq %r15, %rdi
movq %rbx, %rsi
callq 0x8a63
movq 0x1480(%r15), %rdx
movq %r15, %rdi
movq %rax, %rsi
callq 0x89ff
cmpq 0x128(%r15), %rax
jne 0x76c21
movq 0x1940(%r15), %r14
movq 0x820(%r15), %rax
movslq 0x7dc(%r15), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%r15)
leaq 0xa4d6e(%rip), %rcx     # 0x11b93c
movq %rcx, 0x10(%rax)
movq $0x15, 0x8(%rax)
jmp 0x77083
testb $0x40, 0x3(%rbx)
je 0x76d95
cmpb $0x1, 0x24c(%r15)
jne 0x76d95
movq %r15, %rdi
movq %rbx, %rsi
callq 0x8a63
movq 0x1480(%r15), %rdx
movq %r15, %rdi
movq %rax, %rsi
callq 0x89ff
cmpq 0x128(%r15), %rax
je 0x76d95
movq %rax, %r12
movq %r15, %rdi
movq %r14, %rsi
callq 0x42f69
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xaee6
movq 0x8(%rbx), %r12
movq 0x18(%rbx), %rax
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x76de0
cmpq $0x2, 0x10(%rax)
jl 0x76de0
movq 0x700(%r15), %rax
movq %rbx, 0x8(%rax)
movq 0x700(%r15), %rsi
movq %r15, %rdi
callq 0x3c517
movq 0xd3fcc(%rip), %rcx     # 0x14ac58
movq 0x708(%r15), %rdx
movq %rax, 0x8(%rdx)
movq 0x710(%r15), %rax
movq %rcx, 0x8(%rax)
movq 0x708(%r15), %rsi
movq 0x12d8(%r15), %rdx
movq %r15, %rdi
callq 0x3c722
movq %rax, %r14
jmp 0x7717e
movq 0x8(%rbx), %r12
movq 0x18(%rbx), %rax
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x76e37
cmpq $0x2, 0x10(%rax)
jl 0x76e37
movq 0x700(%r15), %rax
movq %rbx, 0x8(%rax)
movq 0x700(%r15), %rsi
movq %r15, %rdi
callq 0x3c517
movq 0x700(%r15), %rcx
movq %rax, 0x8(%rcx)
movq 0x700(%r15), %rsi
movq 0x1318(%r15), %rdx
movq %r15, %rdi
callq 0x3c722
jmp 0x76e42
movq 0x8(%rbx), %r12
movq 0x18(%rbx), %rax
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x76e7a
cmpq $0x2, 0x10(%rax)
jl 0x76e7a
movq 0x700(%r15), %rax
movq %rbx, 0x8(%rax)
movq 0x700(%r15), %rsi
movq %r15, %rdi
callq 0x3c517
movq 0xcfbef(%rip), %rcx     # 0x146950
movq 0x708(%r15), %rdx
movq %rax, 0x8(%rdx)
movq 0x710(%r15), %rax
movq %rcx, 0x8(%rax)
movq 0x708(%r15), %rsi
movq 0x12f0(%r15), %rdx
movq %r15, %rdi
callq 0x3c722
movq %rax, %r14
jmp 0x7727f
movq 0x8d8(%r15), %rax
movq 0x8(%rbx), %rcx
movq (%rax,%rcx,8), %rax
movq 0x60(%rax), %rax
testq %rax, %rax
je 0x7704b
movq %r15, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movq %r15, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x399ce
movq 0x90(%r15), %rax
cmpq 0x98(%r15), %rax
ja 0x76dff
movq %r15, %rdi
callq 0xa550
movq 0x90(%r15), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%r15)
movq -0x8(%rax), %r14
movq $0x200017, (%r14)       # imm = 0x200017
movq %r12, 0x8(%r14)
leaq (,%r12,8), %rsi
testq %rsi, %rsi
jle 0x770b4
movq %r15, %rdi
callq 0x9357
jmp 0x7711a
movq %r15, %rdi
movq %r12, %rsi
callq 0x3bc4f
movq %rax, %r14
testq %r12, %r12
jle 0x772ab
movq 0x10(%rbx), %rax
leaq (%rax,%r12,8), %rcx
movq 0x10(%r14), %rdx
leaq (%rdx,%r12,8), %rdx
addq $-0x8, %rdx
movq (%rax), %rsi
addq $0x8, %rax
movq %rsi, (%rdx)
addq $-0x8, %rdx
cmpq %rcx, %rax
jb 0x76e62
jmp 0x772ab
movq 0x90(%r15), %rax
cmpq 0x98(%r15), %rax
ja 0x76e99
movq %r15, %rdi
callq 0xa550
movq 0x90(%r15), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%r15)
movq -0x8(%rax), %r14
movq $0x200016, (%r14)       # imm = 0x200016
movq %r12, 0x8(%r14)
leaq (,%r12,8), %rsi
testq %rsi, %rsi
jle 0x771b5
movq %r15, %rdi
callq 0x9357
jmp 0x7721b
movq 0xd0(%r15), %rax
movq 0xf0(%r15), %rbp
leaq (,%rbp,2), %rcx
movq %rcx, (%rsp)
movq 0x18(%rax), %rsi
movq %rbp, %r12
shlq $0x4, %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x9fd6
movq $0x0, 0x20(%rax)
movq 0xd0(%r15), %rcx
movq %rax, 0x18(%rcx)
movq (%rax), %rax
movq 0xd0(%r15), %rcx
movq %rax, 0x10(%rcx)
movq 0xd0(%r15), %rax
movq (%rsp), %rcx
movq %rcx, 0x8(%rax)
movq %rcx, 0xf0(%r15)
movq 0xe8(%r15), %rdi
movq %r12, %rsi
callq 0x8510
movq %rax, 0xe8(%r15)
cmpq (%rsp), %rbp
jge 0x76f93
movq 0x140(%r15), %rcx
movq %rbp, %rdx
movq 0xd0(%r15), %rax
movq 0x10(%rax), %rax
movq %rcx, (%rax,%rdx,8)
movq 0xe8(%r15), %rax
movq 0x108(%r15), %rsi
leaq 0x1(%rsi), %rdi
movq %rdi, 0x108(%r15)
movq %rdx, 0x8(%rax,%rsi,8)
incq %rdx
decq %rbp
jne 0x76f5e
movq 0xd0(%r15), %rcx
movq 0x108(%r15), %rdx
leaq -0x1(%rdx), %rsi
movq %rsi, 0x108(%r15)
movq (%rax,%rdx,8), %rdx
movq 0x10(%rcx), %rax
movq %rdx, (%rsp)
movq %r14, (%rax,%rdx,8)
testq %r13, %r13
js 0x76ff7
movq 0x10(%rbx), %rbx
xorl %ebp, %ebp
movq (%rbx,%rbp,8), %r12
testq %r12, %r12
je 0x76feb
movq (%r12), %rcx
movq 0x20(%r12), %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x36924
movq 0x18(%r12), %r12
jmp 0x76fcb
leaq 0x1(%rbp), %rax
cmpq %r13, %rbp
movq %rax, %rbp
jne 0x76fc7
movq (%rsp), %r8
cmpq %r8, 0xf0(%r15)
jle 0x772ab
movq 0xd0(%r15), %rcx
movq 0x140(%r15), %rax
movq 0x10(%rcx), %rdx
cmpq %rax, (%rdx,%r8,8)
je 0x77042
movq 0xe8(%r15), %rdx
movq 0x108(%r15), %rsi
leaq 0x1(%rsi), %rdi
movq %rdi, 0x108(%r15)
movq %r8, 0x8(%rdx,%rsi,8)
movq 0x10(%rcx), %rdx
movq %rax, (%rdx,%r8,8)
jmp 0x772ab
movq 0x1918(%r15), %r14
movq 0x820(%r15), %rax
movslq 0x7dc(%r15), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%r15)
leaq 0xa48ae(%rip), %rcx     # 0x11b925
movq %rcx, 0x10(%rax)
movq $0x16, 0x8(%rax)
movq 0x6e0(%r15), %rcx
movq %rax, 0x8(%rcx)
movq 0x6e0(%r15), %rax
movq 0x10(%rax), %rax
movq %rbx, 0x8(%rax)
movq 0x6e0(%r15), %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x38dfa
jmp 0x772ab
movq 0x838(%r15), %rax
testq %rax, %rax
jne 0x770ff
movl $0x2800, %edi           # imm = 0x2800
callq 0x8480
movq %rax, 0x838(%r15)
movq %rax, %rcx
addq $0x28, %rcx
movl $0xff, %edx
movq %rcx, -0x10(%rcx)
movl $0x0, -0x20(%rcx)
addq $0x28, %rcx
decl %edx
jne 0x770dd
movq $0x0, -0x10(%rcx)
movl $0x0, -0x20(%rcx)
movq 0x18(%rax), %rcx
movq %rcx, 0x838(%r15)
movl $0x0, 0x8(%rax)
xorl %ecx, %ecx
movq %rcx, (%rax)
movq %rcx, 0x20(%rax)
movq %rax, 0x18(%r14)
movq (%rax), %rcx
movq %rcx, 0x10(%r14)
movq $0x0, 0x20(%rax)
leaq -0x3c0eb(%rip), %rax    # 0x3b049
movq %rax, 0x20(%r14)
leaq -0x3c099(%rip), %rax    # 0x3b0a6
movq %rax, 0x28(%r14)
movq 0x740(%r15), %r15
movq (%r15), %rax
movq 0x10(%r15), %rsi
cmpq 0x8(%r15), %rsi
jne 0x77172
leaq (%rsi,%rsi), %rcx
movq %rcx, 0x8(%r15)
shlq $0x4, %rsi
movq %rax, %rdi
callq 0x8510
movq %rax, (%r15)
movq 0x10(%r15), %rsi
leaq 0x1(%rsi), %rcx
movq %rcx, 0x10(%r15)
movq %r14, (%rax,%rsi,8)
testq %r12, %r12
jle 0x772ab
movq 0x10(%rbx), %rax
leaq (%rax,%r12,8), %rcx
movq 0x10(%r14), %rdx
leaq (%rdx,%r12,8), %rdx
addq $-0x8, %rdx
movsd (%rax), %xmm0
addq $0x8, %rax
movsd %xmm0, (%rdx)
addq $-0x8, %rdx
cmpq %rcx, %rax
jb 0x7719b
jmp 0x772ab
movq 0x838(%r15), %rax
testq %rax, %rax
jne 0x77200
movl $0x2800, %edi           # imm = 0x2800
callq 0x8480
movq %rax, 0x838(%r15)
movq %rax, %rcx
addq $0x28, %rcx
movl $0xff, %edx
movq %rcx, -0x10(%rcx)
movl $0x0, -0x20(%rcx)
addq $0x28, %rcx
decl %edx
jne 0x771de
movq $0x0, -0x10(%rcx)
movl $0x0, -0x20(%rcx)
movq 0x18(%rax), %rcx
movq %rcx, 0x838(%r15)
movl $0x0, 0x8(%rax)
xorl %ecx, %ecx
movq %rcx, (%rax)
movq %rcx, 0x20(%rax)
movq %rax, 0x18(%r14)
movq (%rax), %rcx
movq %rcx, 0x10(%r14)
movq $0x0, 0x20(%rax)
leaq 0x22600(%rip), %rax     # 0x99835
movq %rax, 0x20(%r14)
leaq 0x2265b(%rip), %rax     # 0x9989b
movq %rax, 0x28(%r14)
movq 0x740(%r15), %r15
movq (%r15), %rax
movq 0x10(%r15), %rsi
cmpq 0x8(%r15), %rsi
jne 0x77273
leaq (%rsi,%rsi), %rcx
movq %rcx, 0x8(%r15)
shlq $0x4, %rsi
movq %rax, %rdi
callq 0x8510
movq %rax, (%r15)
movq 0x10(%r15), %rsi
leaq 0x1(%rsi), %rcx
movq %rcx, 0x10(%r15)
movq %r14, (%rax,%rsi,8)
testq %r12, %r12
jle 0x772ab
movq 0x10(%rbx), %rax
leaq (%rax,%r12,8), %rcx
movq 0x10(%r14), %rdx
leaq (%rdx,%r12,8), %rdx
addq $-0x8, %rdx
movq (%rax), %rsi
addq $0x8, %rax
movq %rsi, (%rdx)
addq $-0x8, %rdx
cmpq %rcx, %rax
jb 0x77298
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq