// File: /workspace/github_c_makefile_star2_O1/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, %r12
movq %rdi, %r14
movq 0x8(%rsi), %rbx
movq %rbx, 0x508(%rdi)
movzbl (%rbx), %eax
leal -0x13(%rax), %ecx
cmpl $0x9, %ecx
ja 0x7c746
leaq 0x944a6(%rip), %rax     # 0x110ba0
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq 0x8(%rbx), %r12
movq 0x10(%rbx), %rbx
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0xf83b
movq %rax, %r15
testq %r12, %r12
jle 0x7cf7d
leaq (%rbx,%r12), %rax
movq 0x10(%r15), %rcx
addq %r12, %rcx
decq %rcx
movb (%rbx), %dl
incq %rbx
movb %dl, (%rcx)
decq %rcx
cmpq %rax, %rbx
jb 0x7c732
jmp 0x7cf7d
cmpl $0x1, %eax
je 0x7cc0e
cmpl $0x2, %eax
jne 0x7c760
movq 0x110(%r14), %r15
jmp 0x7cf7d
movq 0x1480(%r14), %rdx
movq 0xd64a2(%rip), %r8      # 0x152c10
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rcx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x103001
movq 0x8(%rbx), %r12
movq 0x10(%rbx), %rbx
movq %r14, %rdi
movq %r12, %rsi
callq 0x3f2f5
movq %rax, %r15
testq %r12, %r12
jle 0x7cf7d
leaq (%rbx,%r12), %rax
movq 0x10(%r15), %rcx
addq %r12, %rcx
decq %rcx
movb (%rbx), %dl
incq %rbx
movb %dl, (%rcx)
decq %rcx
cmpq %rax, %rbx
jb 0x7c7b7
jmp 0x7cf7d
movq 0x8(%rbx), %r13
leaq 0x1(%r13), %rsi
movq %r14, %rdi
callq 0x38b06
movq %rax, %r15
cmpq $0x0, 0x108(%r14)
jns 0x7c8ae
movq 0xd0(%r14), %rax
movq 0xf0(%r14), %rbp
leaq (,%rbp,2), %rcx
movq %rcx, (%rsp)
movq 0x18(%rax), %rsi
movq %rbp, %r12
shlq $0x4, %r12
movq %r14, %rdi
movq %r12, %rdx
callq 0xae0f
movq $0x0, 0x20(%rax)
movq 0xd0(%r14), %rcx
movq %rax, 0x18(%rcx)
movq (%rax), %rax
movq 0xd0(%r14), %rcx
movq %rax, 0x10(%rcx)
movq 0xd0(%r14), %rax
movq (%rsp), %rcx
movq %rcx, 0x8(%rax)
movq %rcx, 0xf0(%r14)
movq 0xe8(%r14), %rdi
movq %r12, %rsi
callq 0x9510
movq %rax, 0xe8(%r14)
cmpq (%rsp), %rbp
jge 0x7c8ae
movq %rbp, %rax
movq 0xd0(%r14), %rcx
movq 0x140(%r14), %rdx
movq 0x10(%rcx), %rcx
movq %rdx, (%rcx,%rax,8)
movq 0xe8(%r14), %rcx
movq 0x108(%r14), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0x108(%r14)
movq %rax, 0x8(%rcx,%rdx,8)
incq %rax
decq %rbp
jne 0x7c872
movq 0xd0(%r14), %rax
movq 0xe8(%r14), %rcx
movq 0x108(%r14), %rdx
leaq -0x1(%rdx), %rsi
movq %rsi, 0x108(%r14)
movq (%rcx,%rdx,8), %rcx
movq 0x10(%rax), %rax
movq %rcx, (%rsp)
movq %r15, (%rax,%rcx,8)
testq %r13, %r13
js 0x7c919
movq 0x10(%rbx), %rbx
xorl %ebp, %ebp
movq (%rbx,%rbp,8), %r12
testq %r12, %r12
je 0x7c90d
movq (%r12), %rcx
movq 0x20(%r12), %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x38db7
movq 0x18(%r12), %r12
jmp 0x7c8ed
leaq 0x1(%rbp), %rax
cmpq %r13, %rbp
movq %rax, %rbp
jne 0x7c8e9
movq (%rsp), %r8
cmpq %r8, 0xf0(%r14)
jle 0x7cf7d
movq 0xd0(%r14), %rax
movq 0x140(%r14), %rcx
movq 0x10(%rax), %rdx
cmpq %rcx, (%rdx,%r8,8)
je 0x7c960
movq 0xe8(%r14), %rdx
movq 0x108(%r14), %rsi
leaq 0x1(%rsi), %rdi
movq %rdi, 0x108(%r14)
movq %r8, 0x8(%rdx,%rsi,8)
movq 0x10(%rax), %rax
movq %rcx, (%rax,%r8,8)
jmp 0x7cf7d
movb $0x1, %bpl
testb $0x40, 0x3(%rbx)
je 0x7cb8d
cmpb $0x1, 0x24c(%r14)
jne 0x7cb8d
movq %r14, %rdi
movq %rbx, %rsi
callq 0x9a55
movq 0x1480(%r14), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x99ef
cmpq 0x128(%r14), %rax
je 0x7cb8d
movq %rax, %r15
movq %r14, %rdi
movq %r12, %rsi
callq 0x45a8d
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0xbd41
movq %rax, %r15
xorl %ebp, %ebp
jmp 0x7cb8d
movb $0x1, %bpl
testb $0x40, 0x3(%rbx)
je 0x7cbd3
cmpb $0x1, 0x24c(%r14)
jne 0x7cbd3
movq %r14, %rdi
movq %rbx, %rsi
callq 0x9a55
movq 0x1480(%r14), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x99ef
cmpq 0x128(%r14), %rax
je 0x7cbd3
movq %rax, %r15
movq %r14, %rdi
movq %r12, %rsi
callq 0x45a8d
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0xbd41
movq %rax, %r15
xorl %ebp, %ebp
jmp 0x7cbd3
movq 0x8(%rbx), %r12
movq 0x18(%rbx), %rax
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x7cc27
cmpq $0x2, 0x10(%rax)
jl 0x7cc27
movq 0x700(%r14), %rax
movq %rbx, 0x8(%rax)
movq 0x700(%r14), %rsi
movq %r14, %rdi
callq 0x3eb16
movq 0xd61d4(%rip), %rcx     # 0x152c58
movq 0x708(%r14), %rdx
movq %rax, 0x8(%rdx)
movq 0x710(%r14), %rax
movq %rcx, 0x8(%rax)
movq 0x708(%r14), %rsi
movq 0x12d8(%r14), %rdx
movq %r14, %rdi
callq 0x3ed20
movq %rax, %r15
jmp 0x7cde4
movq 0x8(%rbx), %r12
movq 0x18(%rbx), %rax
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x7cc7e
cmpq $0x2, 0x10(%rax)
jl 0x7cc7e
movq 0x700(%r14), %rax
movq %rbx, 0x8(%rax)
movq 0x700(%r14), %rsi
movq %r14, %rdi
callq 0x3eb16
movq 0x700(%r14), %rcx
movq %rax, 0x8(%rcx)
movq 0x700(%r14), %rsi
movq 0x1318(%r14), %rdx
movq %r14, %rdi
callq 0x3ed20
jmp 0x7cc89
movq 0x8(%rbx), %r12
movq 0x18(%rbx), %rax
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x7ccc1
cmpq $0x2, 0x10(%rax)
jl 0x7ccc1
movq 0x700(%r14), %rax
movq %rbx, 0x8(%rax)
movq 0x700(%r14), %rsi
movq %r14, %rdi
callq 0x3eb16
movq 0xd1df7(%rip), %rcx     # 0x14e950
movq 0x708(%r14), %rdx
movq %rax, 0x8(%rdx)
movq 0x710(%r14), %rax
movq %rcx, 0x8(%rax)
movq 0x708(%r14), %rsi
movq 0x12f0(%r14), %rdx
movq %r14, %rdi
callq 0x3ed20
movq %rax, %r15
jmp 0x7cee7
testb %bpl, %bpl
je 0x7cf7d
movq 0x1940(%r14), %r15
movq 0x820(%r14), %rax
movslq 0x7dc(%r14), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%r14)
leaq 0xa7c6a(%rip), %rcx     # 0x12482c
movq %rcx, 0x10(%rax)
movq $0x15, 0x8(%rax)
jmp 0x7cf51
testb %bpl, %bpl
je 0x7cf7d
movq 0x8d8(%r14), %rax
movq 0x8(%rbx), %rcx
movq (%rax,%rcx,8), %rax
movq 0x60(%rax), %rax
testq %rax, %rax
je 0x7cf19
movq %r14, %rdi
movq %r12, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3bf5b
movq 0x90(%r14), %rax
cmpq 0x98(%r14), %rax
ja 0x7cc3f
movq %r14, %rdi
callq 0xb389
movq 0x90(%r14), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%r14)
movq -0x8(%rax), %r15
movq $0x200017, (%r15)       # imm = 0x200017
movq %r12, 0x8(%r15)
leaq (,%r12,8), %rsi
testq %rsi, %rsi
jle 0x7cd18
movq %r14, %rdi
callq 0xa305
jmp 0x7cd80
movq %r14, %rdi
movq %r12, %rsi
callq 0x3e258
movq %rax, %r15
testq %r12, %r12
jle 0x7cf7d
movq 0x10(%rbx), %rax
leaq (%rax,%r12,8), %rcx
movq 0x10(%r15), %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 0x7cca9
jmp 0x7cf7d
movq 0x90(%r14), %rax
cmpq 0x98(%r14), %rax
ja 0x7ccd9
movq %r14, %rdi
callq 0xb389
movq 0x90(%r14), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%r14)
movq -0x8(%rax), %r15
movq $0x200016, (%r15)       # imm = 0x200016
movq %r12, 0x8(%r15)
leaq (,%r12,8), %rsi
testq %rsi, %rsi
jle 0x7ce1b
movq %r14, %rdi
callq 0xa305
jmp 0x7ce83
cmpq $0x0, 0x838(%r14)
jne 0x7cd5e
movl $0x2800, %edi           # imm = 0x2800
callq 0x9480
movq %rax, 0x838(%r14)
addq $0x28, %rax
movl $0xff, %ecx
movq %rax, -0x10(%rax)
movl $0x0, -0x20(%rax)
addq $0x28, %rax
decl %ecx
jne 0x7cd3c
movq $0x0, -0x10(%rax)
movl $0x0, -0x20(%rax)
movq 0x838(%r14), %rax
movq 0x18(%rax), %rcx
movq %rcx, 0x838(%r14)
movl $0x0, 0x8(%rax)
xorl %ecx, %ecx
movq %rcx, (%rax)
movq %rcx, 0x20(%rax)
movq %rax, 0x18(%r15)
movq (%rax), %rcx
movq %rcx, 0x10(%r15)
movq $0x0, 0x20(%rax)
leaq -0x3f7ba(%rip), %rax    # 0x3d5e0
movq %rax, 0x20(%r15)
leaq -0x3f768(%rip), %rax    # 0x3d63d
movq %rax, 0x28(%r15)
movq 0x740(%r14), %r14
movq 0x8(%r14), %rsi
cmpq %rsi, 0x10(%r14)
jne 0x7cdd1
leaq (%rsi,%rsi), %rax
movq %rax, 0x8(%r14)
movq (%r14), %rdi
shlq $0x4, %rsi
callq 0x9510
movq %rax, (%r14)
movq (%r14), %rax
movq 0x10(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x10(%r14)
movq %r15, (%rax,%rcx,8)
testq %r12, %r12
jle 0x7cf7d
movq 0x10(%rbx), %rax
leaq (%rax,%r12,8), %rcx
movq 0x10(%r15), %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 0x7ce01
jmp 0x7cf7d
cmpq $0x0, 0x838(%r14)
jne 0x7ce61
movl $0x2800, %edi           # imm = 0x2800
callq 0x9480
movq %rax, 0x838(%r14)
addq $0x28, %rax
movl $0xff, %ecx
movq %rax, -0x10(%rax)
movl $0x0, -0x20(%rax)
addq $0x28, %rax
decl %ecx
jne 0x7ce3f
movq $0x0, -0x10(%rax)
movl $0x0, -0x20(%rax)
movq 0x838(%r14), %rax
movq 0x18(%rax), %rcx
movq %rcx, 0x838(%r14)
movl $0x0, 0x8(%rax)
xorl %ecx, %ecx
movq %rcx, (%rax)
movq %rcx, 0x20(%rax)
movq %rax, 0x18(%r15)
movq (%rax), %rcx
movq %rcx, 0x10(%r15)
movq $0x0, 0x20(%rax)
leaq 0x23264(%rip), %rax     # 0xa0101
movq %rax, 0x20(%r15)
leaq 0x232bf(%rip), %rax     # 0xa0167
movq %rax, 0x28(%r15)
movq 0x740(%r14), %r14
movq 0x8(%r14), %rsi
cmpq %rsi, 0x10(%r14)
jne 0x7ced4
leaq (%rsi,%rsi), %rax
movq %rax, 0x8(%r14)
movq (%r14), %rdi
shlq $0x4, %rsi
callq 0x9510
movq %rax, (%r14)
movq (%r14), %rax
movq 0x10(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x10(%r14)
movq %r15, (%rax,%rcx,8)
testq %r12, %r12
jle 0x7cf7d
movq 0x10(%rbx), %rax
leaq (%rax,%r12,8), %rcx
movq 0x10(%r15), %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 0x7cf04
jmp 0x7cf7d
movq 0x1918(%r14), %r15
movq 0x820(%r14), %rax
movslq 0x7dc(%r14), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%r14)
leaq 0xa78d0(%rip), %rcx     # 0x124815
movq %rcx, 0x10(%rax)
movq $0x16, 0x8(%rax)
movq 0x6e0(%r14), %rcx
movq %rax, 0x8(%rcx)
movq 0x6e0(%r14), %rax
movq 0x10(%rax), %rax
movq %rbx, 0x8(%rax)
movq 0x6e0(%r14), %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x3b366
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq