// File: /workspace/github_c_makefile_star2_O1/BernardTatin[P]s7sh/s7.c
// Function: g_min
static s7_pointer g_min(s7_scheme *sc, s7_pointer args)
    {
#define H_min "(min ...) returns the minimum of its arguments"
#define Q_min sc->pcl_r

        s7_pointer x, y, p;
        s7_int num_a, num_b, den_a, den_b;

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

        switch (type(x))
        {
            case T_INTEGER:
MIN_INTEGERS:
                if (is_null(p)) return(x);
                y = car(p);
                p = cdr(p);

                switch (type(y))
                {
                    case T_INTEGER:
                        if (integer(x) > integer(y)) x = y;
                        goto MIN_INTEGERS;

                    case T_RATIO:
                        num_a = integer(x);
                        den_a = 1;
                        num_b = numerator(y);
                        den_b = denominator(y);
                        goto RATIO_MIN_RATIO;

                    case T_REAL:
                        if (is_NaN(real(y)))
                            return(nan_with_error_check(sc, y, p, args, sc->min_symbol));
                        if (integer(x) > real(y))
                        {
                            x = y;
                            goto MIN_REALS;
                        }
                        goto MIN_INTEGERS;

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

            case T_RATIO:
MIN_RATIOS:
                if (is_null(p)) return(x);
                y = car(p);
                p = cdr(p);

                switch (type(y))
                {
                    case T_INTEGER:
                        num_a = numerator(x);
                        den_a = denominator(x);
                        num_b = integer(y);
                        den_b = 1;
                        goto RATIO_MIN_RATIO;

                    case T_RATIO:
                        num_a = numerator(x);
                        den_a = denominator(x);
                        num_b = numerator(y);
                        den_b = denominator(y);

RATIO_MIN_RATIO:
                        if ((num_a >= 0) && (num_b < 0))
                            x = y;
                        else
                        {
                            if ((num_a >= 0) || (num_b < 0))
                            {
                                if (den_a == den_b)
                                {
                                    if (num_a > num_b)
                                        x = y;
                                }
                                else
                                {
                                    if (num_a == num_b)
                                    {
                                        if (((num_a >= 0) &&
                                                    (den_a < den_b)) ||
                                                ((num_a < 0) &&
                                                 (den_a > den_b)))
                                            x = y;
                                    }
                                    else
                                    {
                                        s7_int vala, valb;
                                        vala = num_a / den_a;
                                        valb = num_b / den_b;

                                        if (!((vala < valb) ||
                                                    ((vala == valb) && (is_t_integer(x)))))
                                        {
                                            if ((valb < vala) ||
                                                    ((vala == valb) && (is_t_integer(y))) ||
                                                    (((long_double)(num_a % den_a) / (long_double)den_a) >= ((long_double)(num_b % den_b) / (long_double)den_b)))
                                                x = y;
                                        }}}}
                        }
                        if (is_t_ratio(x))
                            goto MIN_RATIOS;
                        goto MIN_INTEGERS;

                    case T_REAL:
                        /* (min 3/4 +nan.0) should probably return NaN */
                        if (is_NaN(real(y)))
                            return(nan_with_error_check(sc, y, p, args, sc->min_symbol));
                        if (fraction(x) > real(y))
                        {
                            x = y;
                            goto MIN_REALS;
                        }
                        goto MIN_RATIOS;

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

            case T_REAL:
                if (is_NaN(real(x)))
                    return(nan_with_error_check(sc, x, p, args, sc->min_symbol));

MIN_REALS:
                if (is_null(p)) return(x);
                y = car(p);
                p = cdr(p);

                switch (type(y))
                {
                    case T_INTEGER:
                        if (real(x) > integer(y))
                        {
                            x = y;
                            goto MIN_INTEGERS;
                        }
                        goto MIN_REALS;

                    case T_RATIO:
                        if (real(x) > fraction(y))
                        {
                            x = y;
                            goto MIN_RATIOS;
                        }
                        goto MIN_REALS;

                    case T_REAL:
                        if (is_NaN(real(y)))
                            return(nan_with_error_check(sc, y, p, args, sc->min_symbol));
                        if (real(x) > real(y)) x = y;
                        goto MIN_REALS;

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

            default:
                return(method_or_bust(sc, x, sc->min_symbol, cons(sc, x, p), T_REAL, 1));
        }
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r15
movq %rdi, %rbx
movq 0x8(%rsi), %r12
movq 0x10(%rsi), %r14
movzbl (%r12), %eax
cmpl $0xd, %eax
je 0x70f39
cmpl $0xc, %eax
je 0x711be
cmpl $0xb, %eax
je 0x70f52
movq 0x1348(%rbx), %r15
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x70efa
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rcx
movq $0x200001, (%rcx)       # imm = 0x200001
movq %r12, 0x8(%rcx)
movq %r14, 0x10(%rcx)
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movl $0xd, %r8d
movl $0x1, %r9d
jmp 0x71087
movsd 0x8(%r12), %xmm0
ucomisd %xmm0, %xmm0
jp 0x711ac
movq %r12, %r13
jmp 0x71220
movq 0x110(%rbx), %rax
cmpq %rax, %r14
je 0x7103d
movq 0x8(%r14), %r13
movq 0x10(%r14), %r14
movzbl (%r13), %ecx
cmpl $0xd, %ecx
jne 0x70f99
movsd 0x8(%r13), %xmm0
ucomisd %xmm0, %xmm0
jp 0x71052
xorps %xmm1, %xmm1
cvtsi2sdq 0x8(%r12), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x70f59
jmp 0x71220
cmpl $0xc, %ecx
je 0x70fb2
cmpl $0xb, %ecx
jne 0x70fc1
movq 0x8(%r12), %rcx
cmpq 0x8(%r13), %rcx
cmovgq %r13, %r12
jmp 0x70f59
movq 0x10(%r13), %r8
movl $0x1, %r9d
jmp 0x7124c
movq 0x1348(%rbx), %rbp
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x70fe0
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movl $0x200001, %edx         # imm = 0x200001
movq %rdx, (%rax)
movq %r13, 0x8(%rax)
movq %r14, 0x10(%rax)
movq 0x90(%rbx), %rcx
leaq -0x8(%rcx), %rsi
movq %rsi, 0x90(%rbx)
movq -0x8(%rcx), %rcx
movq %rdx, (%rcx)
movq %r12, 0x8(%rcx)
movq %rax, 0x10(%rcx)
xorl %r9d, %r9d
cmpq %r15, %r14
je 0x71078
movq 0x10(%r15), %r15
incl %r9d
cmpq %r14, %r15
jne 0x7102f
jmp 0x71078
movq %r12, %r13
movq %r13, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1348(%rbx), %r8
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %r15, %rcx
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x105133
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movl $0xd, %r8d
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xf1ae
cmpq %rax, %r14
je 0x71040
movq 0x8(%r14), %r12
movq 0x10(%r14), %r14
movzbl (%r12), %ecx
cmpl $0xb, %ecx
je 0x710e3
cmpl $0xc, %ecx
jne 0x710fe
fldl 0x8(%r13)
movq 0x8(%r12), %rcx
movq 0x10(%r12), %rdx
movq %rcx, 0x8(%rsp)
fildll 0x8(%rsp)
movq %rdx, (%rsp)
fildll (%rsp)
fdivrp %st, %st(1)
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
jbe 0x7109a
jmp 0x711be
movsd 0x8(%r13), %xmm0
xorps %xmm1, %xmm1
cvtsi2sdq 0x8(%r12), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x7109a
jmp 0x70f52
cmpl $0xd, %ecx
jne 0x71127
movsd 0x8(%r12), %xmm0
ucomisd %xmm0, %xmm0
jp 0x711ac
movsd 0x8(%r13), %xmm1
ucomisd %xmm0, %xmm1
cmovaq %r12, %r13
jmp 0x7109a
movq 0x1348(%rbx), %rbp
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x71146
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movl $0x200001, %edx         # imm = 0x200001
movq %rdx, (%rax)
movq %r12, 0x8(%rax)
movq %r14, 0x10(%rax)
movq 0x90(%rbx), %rcx
leaq -0x8(%rcx), %rsi
movq %rsi, 0x90(%rbx)
movq -0x8(%rcx), %rcx
movq %rdx, (%rcx)
movq %r13, 0x8(%rcx)
movq %rax, 0x10(%rcx)
xorl %r9d, %r9d
cmpq %r15, %r14
je 0x711a1
movq 0x10(%r15), %r15
incl %r9d
cmpq %r14, %r15
jne 0x71195
movq %rbx, %rdi
movq %r12, %rsi
jmp 0x7107e
movq 0x1348(%rbx), %r8
movq %rbx, %rdi
movq %r12, %rsi
jmp 0x7105f
movq 0x110(%rbx), %rax
cmpq %rax, %r14
je 0x7103d
movq 0x8(%r14), %r13
movq 0x10(%r14), %r14
movzbl (%r13), %ecx
cmpl $0xd, %ecx
jne 0x7122c
movsd 0x8(%r13), %xmm0
ucomisd %xmm0, %xmm0
jp 0x71052
movq 0x8(%r12), %rcx
movq 0x10(%r12), %rdx
movq %rcx, 0x20(%rsp)
fildll 0x20(%rsp)
movq %rdx, 0x18(%rsp)
fildll 0x18(%rsp)
fdivrp %st, %st(1)
movsd %xmm0, 0x10(%rsp)
fldl 0x10(%rsp)
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
jbe 0x711c5
movq 0x110(%rbx), %rax
jmp 0x7109a
cmpl $0xc, %ecx
je 0x71243
cmpl $0xb, %ecx
jne 0x7128e
movq 0x10(%r12), %r9
movl $0x1, %r8d
jmp 0x7124c
movq 0x10(%r12), %r9
movq 0x10(%r13), %r8
movq 0x8(%r12), %rax
movq 0x8(%r13), %rsi
testq %rax, %rax
js 0x71264
testq %rsi, %rsi
jns 0x71264
movq %r13, %r12
jmp 0x7127e
testq %rax, %rax
jns 0x7126e
testq %rsi, %rsi
jns 0x7127e
cmpq %r8, %r9
jne 0x71311
cmpq %rsi, %rax
cmovgq %r13, %r12
cmpb $0xc, (%r12)
jne 0x70f52
jmp 0x711be
movq 0x1348(%rbx), %rbp
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x712ad
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movl $0x200001, %edx         # imm = 0x200001
movq %rdx, (%rax)
movq %r13, 0x8(%rax)
movq %r14, 0x10(%rax)
movq 0x90(%rbx), %rcx
leaq -0x8(%rcx), %rsi
movq %rsi, 0x90(%rbx)
movq -0x8(%rcx), %rcx
movq %rdx, (%rcx)
movq %r12, 0x8(%rcx)
movq %rax, 0x10(%rcx)
xorl %r9d, %r9d
cmpq %r15, %r14
je 0x71078
movq 0x10(%r15), %r15
incl %r9d
cmpq %r14, %r15
jne 0x71300
jmp 0x71078
cmpq %rsi, %rax
jne 0x7133b
testq %rax, %rax
js 0x71324
cmpq %r8, %r9
jl 0x7125f
testq %rax, %rax
jns 0x7127e
cmpq %r8, %r9
jg 0x7125f
jmp 0x7127e
cqto
idivq %r9
movq %rdx, %rcx
movq %rax, %rdi
movq %rsi, %rax
cqto
idivq %r8
cmpq %rax, %rdi
jl 0x7127e
jne 0x71364
cmpb $0xb, (%r12)
je 0x7127e
cmpq %rdi, %rax
jl 0x7125f
jne 0x7137a
cmpb $0xb, (%r13)
je 0x7125f
movq %rcx, 0x28(%rsp)
fildll 0x28(%rsp)
movq %r9, 0x30(%rsp)
fildll 0x30(%rsp)
fdivrp %st, %st(1)
movq %rdx, 0x38(%rsp)
fildll 0x38(%rsp)
movq %r8, 0x40(%rsp)
fildll 0x40(%rsp)
fdivrp %st, %st(1)
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
jae 0x7125f
jmp 0x7127e