// File: /workspace/github_c_makefile_star2_O0/BernardTatin[P]s7sh/s7.c
// Function: g_log
static s7_pointer g_log(s7_scheme *sc, s7_pointer args)
    {
#define H_log "(log z1 (z2 e)) returns log(z1) / log(z2) where z2 (the base) defaults to e: (log 8 2) = 3"
#define Q_log sc->pcl_n

        s7_pointer x;
        x = car(args);
        if (!s7_is_number(x))
            return(method_or_bust_with_type(sc, x, sc->log_symbol, args, a_number_string, 1));

        if (is_pair(cdr(args)))
        {
            s7_pointer y;

            y = cadr(args);
            if (!(s7_is_number(y)))
                return(method_or_bust_with_type(sc, y, sc->log_symbol, args, a_number_string, 2));

            if (y == small_int(2))
            {
                /* (define (2^n? x) (and (not (zero? x)) (zero? (logand x (- x 1))))) */
                if (is_t_integer(x))
                {
                    s7_int ix;
                    ix = s7_integer(x);
                    if (ix > 0)
                    {
                        s7_double fx;
#if (__ANDROID__) || (MS_WINDOWS) || ((__GNUC__) && ((__GNUC__ < 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ <= 4))))
                        /* just a guess -- log2 gets a warning in gcc 4.3.2, but not in 4.4.4 */
                        fx = log((double)ix) / log(2.0);
#else
                        fx = log2((double)ix);
#endif
                        /* (s7_int)fx rounds (log 8 2) to 2 in FreeBSD! */
#if ((__GNUC__) && ((__GNUC__ < 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ < 4))))
                        return(make_real(sc, fx));
#else
                        if ((ix & (ix - 1)) == 0)
                            return(make_integer(sc, (s7_int)s7_round(fx)));
                        return(make_real(sc, fx));
#endif
                    }
                }
                if ((s7_is_real(x)) &&
                        (s7_is_positive(x)))
                    return(make_real(sc, log(s7_real(x)) * LOG_2));
                return(s7_from_c_complex(sc, clog(s7_to_c_complex(x)) * LOG_2));
            }

            if ((x == small_int(1)) && (y == small_int(1)))  /* (log 1 1) -> 0 (this is NaN in the bignum case) */
                return(small_int(0));

            /* (log 1 0) must be 0 since everyone says (expt 0 0) is 1 */
            if (s7_is_zero(y))
            {
                if ((y == small_int(0)) &&
                        (x == small_int(1)))
                    return(y);
                return(out_of_range(sc, sc->log_symbol, small_int(2), y, wrap_string(sc, "can't be 0", 10)));
            }

            if (s7_is_one(y))          /* this used to raise an error, but the bignum case is simpler if we return inf */
            {
                if (s7_is_one(x))      /* but (log 1.0 1.0) -> 0.0 */
                    return(real_zero);
                return(real_infinity); /* currently (log 1/0 1) is inf? */
            }

            if ((s7_is_real(x)) &&
                    (s7_is_real(y)) &&
                    (s7_is_positive(x)) &&
                    (s7_is_positive(y)))
            {
                if ((s7_is_rational(x)) &&
                        (s7_is_rational(y)))
                {
                    s7_double res;
                    s7_int ires;
                    res = log(rational_to_double(sc, x)) / log(rational_to_double(sc, y));
                    ires = (s7_int)res;
                    if (res - ires == 0.0)
                        return(make_integer(sc, ires));   /* (log 8 2) -> 3 or (log 1/8 2) -> -3 */
                    return(make_real(sc, res));         /* perhaps use rationalize here? (log 2 8) -> 1/3 */
                }
                return(make_real(sc, log(s7_real(x)) / log(s7_real(y))));
            }
            return(s7_from_c_complex(sc, clog(s7_to_c_complex(x)) / clog(s7_to_c_complex(y))));
        }

        if (s7_is_real(x))
        {
            if (s7_is_positive(x))
                return(make_real(sc, log(s7_real(x))));
            return(s7_make_complex(sc, log(-s7_real(x)), M_PI));
        }
        return(s7_from_c_complex(sc, clog(s7_to_c_complex(x))));
    }

// Assembly:
subq $0x298, %rsp            # imm = 0x298
movq %rdi, 0x288(%rsp)
movq %rsi, 0x280(%rsp)
movq 0x280(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x278(%rsp)
movq 0x278(%rsp), %rdi
callq 0x11320
testb $0x1, %al
jne 0x72ac2
movq 0x288(%rsp), %rdi
movq 0x278(%rsp), %rsi
movq 0x288(%rsp), %rax
movq 0x1290(%rax), %rdx
movq 0x280(%rsp), %rcx
movq 0x1b2446(%rip), %r8     # 0x224ef0
movl $0x1, %r9d
callq 0x14130
movq %rax, 0x290(%rsp)
jmp 0x736ee
movq 0x280(%rsp), %rax
movq 0x10(%rax), %rax
movzbl (%rax), %eax
cmpl $0x1, %eax
jne 0x7353c
movq 0x280(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, 0x270(%rsp)
movq 0x270(%rsp), %rdi
callq 0x11320
testb $0x1, %al
jne 0x72b49
movq 0x288(%rsp), %rdi
movq 0x270(%rsp), %rsi
movq 0x288(%rsp), %rax
movq 0x1290(%rax), %rdx
movq 0x280(%rsp), %rcx
movq 0x1b23bf(%rip), %r8     # 0x224ef0
movl $0x2, %r9d
callq 0x14130
movq %rax, 0x290(%rsp)
jmp 0x736ee
movq 0x270(%rsp), %rax
cmpq 0x1a3938(%rip), %rax    # 0x216490
jne 0x72e67
movq 0x278(%rsp), %rax
movzbl (%rax), %eax
cmpl $0xb, %eax
jne 0x72c88
movq 0x278(%rsp), %rdi
callq 0x10790
movq %rax, 0x268(%rsp)
cmpq $0x0, 0x268(%rsp)
jle 0x72c86
cvtsi2sdq 0x268(%rsp), %xmm0
callq 0x92b0
movsd %xmm0, 0x90(%rsp)
movsd 0x16ee32(%rip), %xmm0   # 0x1e19e8
callq 0x92b0
movaps %xmm0, %xmm1
movsd 0x90(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x260(%rsp)
movsd 0x260(%rsp), %xmm0
movsd %xmm0, 0x250(%rsp)
movq 0x288(%rsp), %rax
movq 0x90(%rax), %rax
movq 0x288(%rsp), %rcx
cmpq 0x98(%rcx), %rax
ja 0x72c13
movq 0x288(%rsp), %rdi
callq 0xc670
movq 0x288(%rsp), %rcx
movq 0x90(%rcx), %rax
movq %rax, %rdx
addq $-0x8, %rdx
movq %rdx, 0x90(%rcx)
movq -0x8(%rax), %rax
movq %rax, 0x258(%rsp)
movq 0x258(%rsp), %rax
movq $0xd, (%rax)
movsd 0x250(%rsp), %xmm0
movq 0x258(%rsp), %rax
movsd %xmm0, 0x8(%rax)
movq 0x258(%rsp), %rax
movq %rax, 0x248(%rsp)
movq 0x248(%rsp), %rax
movq %rax, 0x290(%rsp)
jmp 0x736ee
jmp 0x72c88
movq 0x278(%rsp), %rdi
callq 0x11360
testb $0x1, %al
jne 0x72c9e
jmp 0x72d97
movq 0x278(%rsp), %rdi
callq 0x1bb590
testb $0x1, %al
jne 0x72cb4
jmp 0x72d97
movq 0x278(%rsp), %rdi
callq 0x128d0
callq 0x92b0
movsd %xmm0, 0xa0(%rsp)
fldl 0xa0(%rsp)
fldt 0x16edd4(%rip)          # 0x1e1ab0
fmulp %st, %st(1)
fstpl 0x98(%rsp)
movsd 0x98(%rsp), %xmm0
movsd %xmm0, 0x238(%rsp)
movq 0x288(%rsp), %rax
movq 0x90(%rax), %rax
movq 0x288(%rsp), %rcx
cmpq 0x98(%rcx), %rax
ja 0x72d24
movq 0x288(%rsp), %rdi
callq 0xc670
movq 0x288(%rsp), %rcx
movq 0x90(%rcx), %rax
movq %rax, %rdx
addq $-0x8, %rdx
movq %rdx, 0x90(%rcx)
movq -0x8(%rax), %rax
movq %rax, 0x240(%rsp)
movq 0x240(%rsp), %rax
movq $0xd, (%rax)
movsd 0x238(%rsp), %xmm0
movq 0x240(%rsp), %rax
movsd %xmm0, 0x8(%rax)
movq 0x240(%rsp), %rax
movq %rax, 0x230(%rsp)
movq 0x230(%rsp), %rax
movq %rax, 0x290(%rsp)
jmp 0x736ee
movq 0x288(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x278(%rsp), %rdi
callq 0x1bb600
movsd %xmm0, 0x220(%rsp)
movsd %xmm1, 0x228(%rsp)
movsd 0x220(%rsp), %xmm0
movsd 0x228(%rsp), %xmm1
callq 0x92a0
movq 0x88(%rsp), %rdi
movsd %xmm0, 0xc0(%rsp)
fldl 0xc0(%rsp)
movsd %xmm1, 0xb8(%rsp)
fldl 0xb8(%rsp)
fldt 0x16eca5(%rip)          # 0x1e1ab0
fmul %st, %st(2)
fmulp %st, %st(1)
fxch %st(1)
fstpl 0xb0(%rsp)
movsd 0xb0(%rsp), %xmm1
fstpl 0xa8(%rsp)
movsd 0xa8(%rsp), %xmm0
movsd %xmm1, 0x210(%rsp)
movsd %xmm0, 0x218(%rsp)
movsd 0x210(%rsp), %xmm0
movsd 0x218(%rsp), %xmm1
callq 0x1bb560
movq %rax, 0x290(%rsp)
jmp 0x736ee
movq 0x278(%rsp), %rax
cmpq 0x1a3612(%rip), %rax    # 0x216488
jne 0x72e9d
movq 0x270(%rsp), %rax
cmpq 0x1a3601(%rip), %rax    # 0x216488
jne 0x72e9d
movq 0x1a35f0(%rip), %rax    # 0x216480
movq %rax, 0x290(%rsp)
jmp 0x736ee
movq 0x270(%rsp), %rdi
callq 0x1bb660
testb $0x1, %al
jne 0x72eb3
jmp 0x72f70
movq 0x270(%rsp), %rax
cmpq 0x1a35be(%rip), %rax    # 0x216480
jne 0x72eea
movq 0x278(%rsp), %rax
cmpq 0x1a35b5(%rip), %rax    # 0x216488
jne 0x72eea
movq 0x270(%rsp), %rax
movq %rax, 0x290(%rsp)
jmp 0x736ee
movq 0x288(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x288(%rsp), %rax
movq 0x1290(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, 0x70(%rsp)
movq 0x1a357a(%rip), %rax    # 0x216490
movq %rax, 0x78(%rsp)
movq 0x270(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x288(%rsp), %rdi
leaq 0x180718(%rip), %rsi    # 0x1f3652
movl $0xa, %edx
callq 0xb880
movq 0x68(%rsp), %rdi
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
movq 0x80(%rsp), %rcx
movq %rax, %r8
callq 0x13880
movq %rax, 0x290(%rsp)
jmp 0x736ee
movq 0x270(%rsp), %rdi
callq 0xd5870
testb $0x1, %al
jne 0x72f83
jmp 0x72fbe
movq 0x278(%rsp), %rdi
callq 0xd5870
testb $0x1, %al
jne 0x72f96
jmp 0x72faa
movq 0x1a77eb(%rip), %rax    # 0x21a788
movq %rax, 0x290(%rsp)
jmp 0x736ee
movq 0x1aaa27(%rip), %rax    # 0x21d9d8
movq %rax, 0x290(%rsp)
jmp 0x736ee
movq 0x278(%rsp), %rdi
callq 0x11360
testb $0x1, %al
jne 0x72fd4
jmp 0x73465
movq 0x270(%rsp), %rdi
callq 0x11360
testb $0x1, %al
jne 0x72fea
jmp 0x73465
movq 0x278(%rsp), %rdi
callq 0x1bb590
testb $0x1, %al
jne 0x73000
jmp 0x73465
movq 0x270(%rsp), %rdi
callq 0x1bb590
testb $0x1, %al
jne 0x73016
jmp 0x73465
movq 0x278(%rsp), %rdi
callq 0x11380
testb $0x1, %al
jne 0x7302c
jmp 0x73385
movq 0x270(%rsp), %rdi
callq 0x11380
testb $0x1, %al
jne 0x73042
jmp 0x73385
movq 0x278(%rsp), %rax
movq %rax, 0x1f8(%rsp)
movq 0x1f8(%rsp), %rax
movzbl (%rax), %eax
cmpl $0xb, %eax
jne 0x73086
movq 0x1f8(%rsp), %rax
cvtsi2sdq 0x8(%rax), %xmm0
movsd %xmm0, 0xf0(%rsp)
fldl 0xf0(%rsp)
fstpt 0x5c(%rsp)
jmp 0x730ba
movq 0x1f8(%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x10(%rax), %rax
movq %rcx, 0x100(%rsp)
fildll 0x100(%rsp)
movq %rax, 0xf8(%rsp)
fildll 0xf8(%rsp)
fdivrp %st, %st(1)
fstpt 0x5c(%rsp)
fldt 0x5c(%rsp)
fstpt 0x1e0(%rsp)
fldt 0x1e0(%rsp)
fstpl 0xe8(%rsp)
movsd 0xe8(%rsp), %xmm0
callq 0x92b0
movsd %xmm0, 0x50(%rsp)
movq 0x270(%rsp), %rax
movq %rax, 0x1d8(%rsp)
movq 0x1d8(%rsp), %rax
movzbl (%rax), %eax
cmpl $0xb, %eax
jne 0x7312b
movq 0x1d8(%rsp), %rax
cvtsi2sdq 0x8(%rax), %xmm0
movsd %xmm0, 0xd0(%rsp)
fldl 0xd0(%rsp)
fstpt 0x44(%rsp)
jmp 0x7315f
movq 0x1d8(%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x10(%rax), %rax
movq %rcx, 0xe0(%rsp)
fildll 0xe0(%rsp)
movq %rax, 0xd8(%rsp)
fildll 0xd8(%rsp)
fdivrp %st, %st(1)
fstpt 0x44(%rsp)
fldt 0x44(%rsp)
fstpt 0x1c0(%rsp)
fldt 0x1c0(%rsp)
fstpl 0xc8(%rsp)
movsd 0xc8(%rsp), %xmm0
callq 0x92b0
movaps %xmm0, %xmm1
movsd 0x50(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x208(%rsp)
cvttsd2si 0x208(%rsp), %rax
movq %rax, 0x200(%rsp)
movsd 0x208(%rsp), %xmm0
cvtsi2sdq 0x200(%rsp), %xmm1
subsd %xmm1, %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x732d3
jp 0x732d3
movq 0x200(%rsp), %rax
movq %rax, 0x1b8(%rsp)
movq 0x1b8(%rsp), %rax
andq $-0x800, %rax           # imm = 0xF800
cmpq $0x0, %rax
jne 0x73219
movq 0x1b8(%rsp), %rcx
leaq 0x1a3275(%rip), %rax    # 0x216480
movq (%rax,%rcx,8), %rax
movq %rax, 0x38(%rsp)
jmp 0x732b1
jmp 0x7321b
movq 0x288(%rsp), %rax
movq 0x90(%rax), %rax
movq 0x288(%rsp), %rcx
cmpq 0x98(%rcx), %rax
ja 0x73248
movq 0x288(%rsp), %rdi
callq 0xc670
movq 0x288(%rsp), %rcx
movq 0x90(%rcx), %rax
movq %rax, %rdx
addq $-0x8, %rdx
movq %rdx, 0x90(%rcx)
movq -0x8(%rax), %rax
movq %rax, 0x1a8(%rsp)
movq 0x1a8(%rsp), %rax
movq $0xb, (%rax)
movq 0x1b8(%rsp), %rcx
movq 0x1a8(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x1a8(%rsp), %rax
movq %rax, 0x1a0(%rsp)
movq 0x1a0(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x1b0(%rsp)
movq 0x1b0(%rsp), %rax
movq %rax, 0x290(%rsp)
jmp 0x736ee
movsd 0x208(%rsp), %xmm0
movsd %xmm0, 0x190(%rsp)
movq 0x288(%rsp), %rax
movq 0x90(%rax), %rax
movq 0x288(%rsp), %rcx
cmpq 0x98(%rcx), %rax
ja 0x73312
movq 0x288(%rsp), %rdi
callq 0xc670
movq 0x288(%rsp), %rcx
movq 0x90(%rcx), %rax
movq %rax, %rdx
addq $-0x8, %rdx
movq %rdx, 0x90(%rcx)
movq -0x8(%rax), %rax
movq %rax, 0x198(%rsp)
movq 0x198(%rsp), %rax
movq $0xd, (%rax)
movsd 0x190(%rsp), %xmm0
movq 0x198(%rsp), %rax
movsd %xmm0, 0x8(%rax)
movq 0x198(%rsp), %rax
movq %rax, 0x188(%rsp)
movq 0x188(%rsp), %rax
movq %rax, 0x290(%rsp)
jmp 0x736ee
movq 0x278(%rsp), %rdi
callq 0x128d0
callq 0x92b0
movsd %xmm0, 0x30(%rsp)
movq 0x270(%rsp), %rdi
callq 0x128d0
callq 0x92b0
movaps %xmm0, %xmm1
movsd 0x30(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x178(%rsp)
movq 0x288(%rsp), %rax
movq 0x90(%rax), %rax
movq 0x288(%rsp), %rcx
cmpq 0x98(%rcx), %rax
ja 0x733f2
movq 0x288(%rsp), %rdi
callq 0xc670
movq 0x288(%rsp), %rcx
movq 0x90(%rcx), %rax
movq %rax, %rdx
addq $-0x8, %rdx
movq %rdx, 0x90(%rcx)
movq -0x8(%rax), %rax
movq %rax, 0x180(%rsp)
movq 0x180(%rsp), %rax
movq $0xd, (%rax)
movsd 0x178(%rsp), %xmm0
movq 0x180(%rsp), %rax
movsd %xmm0, 0x8(%rax)
movq 0x180(%rsp), %rax
movq %rax, 0x170(%rsp)
movq 0x170(%rsp), %rax
movq %rax, 0x290(%rsp)
jmp 0x736ee
movq 0x288(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x278(%rsp), %rdi
callq 0x1bb600
movsd %xmm0, 0x160(%rsp)
movsd %xmm1, 0x168(%rsp)
movsd 0x160(%rsp), %xmm0
movsd 0x168(%rsp), %xmm1
callq 0x92a0
movsd %xmm0, 0x18(%rsp)
movsd %xmm1, 0x20(%rsp)
movq 0x270(%rsp), %rdi
callq 0x1bb600
movsd %xmm0, 0x150(%rsp)
movsd %xmm1, 0x158(%rsp)
movsd 0x150(%rsp), %xmm0
movsd 0x158(%rsp), %xmm1
callq 0x92a0
movaps %xmm0, %xmm2
movsd 0x18(%rsp), %xmm0
movaps %xmm1, %xmm3
movsd 0x20(%rsp), %xmm1
callq 0x1dc460
movq 0x28(%rsp), %rdi
movsd %xmm0, 0x140(%rsp)
movsd %xmm1, 0x148(%rsp)
movsd 0x140(%rsp), %xmm0
movsd 0x148(%rsp), %xmm1
callq 0x1bb560
movq %rax, 0x290(%rsp)
jmp 0x736ee
movq 0x278(%rsp), %rdi
callq 0x11360
testb $0x1, %al
jne 0x73552
jmp 0x73675
movq 0x278(%rsp), %rdi
callq 0x1bb590
testb $0x1, %al
jne 0x73568
jmp 0x73623
movq 0x278(%rsp), %rdi
callq 0x128d0
callq 0x92b0
movsd %xmm0, 0x130(%rsp)
movq 0x288(%rsp), %rax
movq 0x90(%rax), %rax
movq 0x288(%rsp), %rcx
cmpq 0x98(%rcx), %rax
ja 0x735b0
movq 0x288(%rsp), %rdi
callq 0xc670
movq 0x288(%rsp), %rcx
movq 0x90(%rcx), %rax
movq %rax, %rdx
addq $-0x8, %rdx
movq %rdx, 0x90(%rcx)
movq -0x8(%rax), %rax
movq %rax, 0x138(%rsp)
movq 0x138(%rsp), %rax
movq $0xd, (%rax)
movsd 0x130(%rsp), %xmm0
movq 0x138(%rsp), %rax
movsd %xmm0, 0x8(%rax)
movq 0x138(%rsp), %rax
movq %rax, 0x128(%rsp)
movq 0x128(%rsp), %rax
movq %rax, 0x290(%rsp)
jmp 0x736ee
movq 0x288(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x278(%rsp), %rdi
callq 0x128d0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
callq 0x92b0
movq 0x10(%rsp), %rdi
movsd 0x16e372(%rip), %xmm1   # 0x1e19d8
callq 0x122a0
movq %rax, 0x290(%rsp)
jmp 0x736ee
movq 0x288(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x278(%rsp), %rdi
callq 0x1bb600
movsd %xmm0, 0x118(%rsp)
movsd %xmm1, 0x120(%rsp)
movsd 0x118(%rsp), %xmm0
movsd 0x120(%rsp), %xmm1
callq 0x92a0
movq 0x8(%rsp), %rdi
movsd %xmm0, 0x108(%rsp)
movsd %xmm1, 0x110(%rsp)
movsd 0x108(%rsp), %xmm0
movsd 0x110(%rsp), %xmm1
callq 0x1bb560
movq %rax, 0x290(%rsp)
movq 0x290(%rsp), %rax
addq $0x298, %rsp            # imm = 0x298
retq
nop