// File: /workspace/github_c_makefile_star2_O3/BernardTatin[P]s7sh/s7.c
// Function: g_acos
static s7_pointer g_acos(s7_scheme *sc, s7_pointer args)
    {
#define H_acos "(acos z) returns acos(z); (cos (acos 1)) = 1"
#define Q_acos sc->pl_nn
        s7_pointer n;

        n = car(args);
        switch (type(n))
        {
            case T_INTEGER:
                if (integer(n) == 1) return(small_int(0));
                return(c_acos(sc, (s7_double)integer(n)));

            case T_RATIO:
                return(c_acos(sc, (s7_double)numerator(n) / (s7_double)denominator(n)));

            case T_REAL:
                return(c_acos(sc, real(n)));

            case T_COMPLEX:
#if HAVE_COMPLEX_NUMBERS
                /* if either real or imag part is very large, use explicit formula, not cacos */
                /*   this code taken from sbcl's src/code/irrat.lisp */

                if ((fabs(real_part(n)) > 1.0e7) ||
                        (fabs(imag_part(n)) > 1.0e7))
                {
                    s7_complex sq1mz, sq1pz, z;
                    z = as_c_complex(n);
                    sq1mz = csqrt(1.0 - z);
                    sq1pz = csqrt(1.0 + z);	  /* creal(sq1pz) can be 0.0 */
                    if (creal(sq1pz) == 0.0)        /* so the atan arg will be inf, so the real part will be pi/2(?) */
                        return(s7_make_complex(sc, M_PI / 2.0, asinh(cimag(sq1mz * conj(sq1pz)))));
                    return(s7_make_complex(sc, 2.0 * atan(creal(sq1mz) / creal(sq1pz)), asinh(cimag(sq1mz * conj(sq1pz)))));
                }
                return(s7_from_c_complex(sc, cacos(s7_to_c_complex(n))));
#else
                return(out_of_range(sc, sc->acos_symbol, small_int(1), n, no_complex_numbers_string));
#endif

            default:
                return(method_or_bust_with_type_one_arg(sc, n, sc->acos_symbol, list_1(sc, n), a_number_string));
        }
    }

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movq 0x8(%rsi), %r14
movzbl (%r14), %eax
addl $-0xb, %eax
cmpl $0x3, %eax
ja 0x6736c
leaq 0xa0708(%rip), %rcx     # 0x1079c4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x8(%r14), %rax
cmpq $0x1, %rax
jne 0x674a1
movq 0xdf676(%rip), %rax     # 0x146950
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movsd 0x8(%r14), %xmm0
jmp 0x674a6
movsd 0x8(%r14), %xmm3
movsd 0x10(%r14), %xmm2
movapd 0xa2bbb(%rip), %xmm0    # 0x109ec0
movapd %xmm3, %xmm1
andpd %xmm0, %xmm1
ucomisd 0x9ed9b(%rip), %xmm1    # 0x1060b0
movapd %xmm2, 0x10(%rsp)
ja 0x673d7
andpd %xmm2, %xmm0
ucomisd 0x9ed83(%rip), %xmm0    # 0x1060b0
ja 0x673d7
movq %r14, %rdi
callq 0xe238
xorpd %xmm2, %xmm2
movapd 0x10(%rsp), %xmm1
mulsd %xmm1, %xmm2
addsd %xmm2, %xmm0
callq 0x8120
jmp 0x6748e
cvtsi2sdq 0x8(%r14), %xmm0
cvtsi2sdq 0x10(%r14), %xmm1
divsd %xmm1, %xmm0
jmp 0x674a6
movq 0xb98(%rbx), %r15
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %r12
cmpq 0x98(%rbx), %rax
ja 0x67399
movq %rbx, %rdi
callq 0xa550
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rcx
movq $0x200001, (%rcx)       # imm = 0x200001
movq %r14, 0x8(%rcx)
movq %r12, 0x10(%rcx)
movq 0xedfe2(%rip), %r8      # 0x1553a0
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xfa261
xorpd %xmm1, %xmm1
movapd %xmm2, %xmm0
mulsd %xmm1, %xmm0
addsd %xmm0, %xmm3
movapd %xmm3, 0x30(%rsp)
movsd 0x9ec3b(%rip), %xmm0    # 0x106030
subsd %xmm3, %xmm0
movapd 0xa2aaf(%rip), %xmm1    # 0x109eb0
xorpd %xmm2, %xmm1
callq 0x8560
movsd %xmm0, 0x8(%rsp)
movsd %xmm1, 0x28(%rsp)
movapd 0x30(%rsp), %xmm0
addsd 0x9ec0c(%rip), %xmm0    # 0x106030
movapd 0x10(%rsp), %xmm1
callq 0x8560
movapd %xmm0, %xmm3
ucomisd 0x9ec85(%rip), %xmm0    # 0x1060c0
jne 0x674b9
jp 0x674b9
movsd 0x8(%rsp), %xmm5
movapd %xmm5, %xmm4
mulsd %xmm3, %xmm4
movapd %xmm3, %xmm0
movsd 0x28(%rsp), %xmm6
mulsd %xmm6, %xmm0
movapd %xmm6, %xmm2
mulsd %xmm1, %xmm2
addsd %xmm4, %xmm2
movapd %xmm5, %xmm4
mulsd %xmm1, %xmm4
subsd %xmm4, %xmm0
ucomisd %xmm2, %xmm2
jp 0x6753b
callq 0x8740
movapd %xmm0, %xmm1
movsd 0x9ec2a(%rip), %xmm0    # 0x1060b8
movq %rbx, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xd387
cvtsi2sd %rax, %xmm0
movq %rbx, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xfa836
movsd 0x8(%rsp), %xmm0
divsd %xmm3, %xmm0
movsd %xmm3, 0x10(%rsp)
movapd %xmm1, 0x30(%rsp)
callq 0x8150
movapd 0x30(%rsp), %xmm3
movsd 0x10(%rsp), %xmm2
addsd %xmm0, %xmm0
movsd %xmm0, 0x40(%rsp)
movsd 0x8(%rsp), %xmm5
movapd %xmm5, %xmm1
mulsd %xmm2, %xmm1
movapd %xmm2, %xmm0
movsd 0x28(%rsp), %xmm4
mulsd %xmm4, %xmm0
movapd %xmm4, %xmm2
mulsd %xmm3, %xmm2
addsd %xmm1, %xmm2
movapd %xmm5, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm1, %xmm0
ucomisd %xmm2, %xmm2
jp 0x67577
callq 0x8740
movapd %xmm0, %xmm1
movq %rbx, %rdi
movsd 0x40(%rsp), %xmm0
jmp 0x67491
ucomisd %xmm0, %xmm0
jnp 0x6747d
movapd %xmm5, %xmm2
movapd %xmm1, %xmm5
movapd %xmm3, %xmm4
movapd %xmm6, %xmm1
movapd 0xa2953(%rip), %xmm3    # 0x109eb0
xorpd %xmm5, %xmm3
movapd %xmm2, %xmm0
movapd %xmm4, %xmm2
callq 0x1051d0
movapd %xmm1, %xmm0
jmp 0x6747d
ucomisd %xmm0, %xmm0
jnp 0x67524
movapd %xmm4, %xmm1
movapd 0xa2927(%rip), %xmm3    # 0x109eb0
xorpd 0x30(%rsp), %xmm3
movapd %xmm5, %xmm0
movsd 0x10(%rsp), %xmm2
callq 0x1051d0
movapd %xmm1, %xmm0
jmp 0x67524