// File: /workspace/github_c_makefile_star2_O1/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), %r15d
leal -0xb(%r15), %eax
cmpl $0x3, %eax
ja 0x6c47c
leaq 0xa4619(%rip), %rcx     # 0x110944
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x8(%r14), %rax
cmpq $0x1, %rax
jne 0x6c4e7
movq 0xe2607(%rip), %rax     # 0x14e950
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movsd 0x8(%r14), %xmm0
jmp 0x6c4ec
movsd 0x8(%r14), %xmm1
movapd 0xa6a62(%rip), %xmm0    # 0x112dd0
andpd %xmm1, %xmm0
ucomisd 0xa2d36(%rip), %xmm0    # 0x10f0b0
ja 0x6c39c
movsd 0x10(%r14), %xmm2
movapd 0xa6a46(%rip), %xmm0    # 0x112dd0
andpd %xmm2, %xmm0
ucomisd 0xa2d1a(%rip), %xmm0    # 0x10f0b0
jbe 0x6c584
movsd 0x10(%r14), %xmm3
movapd %xmm3, 0x30(%rsp)
xorpd %xmm2, %xmm2
movapd %xmm3, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm0, %xmm1
movapd %xmm1, 0x20(%rsp)
movsd 0xa2c6a(%rip), %xmm0    # 0x10f030
subsd %xmm1, %xmm0
movapd 0xa69ee(%rip), %xmm1    # 0x112dc0
xorpd %xmm3, %xmm1
callq 0x9560
movsd %xmm0, (%rsp)
movsd %xmm1, 0x18(%rsp)
movapd 0x20(%rsp), %xmm0
addsd 0xa2c3c(%rip), %xmm0    # 0x10f030
movapd 0x30(%rsp), %xmm1
callq 0x9560
movapd %xmm0, %xmm3
ucomisd 0xa2cb5(%rip), %xmm0    # 0x10f0c0
jne 0x6c4ff
jp 0x6c4ff
movsd (%rsp), %xmm5
movapd %xmm5, %xmm4
mulsd %xmm3, %xmm4
movapd %xmm3, %xmm0
movsd 0x18(%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 0x6c5c8
callq 0x9740
movapd %xmm0, %xmm1
movsd 0xa2c53(%rip), %xmm0    # 0x10f0b8
jmp 0x6c5b5
cvtsi2sdq 0x8(%r14), %xmm0
cvtsi2sdq 0x10(%r14), %xmm1
divsd %xmm1, %xmm0
jmp 0x6c4ec
movq 0xb98(%rbx), %r15
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %r12
cmpq 0x98(%rbx), %rax
ja 0x6c4a2
movq %rbx, %rdi
callq 0xb389
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 0xf0ed2(%rip), %r8      # 0x15d3a0
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x103001
cvtsi2sd %rax, %xmm0
movq %rbx, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x1035fe
movsd (%rsp), %xmm0
divsd %xmm3, %xmm0
movsd %xmm3, 0x30(%rsp)
movapd %xmm1, 0x20(%rsp)
callq 0x9150
movapd 0x20(%rsp), %xmm3
movsd 0x30(%rsp), %xmm2
movapd %xmm0, %xmm5
addsd %xmm0, %xmm5
movsd (%rsp), %xmm6
movapd %xmm6, %xmm1
mulsd %xmm2, %xmm1
movapd %xmm2, %xmm0
movsd 0x18(%rsp), %xmm4
mulsd %xmm4, %xmm0
movapd %xmm4, %xmm2
mulsd %xmm3, %xmm2
addsd %xmm1, %xmm2
movapd %xmm6, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm1, %xmm0
ucomisd %xmm2, %xmm2
movsd %xmm5, 0x40(%rsp)
jp 0x6c604
callq 0x9740
movapd %xmm0, %xmm1
movq %rbx, %rdi
movsd 0x40(%rsp), %xmm0
jmp 0x6c5b8
movq %r14, %rdi
movapd %xmm2, (%rsp)
callq 0xefb9
movapd (%rsp), %xmm1
xorpd %xmm2, %xmm2
cmpb $0xe, %r15b
je 0x6c5a4
xorpd %xmm1, %xmm1
mulsd %xmm1, %xmm2
addsd %xmm0, %xmm2
movapd %xmm2, %xmm0
callq 0x9120
movq %rbx, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xe101
ucomisd %xmm0, %xmm0
jnp 0x6c454
movapd %xmm5, %xmm2
movapd %xmm1, %xmm5
movapd %xmm3, %xmm4
movapd %xmm6, %xmm1
movapd 0xa67d6(%rip), %xmm3    # 0x112dc0
xorpd %xmm5, %xmm3
movapd %xmm2, %xmm0
movapd %xmm4, %xmm2
callq 0x10e760
movapd %xmm1, %xmm0
jmp 0x6c454
ucomisd %xmm0, %xmm0
jnp 0x6c570
movapd %xmm4, %xmm1
movapd 0xa67a6(%rip), %xmm3    # 0x112dc0
xorpd 0x20(%rsp), %xmm3
movapd %xmm6, %xmm0
movsd 0x30(%rsp), %xmm2
callq 0x10e760
movapd %xmm1, %xmm0
jmp 0x6c570