// File: /workspace/github_c_makefile_star2_O0/BernardTatin[P]s7sh/s7.c
// Function: g_gcd
static s7_pointer g_gcd(s7_scheme *sc, s7_pointer args)
    {
#define H_gcd "(gcd ...) returns the greatest common divisor of its rational arguments"
#define Q_gcd sc->pcl_f
        s7_int n = 0, d = 1;
        s7_pointer p;

        if (!is_pair(args))
            return(small_int(0));

        if (!is_pair(cdr(args)))
        {
            if (!is_rational(car(args)))
                return(method_or_bust_with_type(sc, car(args), sc->gcd_symbol, args, a_rational_string, 1));
            return(g_abs(sc, args));
        }

        for (p = args; is_pair(p); p = cdr(p))
        {
            s7_pointer x;
            s7_int b;
            x = car(p);
            switch (type(x))
            {
                case T_INTEGER:
                    n = c_gcd(n, integer(x));
                    break;

                case T_RATIO:
                    n = c_gcd(n, s7_numerator(x));
                    b = s7_denominator(x);
                    if (b < 0) b = -b;
                    d = (d / c_gcd(d, b)) * b;
                    if (d < 0) return(simple_out_of_range(sc, sc->gcd_symbol, args, result_is_too_large_string));
                    break;

                default:
                    return(method_or_bust_with_type(sc, x, sc->gcd_symbol, cons(sc, (d <= 1) ? make_integer(sc, n) : s7_make_ratio(sc, n, d), p),
                                a_rational_string, position_of(p, args)));
            }
            if (n < 0) return(simple_out_of_range(sc, sc->gcd_symbol, args, result_is_too_large_string));
        }

        if (d <= 1)
            return(make_integer(sc, n));
        return(make_simple_ratio(sc, n, d));
    }

// Assembly:
subq $0xf8, %rsp
movq %rdi, 0xe8(%rsp)
movq %rsi, 0xe0(%rsp)
movq $0x0, 0xd8(%rsp)
movq $0x1, 0xd0(%rsp)
movq 0xe0(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x1, %eax
je 0x79893
movq 0x19cbfa(%rip), %rax    # 0x216480
movq %rax, 0xf0(%rsp)
jmp 0x79e6f
movq 0xe0(%rsp), %rax
movq 0x10(%rax), %rax
movzbl (%rax), %eax
cmpl $0x1, %eax
je 0x79935
movq 0xe0(%rsp), %rax
movq 0x8(%rax), %rax
movzbl (%rax), %eax
movl %eax, %ecx
leaq 0x1a0c5d(%rip), %rax    # 0x21a520
testb $0x1, (%rax,%rcx)
jne 0x79913
movq 0xe8(%rsp), %rdi
movq 0xe0(%rsp), %rax
movq 0x8(%rax), %rsi
movq 0xe8(%rsp), %rax
movq 0xf38(%rax), %rdx
movq 0xe0(%rsp), %rcx
movq 0x1ab8ad(%rip), %r8     # 0x2251a8
movl $0x1, %r9d
callq 0x14130
movq %rax, 0xf0(%rsp)
jmp 0x79e6f
movq 0xe8(%rsp), %rdi
movq 0xe0(%rsp), %rsi
callq 0x722b0
movq %rax, 0xf0(%rsp)
jmp 0x79e6f
movq 0xe0(%rsp), %rax
movq %rax, 0xc8(%rsp)
movq 0xc8(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x1, %eax
jne 0x79d6a
movq 0xc8(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0xc0(%rsp)
movq 0xc0(%rsp), %rax
movzbl (%rax), %eax
movl %eax, 0x54(%rsp)
subl $0xb, %eax
je 0x79991
jmp 0x79983
movl 0x54(%rsp), %eax
subl $0xc, %eax
je 0x799b7
jmp 0x79aa4
movq 0xd8(%rsp), %rdi
movq 0xc0(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0x1bc3f0
movq %rax, 0xd8(%rsp)
jmp 0x79d08
movq 0xd8(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x12830
movq 0x48(%rsp), %rdi
movq %rax, %rsi
callq 0x1bc3f0
movq %rax, 0xd8(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x12890
movq %rax, 0xb8(%rsp)
cmpq $0x0, 0xb8(%rsp)
jge 0x79a18
xorl %eax, %eax
subq 0xb8(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0xd0(%rsp), %rdi
movq 0xb8(%rsp), %rsi
callq 0x1bc3f0
movq %rax, %rcx
movq 0x40(%rsp), %rax
cqto
idivq %rcx
imulq 0xb8(%rsp), %rax
movq %rax, 0xd0(%rsp)
cmpq $0x0, 0xd0(%rsp)
jge 0x79a9f
movq 0xe8(%rsp), %rdi
movq 0xe8(%rsp), %rax
movq 0xf38(%rax), %rax
movq 0x8(%rax), %rsi
movq 0xe0(%rsp), %rdx
movq 0x1ab75b(%rip), %rcx    # 0x2251e8
callq 0x45240
movq %rax, 0xf0(%rsp)
jmp 0x79e6f
jmp 0x79d08
movq 0xe8(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0xc0(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0xe8(%rsp), %rax
movq 0xf38(%rax), %rax
movq %rax, 0x38(%rsp)
cmpq $0x1, 0xd0(%rsp)
jg 0x79bd6
movq 0xd8(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0x98(%rsp), %rax
andq $-0x800, %rax           # imm = 0xF800
cmpq $0x0, %rax
jne 0x79b22
movq 0x98(%rsp), %rcx
leaq 0x19c96c(%rip), %rax    # 0x216480
movq (%rax,%rcx,8), %rax
movq %rax, 0x20(%rsp)
jmp 0x79bba
jmp 0x79b24
movq 0xe8(%rsp), %rax
movq 0x90(%rax), %rax
movq 0xe8(%rsp), %rcx
cmpq 0x98(%rcx), %rax
ja 0x79b51
movq 0xe8(%rsp), %rdi
callq 0xc670
movq 0xe8(%rsp), %rcx
movq 0x90(%rcx), %rax
movq %rax, %rdx
addq $-0x8, %rdx
movq %rdx, 0x90(%rcx)
movq -0x8(%rax), %rax
movq %rax, 0x88(%rsp)
movq 0x88(%rsp), %rax
movq $0xb, (%rax)
movq 0x98(%rsp), %rcx
movq 0x88(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x88(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x80(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0x18(%rsp)
jmp 0x79bf8
movq 0xe8(%rsp), %rdi
movq 0xd8(%rsp), %rsi
movq 0xd0(%rsp), %rdx
callq 0x11a80
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq 0xc8(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq 0xe8(%rsp), %rax
movq 0x90(%rax), %rax
movq 0xe8(%rsp), %rcx
cmpq 0x98(%rcx), %rax
ja 0x79c42
movq 0xe8(%rsp), %rdi
callq 0xc670
movq 0xe8(%rsp), %rcx
movq 0x90(%rcx), %rax
movq %rax, %rdx
addq $-0x8, %rdx
movq %rdx, 0x90(%rcx)
movq -0x8(%rax), %rax
movq %rax, 0xb0(%rsp)
movq 0xb0(%rsp), %rax
movq $0x200001, (%rax)       # imm = 0x200001
movq 0xa8(%rsp), %rcx
movq 0xb0(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0xa0(%rsp), %rcx
movq 0xb0(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0xb0(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x1ab4e8(%rip), %rax    # 0x2251a8
movq %rax, 0x10(%rsp)
movq 0xc8(%rsp), %rdi
movq 0xe0(%rsp), %rsi
callq 0xc5450
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %r8
movl %eax, %r9d
callq 0x14130
movq %rax, 0xf0(%rsp)
jmp 0x79e6f
cmpq $0x0, 0xd8(%rsp)
jge 0x79d4f
movq 0xe8(%rsp), %rdi
movq 0xe8(%rsp), %rax
movq 0xf38(%rax), %rax
movq 0x8(%rax), %rsi
movq 0xe0(%rsp), %rdx
movq 0x1ab4ab(%rip), %rcx    # 0x2251e8
callq 0x45240
movq %rax, 0xf0(%rsp)
jmp 0x79e6f
jmp 0x79d51
movq 0xc8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0xc8(%rsp)
jmp 0x79945
cmpq $0x1, 0xd0(%rsp)
jg 0x79e4a
movq 0xd8(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x70(%rsp), %rax
andq $-0x800, %rax           # imm = 0xF800
cmpq $0x0, %rax
jne 0x79db0
movq 0x70(%rsp), %rcx
leaq 0x19c6dd(%rip), %rax    # 0x216480
movq (%rax,%rcx,8), %rax
movq %rax, (%rsp)
jmp 0x79e32
jmp 0x79db2
movq 0xe8(%rsp), %rax
movq 0x90(%rax), %rax
movq 0xe8(%rsp), %rcx
cmpq 0x98(%rcx), %rax
ja 0x79ddf
movq 0xe8(%rsp), %rdi
callq 0xc670
movq 0xe8(%rsp), %rcx
movq 0x90(%rcx), %rax
movq %rax, %rdx
addq $-0x8, %rdx
movq %rdx, 0x90(%rcx)
movq -0x8(%rax), %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rax
movq $0xb, (%rax)
movq 0x70(%rsp), %rcx
movq 0x60(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x60(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rax
movq %rax, (%rsp)
movq (%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0xf0(%rsp)
jmp 0x79e6f
movq 0xe8(%rsp), %rdi
movq 0xd8(%rsp), %rsi
movq 0xd0(%rsp), %rdx
callq 0x1bb0a0
movq %rax, 0xf0(%rsp)
movq 0xf0(%rsp), %rax
addq $0xf8, %rsp
retq
nop