// File: /workspace/github_c_makefile_star2_O2/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 %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r12
movq %rdi, %rbx
testq %rdx, %rdx
je 0xbdbb
testq %r12, %r12
je 0xbe39
cmpq %rdx, %r12
jne 0xbe4c
movq 0x109ba2(%rip), %rax    # 0x115958
jmp 0xbe40
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 0xca206(%rip), %rax     # 0xd5fe6
movq %rax, 0x10(%rsi)
movq $0xa, 0x8(%rsi)
movq 0x1f00(%rbx), %rax
movq %r12, 0x8(%rax)
movq 0x1f00(%rbx), %rax
movq 0x109b4b(%rip), %rcx    # 0x115950
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 $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xc1ff
movq 0x109b10(%rip), %rax    # 0x115950
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
cmpq $0x1, %rdx
jne 0xbe6c
cmpq $0x7ff, %r12            # imm = 0x7FF
ja 0xbf22
leaq 0x109aea(%rip), %rax    # 0x115950
movq (%rax,%r12,8), %rax
jmp 0xbe40
movl 0x10dbb6(%rip), %ecx    # 0x119a28
shlq $0x3f, %rcx
cmpq %rdx, %rcx
jne 0xbe96
testb $0x1, %r12b
jne 0xbfa2
sarq %r12
pushq $0x2
popq %rsi
movq %rdx, %rax
cqto
idivq %rsi
movq %rax, %rdx
movq %r12, %r14
negq %r14
movq %rdx, %r15
negq %r15
cmovsq %rdx, %r15
testq %rdx, %rdx
cmovnsq %r12, %r14
cmpq %rcx, %r14
je 0xbef3
movq %r12, %rax
negq %rax
cmovsq %r12, %rax
movq %r15, %rdx
movq %rdx, %rcx
xorl %edx, %edx
divq %rcx
movq %rcx, %rax
testq %rdx, %rdx
jne 0xbebf
cmpq $0x1, %rcx
je 0xbeff
movq %r14, %rax
cqto
idivq %rcx
movq %rax, %r14
movq %r15, %rax
xorl %edx, %edx
divq %rcx
movq %rax, %r15
jmp 0xbeff
sarq %rcx
shrq %r15
movl %ecx, %eax
orl %r15d, %eax
testb $0x1, %al
je 0xbeed
movq %rcx, %r14
cmpq $0x1, %r15
jne 0xbf60
cmpq $0x7ff, %r14            # imm = 0x7FF
ja 0xc00b
leaq 0x109a37(%rip), %rax    # 0x115950
movq (%rax,%r14,8), %rax
jmp 0xbe40
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xbf41
movq %rbx, %rdi
callq 0x9c27
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movq $0xb, (%rax)
movq %r12, 0x8(%rax)
jmp 0xbe40
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xbf7f
movq %rbx, %rdi
callq 0x9c27
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)
jmp 0xbe40
movq %r12, 0x18(%rsp)
fildll 0x18(%rsp)
movq %rdx, 0x20(%rsp)
fildll 0x20(%rsp)
fdivrp %st, %st(1)
fstpl 0x10(%rsp)
movsd 0x10(%rsp), %xmm0
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xbfeb
movq %rbx, %rdi
movsd %xmm0, 0x8(%rsp)
callq 0x9c27
movsd 0x8(%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 0xbe40
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xc02a
movq %rbx, %rdi
callq 0x9c27
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movq $0xb, (%rax)
movq %r14, 0x8(%rax)
jmp 0xbe40