// File: /workspace/github_c_makefile_star2_O1/BernardTatin[P]s7sh/s7.c
// Function: s7_make_ratio
s7_pointer s7_make_ratio(s7_scheme *sc, s7_int a, s7_int b)
    {
        s7_pointer x;
        if (b == 0)
            return(division_by_zero_error(sc, wrap_string(sc, "make-ratio", 10), set_elist_2(sc, wrap_integer1(sc, a), small_int(0))));
        if (a == 0)
            return(small_int(0));
        if (a == b)
            return(small_int(1));
        if (b == 1)
            return(make_integer(sc, a));

#if (!WITH_GMP)
        if (b == s7_int_min)
        {
            /* we've got a problem... This should not trigger an error during reading -- we might have the
             *   ratio on a switch with-bignums or whatever, so its mere occurrence is just an annoyance.
             */
            if (a & 1)
                return(make_real(sc, (long double)a / (long double)b));
            a /= 2;
            b /= 2;
        }
#endif

        if (b < 0)
        {
            a = -a;
            b = -b;
        }

        if (a == s7_int_min)
        {
            while (((a & 1) == 0) && ((b & 1) == 0))
            {
                a /= 2;
                b /= 2;
            }
        }
        else
        {
            s7_int b1, divisor;
            divisor = s7_int_abs(a);
            b1 = b;
            do {
                s7_int temp;
                temp = divisor % b1;
                divisor = b1;
                b1 = temp;
            } while (b1 != 0);
            if (divisor != 1)
            {
                a /= divisor;
                b /= divisor;
            }
        }
        if (b == 1)
            return(make_integer(sc, a));

        new_cell(sc, x, T_RATIO);
        numerator(x) = a;
        denominator(x) = b;
        return(x);
    }

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rsi, %r14
movq %rdi, %rbx
testq %rdx, %rdx
je 0xddb1
testq %r14, %r14
je 0xde2d
cmpq %rdx, %r14
jne 0xde39
movq 0x140bac(%rip), %rax    # 0x14e958
jmp 0xdfee
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rsi
leal 0x1(%rcx), %eax
andl $0x7, %eax
movl %eax, 0x7dc(%rbx)
leaq 0x105160(%rip), %rax    # 0x112f36
movq %rax, 0x10(%rsi)
movq $0xa, 0x8(%rsi)
movq 0x1f00(%rbx), %rax
movq %r14, 0x8(%rax)
movq 0x1f00(%rbx), %rax
movq 0x140b55(%rip), %rcx    # 0x14e950
movq 0x6e0(%rbx), %rdx
movq %rax, 0x8(%rdx)
movq 0x6e0(%rbx), %rax
movq 0x10(%rax), %rax
movq %rcx, 0x8(%rax)
movq 0x6e0(%rbx), %rdx
movq %rbx, %rdi
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
jmp 0xe1ae
movq 0x140b1c(%rip), %rax    # 0x14e950
jmp 0xdfee
cmpq $0x1, %rdx
je 0xdf60
movl 0x144bdf(%rip), %eax    # 0x152a28
shlq $0x3f, %rax
cmpq %rdx, %rax
jne 0xde6f
testb $0x1, %r14b
jne 0xdedd
sarq %r14
movq %rdx, %rcx
shrq $0x3f, %rcx
addq %rdx, %rcx
sarq %rcx
movq %rcx, %rdx
movq %r14, %rsi
negq %rsi
movq %rdx, %rcx
negq %rcx
cmovsq %rdx, %rcx
testq %rdx, %rdx
cmovnsq %r14, %rsi
cmpq %rax, %rsi
jne 0xdeb2
movl %esi, %eax
orl %ecx, %eax
testb $0x1, %al
jne 0xded5
movq %rsi, %r14
movq %rcx, %r15
sarq %r14
shrq %r15
orl %ecx, %esi
movq %r15, %rcx
testb $0x2, %sil
movq %r14, %rsi
je 0xde99
jmp 0xdf5a
movq %r14, %rax
negq %rax
cmovsq %r14, %rax
movq %rcx, %rdx
movq %rdx, %rdi
xorl %edx, %edx
divq %rdi
movq %rdi, %rax
testq %rdx, %rdx
jne 0xdebf
cmpq $0x1, %rdi
jne 0xdf44
movq %rcx, %r15
movq %rsi, %r14
jmp 0xdf5a
movq %r14, 0x10(%rsp)
fildll 0x10(%rsp)
movq %rdx, 0x18(%rsp)
fildll 0x18(%rsp)
fdivrp %st, %st(1)
fstpl 0x8(%rsp)
movsd 0x8(%rsp), %xmm0
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xdf1d
movq %rbx, %rdi
movsd %xmm0, (%rsp)
callq 0xb389
movsd (%rsp), %xmm0
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movq $0xd, (%rax)
movsd %xmm0, 0x8(%rax)
jmp 0xdfee
movq %rsi, %rax
cqto
idivq %rdi
movq %rax, %r14
movq %rcx, %rax
xorl %edx, %edx
divq %rdi
movq %rax, %r15
cmpq $0x1, %r15
jne 0xdfb1
cmpq $0x7ff, %r14            # imm = 0x7FF
ja 0xdf76
leaq 0x1409e0(%rip), %rax    # 0x14e950
movq (%rax,%r14,8), %rax
jmp 0xdfee
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xdf8e
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movq $0xb, (%rax)
movq %r14, 0x8(%rax)
jmp 0xdfee
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xdfc9
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movq $0xc, (%rax)
movq %r14, 0x8(%rax)
movq %r15, 0x10(%rax)
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq