// File: /workspace/github_c_makefile_star2_O2/BernardTatin[P]s7sh/s7.c
// Function: g_less_or_equal
static s7_pointer g_less_or_equal(s7_scheme *sc, s7_pointer args)
    {
#define H_less_or_equal "(<= x1 ...) returns #t if its arguments are in increasing order"
#define Q_less_or_equal s7_make_circular_signature(sc, 1, 2, sc->is_boolean_symbol, sc->is_real_symbol)

        s7_pointer x, y, p;

        x = car(args);
        p = cdr(args);

        switch (type(x))
        {
            case T_INTEGER:
INTEGER_LEQ:
                y = car(p);
                p = cdr(p);
                switch (type(y))
                {
                    case T_INTEGER:
                        if (integer(x) > integer(y)) goto NOT_LEQ;
                        if (is_null(p)) return(sc->T);
                        x = y;
                        goto INTEGER_LEQ;

                    case T_RATIO:
                        /* no gmp here, but this can overflow: (< 9223372036 1/9223372036), but conversion to real is also problematic
                        */
                        if ((integer(x) >= 0) && (numerator(y) < 0)) goto NOT_LEQ;  /* (< 1 -1/2), ratio numerator can't be 0 */
                        if ((integer(x) <= 0) && (numerator(y) > 0))                 /* (< 0 1/2) */
                        {
                            if (is_null(p)) return(sc->T);
                            x = y;
                            goto RATIO_LEQ;
                        }
                        if ((integer(x) < s7_int32_max) &&
                                (integer(x) > s7_int32_min) &&
                                (denominator(y) < s7_int32_max))
                        {
                            if ((integer(x) * denominator(y)) > numerator(y)) goto NOT_LEQ;
                        }
                        else
                        {
                            if (integer(x) > fraction(y)) goto NOT_LEQ;
                        }
                        if (is_null(p)) return(sc->T);
                        x = y;
                        goto RATIO_LEQ;

                    case T_REAL:
                        if (is_NaN(real(y))) goto NOT_LEQ;
                        if (integer(x) > real(y)) goto NOT_LEQ;
                        if (is_null(p)) return(sc->T);
                        x = y;
                        goto REAL_LEQ;

                    default:
                        return(method_or_bust(sc, y, sc->leq_symbol, cons_unchecked(sc, x, cons(sc, y, p)), T_REAL, position_of(p, args) - 1));
                }

            case T_RATIO:
RATIO_LEQ:
                y = car(p);
                p = cdr(p);
                switch (type(y))
                {
                    case T_INTEGER:
                        if ((numerator(x) > 0) && (integer(y) <= 0)) goto NOT_LEQ;
                        if ((numerator(x) < 0) && (integer(y) >= 0))
                        {
                            if (is_null(p)) return(sc->T);
                            x = y;
                            goto INTEGER_LEQ;
                        }
                        if ((integer(y) < s7_int32_max) &&
                                (integer(y) > s7_int32_min) &&
                                (denominator(x) < s7_int32_max))
                        {
                            if (numerator(x) > (integer(y) * denominator(x))) goto NOT_LEQ;
                        }
                        else
                        {
                            if (fraction(x) > integer(y)) goto NOT_LEQ;
                        }
                        if (is_null(p)) return(sc->T);
                        x = y;
                        goto INTEGER_LEQ;

                    case T_RATIO:
                        {
                            s7_int d1, d2, n1, n2;
                            d1 = denominator(x);
                            n1 = numerator(x);
                            d2 = denominator(y);
                            n2 = numerator(y);
                            if (d1 == d2)
                            {
                                if (n1 > n2) goto NOT_LEQ;
                            }
                            else
                            {
#if HAVE_OVERFLOW_CHECKS
                                if ((multiply_overflow(n1, d2, &n1)) ||
                                        (multiply_overflow(n2, d1, &n2)))
                                {
                                    if (fraction(x) > fraction(y)) goto NOT_LEQ;
                                }
                                else
                                {
                                    if (n1 > n2) goto NOT_LEQ;
                                }
#else
                                if ((n1 * d2) >  (n2 * d1)) goto NOT_LEQ;
#endif
                            }
                        }
                        if (is_null(p)) return(sc->T);
                        x = y;
                        goto RATIO_LEQ;

                    case T_REAL:
                        if (is_NaN(real(y))) goto NOT_LEQ;
                        if (fraction(x) > real(y)) goto NOT_LEQ;
                        if (is_null(p)) return(sc->T);
                        x = y;
                        goto REAL_LEQ;

                    default:
                        return(method_or_bust(sc, y, sc->leq_symbol, cons_unchecked(sc, x, cons(sc, y, p)), T_REAL, position_of(p, args) - 1));
                }

            case T_REAL:
                if (is_NaN(real(x))) goto NOT_LEQ;

REAL_LEQ:
                y = car(p);
                p = cdr(p);
                switch (type(y))
                {
                    case T_INTEGER:
                        if (real(x) > integer(y)) goto NOT_LEQ;
                        if (is_null(p)) return(sc->T);
                        x = y;
                        goto INTEGER_LEQ;

                    case T_RATIO:
                        if (real(x) > fraction(y)) goto NOT_LEQ;
                        if (is_null(p)) return(sc->T);
                        x = y;
                        goto RATIO_LEQ;

                    case T_REAL:
                        if (is_NaN(real(y))) goto NOT_LEQ;
                        if (real(x) > real(y)) goto NOT_LEQ;
                        if (is_null(p)) return(sc->T);
                        x = y;
                        goto REAL_LEQ;

                    default:
                        return(method_or_bust(sc, y, sc->leq_symbol, cons_unchecked(sc, x, cons(sc, y, p)), T_REAL, position_of(p, args) - 1));
                }

            default:
                return(method_or_bust(sc, x, sc->leq_symbol, args, T_REAL, 1));
        }

NOT_LEQ:
        for (; is_pair(p); p = cdr(p))
            if (!is_real_via_method(sc, car(p)))
                return(wrong_type_argument(sc, sc->leq_symbol, position_of(p, args), car(p), T_REAL));

        return(sc->F);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, %rbp
movq %rdi, %rbx
movq 0x8(%rsi), %r15
movq 0x10(%rsi), %r14
movzbl (%r15), %eax
cmpl $0xd, %eax
je 0x5895d
cmpl $0xc, %eax
je 0x58cd1
cmpl $0xb, %eax
je 0x5896e
movq 0x1220(%rbx), %rdx
pushq $0xd
popq %r8
pushq $0x1
popq %r9
movq %rbx, %rdi
movq %r15, %rsi
jmp 0x58ae8
movsd 0x8(%r15), %xmm0
ucomisd %xmm0, %xmm0
jnp 0x589e0
jmp 0x58bd9
movq %r15, %r13
movq 0x8(%r14), %r15
movq 0x10(%r14), %r14
movzbl (%r15), %eax
cmpl $0xb, %eax
jne 0x589a1
movq 0x8(%r13), %rax
cmpq 0x8(%r15), %rax
jg 0x58bd9
movq %r15, %r13
cmpq 0x110(%rbx), %r14
jne 0x58971
jmp 0x58bd0
cmpl $0xc, %eax
je 0x58b01
cmpl $0xd, %eax
jne 0x58a5b
movsd 0x8(%r15), %xmm0
ucomisd %xmm0, %xmm0
jp 0x58bd9
cvtsi2sdq 0x8(%r13), %xmm1
ucomisd %xmm0, %xmm1
ja 0x58bd9
cmpq 0x110(%rbx), %r14
je 0x58bd0
movq %r15, %r13
movq 0x8(%r14), %r15
movq 0x10(%r14), %r14
movzbl (%r15), %eax
cmpl $0xd, %eax
jne 0x58a25
movsd 0x8(%r15), %xmm0
ucomisd %xmm0, %xmm0
jp 0x58bd9
movsd 0x8(%r13), %xmm1
ucomisd %xmm0, %xmm1
ja 0x58bd9
movq %r15, %r13
cmpq 0x110(%rbx), %r14
jne 0x589e3
jmp 0x58bd0
cmpl $0xc, %eax
je 0x58b2e
cmpl $0xb, %eax
jne 0x58a5b
movsd 0x8(%r13), %xmm0
cvtsi2sdq 0x8(%r15), %xmm1
ucomisd %xmm1, %xmm0
ja 0x58bd9
cmpq 0x110(%rbx), %r14
jne 0x5896e
jmp 0x58bd0
movq %rbp, %r12
movq 0x1220(%rbx), %rax
movq %rax, 0x8(%rsp)
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x58a89
movq %rbx, %rdi
callq 0x9c27
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movl $0x200001, %ecx         # imm = 0x200001
movq %rcx, (%rax)
movq %r15, 0x8(%rax)
movq %r14, 0x10(%rax)
movq 0x90(%rbx), %rdx
leaq -0x8(%rdx), %rsi
movq %rsi, 0x90(%rbx)
movq -0x8(%rdx), %rbp
movq %rcx, (%rbp)
movq %r13, 0x8(%rbp)
movq %rax, 0x10(%rbp)
movq %r14, %rdi
movq %r12, %rsi
callq 0x72a82
leal -0x1(%rax), %r9d
pushq $0xd
popq %r8
movq %rbx, %rdi
movq %r15, %rsi
movq 0x8(%rsp), %rdx
movq %rbp, %rcx
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xcd70
movq 0x8(%r13), %rcx
movq 0x8(%r15), %rax
testq %rcx, %rcx
js 0x58b51
testq %rax, %rax
js 0x58bd9
testq %rcx, %rcx
sete %dl
testq %rax, %rax
setne %sil
testb %sil, %dl
je 0x58b5a
jmp 0x58cc4
fldl 0x8(%r13)
movq 0x8(%r15), %rax
movq 0x10(%r15), %rcx
movq %rax, 0x50(%rsp)
fildll 0x50(%rsp)
movq %rcx, 0x48(%rsp)
fildll 0x48(%rsp)
jmp 0x58d3e
testq %rax, %rax
jg 0x58cc4
xorl %esi, %esi
cmpb $0x0, 0xcb881(%rip)     # 0x1243e4
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
cmoveq %rsi, %rdx
cmpq %rdx, %rcx
jge 0x58ba6
movb 0xcb8ec(%rip), %sil     # 0x124464
notb %sil
movzbl %sil, %esi
shll $0x1f, %esi
addq $-0x80000000, %rsi      # imm = 0x80000000
cmpq %rsi, %rcx
jle 0x58ba6
movq 0x10(%r15), %rsi
cmpq %rdx, %rsi
jge 0x58ba6
imulq %rcx, %rsi
cmpq %rax, %rsi
jle 0x58cc4
jmp 0x58bd9
movq %rcx, 0x70(%rsp)
fildll 0x70(%rsp)
movq %rax, 0x78(%rsp)
fildll 0x78(%rsp)
movq 0x10(%r15), %rax
movq %rax, 0x80(%rsp)
fildll 0x80(%rsp)
jmp 0x58d3e
movq 0x118(%rbx), %rax
jmp 0x58c4b
leaq 0xc0dd0(%rip), %r15     # 0x1199b0
cmpb $0x1, (%r14)
jne 0x58c44
movq 0x8(%r14), %rsi
movzbl (%rsi), %eax
cmpb $0x0, (%rax,%r15)
jne 0x58c0f
testb $0x40, 0x3(%rsi)
je 0x58c15
cmpb $0x1, 0x24c(%rbx)
jne 0x58c15
movq %rbx, %rdi
callq 0xc9141
testb %al, %al
je 0x58c15
movq 0x10(%r14), %r14
jmp 0x58be0
movq 0x1220(%rbx), %rax
movq 0x8(%rax), %r12
movq %r14, %rdi
movq %rbp, %rsi
callq 0x72a82
movslq %eax, %r15
cmpl $0x7ff, %r15d           # imm = 0x7FF
ja 0x58c5d
leaq 0xbcd12(%rip), %rax     # 0x115950
movq (%rax,%r15,8), %rdx
jmp 0x58c96
movq 0x120(%rbx), %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x58c7c
movq %rbx, %rdi
callq 0x9c27
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rdx
movq $0xb, (%rdx)
movq %r15, 0x8(%rdx)
movq 0x8(%r14), %rcx
movq 0x140(%rbx), %r8
movq 0xc0e20(%rip), %r9      # 0x119ac8
movq %rbx, %rdi
movq %r12, %rsi
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9bbb
cmpq 0x110(%rbx), %r14
je 0x58bd0
movq %r15, %r12
movq 0x8(%r14), %r15
movq 0x10(%r14), %r14
movzbl (%r15), %eax
cmpl $0xc, %eax
jne 0x58d5f
movq 0x8(%r12), %rdx
movq 0x10(%r12), %rsi
movq 0x8(%r15), %rax
movq 0x10(%r15), %rcx
cmpq %rcx, %rsi
jne 0x58d06
cmpq %rax, %rdx
jle 0x58cc4
jmp 0x58bd9
movq %rdx, %rdi
imulq %rcx, %rdi
jo 0x58d18
movq %rax, %r8
imulq %rsi, %r8
jno 0x58d51
movq %rdx, 0x28(%rsp)
fildll 0x28(%rsp)
movq %rsi, 0x30(%rsp)
fildll 0x30(%rsp)
fdivrp %st, %st(1)
movq %rax, 0x38(%rsp)
fildll 0x38(%rsp)
movq %rcx, 0x40(%rsp)
fildll 0x40(%rsp)
fdivrp %st, %st(1)
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
jbe 0x58cc4
jmp 0x58bd9
cmpq %r8, %rdi
jle 0x58cc4
jmp 0x58bd9
cmpl $0xd, %eax
je 0x58d89
cmpl $0xb, %eax
jne 0x58dd2
movq 0x8(%r12), %rax
testq %rax, %rax
jle 0x58e4c
movq 0x8(%r15), %rcx
testq %rcx, %rcx
jg 0x58e67
jmp 0x58bd9
movsd 0x8(%r15), %xmm0
ucomisd %xmm0, %xmm0
jp 0x58bd9
movq 0x8(%r12), %rax
movq 0x10(%r12), %rcx
movq %rax, 0x68(%rsp)
fildll 0x68(%rsp)
movq %rcx, 0x60(%rsp)
fildll 0x60(%rsp)
fdivrp %st, %st(1)
movsd %xmm0, 0x58(%rsp)
fldl 0x58(%rsp)
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
jbe 0x589d3
jmp 0x58bd9
movq %rbp, %r13
movq 0x1220(%rbx), %rax
movq %rax, 0x8(%rsp)
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x58e00
movq %rbx, %rdi
callq 0x9c27
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movl $0x200001, %ecx         # imm = 0x200001
movq %rcx, (%rax)
movq %r15, 0x8(%rax)
movq %r14, 0x10(%rax)
movq 0x90(%rbx), %rdx
leaq -0x8(%rdx), %rsi
movq %rsi, 0x90(%rbx)
movq -0x8(%rdx), %rbp
movq %rcx, (%rbp)
movq %r12, 0x8(%rbp)
movq %rax, 0x10(%rbp)
movq %r14, %rdi
movq %r13, %rsi
jmp 0x58ad0
setne %dl
movq 0x8(%r15), %rcx
testq %rcx, %rcx
setns %sil
andb %dl, %sil
cmpb $0x1, %sil
je 0x58a49
xorl %esi, %esi
cmpb $0x0, 0xcb574(%rip)     # 0x1243e4
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
cmoveq %rsi, %rdx
cmpq %rdx, %rcx
jge 0x58eb7
movb 0xcb5df(%rip), %sil     # 0x124464
notb %sil
movzbl %sil, %esi
shll $0x1f, %esi
addq $-0x80000000, %rsi      # imm = 0x80000000
cmpq %rsi, %rcx
jle 0x58eb7
movq 0x10(%r12), %rsi
cmpq %rdx, %rsi
jge 0x58eb7
imulq %rcx, %rsi
cmpq %rsi, %rax
jle 0x58a49
jmp 0x58bd9
movq %rax, 0x10(%rsp)
fildll 0x10(%rsp)
movq 0x10(%r12), %rax
movq %rax, 0x20(%rsp)
fildll 0x20(%rsp)
fdivrp %st, %st(1)
movq %rcx, 0x18(%rsp)
fildll 0x18(%rsp)
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
jbe 0x58a49
jmp 0x58bd9