// File: /workspace/github_c_makefile_star2_O2/BernardTatin[P]s7sh/s7.c
// Function: g_atan
static s7_pointer g_atan(s7_scheme *sc, s7_pointer args)
    {
#define H_atan "(atan z) returns atan(z), (atan y x) returns atan(y/x)"
#define Q_atan s7_make_signature(sc, 3, sc->is_number_symbol, sc->is_number_symbol, sc->is_real_symbol)
        /* actually if there are two args, both should be real, but how to express that in the signature? */
        s7_pointer x, y;
        s7_double x1, x2;

        /* currently (atan inf.0 inf.0) -> 0.78539816339745, and (atan inf.0 -inf.0) -> 2.3561944901923 (etc) */

        x = car(args);
        if (!is_pair(cdr(args)))
        {
            switch (type(x))
            {
                case T_INTEGER:
                    if (integer(x) == 0) return(small_int(0));                /* (atan 0) -> 0 */

                case T_RATIO:
                case T_REAL:
                    return(make_real(sc, atan(s7_real(x))));

                case T_COMPLEX:
#if HAVE_COMPLEX_NUMBERS
                    return(s7_from_c_complex(sc, catan(as_c_complex(x))));
#else
                    return(out_of_range(sc, sc->atan_symbol, small_int(1), x, no_complex_numbers_string));
#endif

                default:
                    return(method_or_bust_with_type_one_arg(sc, x, sc->atan_symbol, args, a_number_string));
            }
        }

        if (!s7_is_real(x))
            return(method_or_bust(sc, x, sc->atan_symbol, args, T_REAL, 1));

        y = cadr(args);
        if (!s7_is_real(y))
            return(method_or_bust(sc, y, sc->atan_symbol, args, T_REAL, 2));

        x1 = s7_real(x);
        x2 = s7_real(y);
        return(make_real(sc, atan2(x1, x2)));
    }

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rcx
movq %rdi, %rbx
movq 0x8(%rsi), %rsi
movq 0x10(%rcx), %rdx
cmpb $0x1, (%rdx)
movzbl (%rsi), %eax
jne 0x52cbc
leaq 0xc6d34(%rip), %rdi     # 0x1199b0
cmpb $0x0, (%rax,%rdi)
je 0x52d3a
movq 0x8(%rdx), %r14
movzbl (%r14), %eax
cmpb $0x0, (%rax,%rdi)
je 0x52d4e
movq %rsi, %rdi
callq 0xc42a
movsd %xmm0, (%rsp)
movq %r14, %rdi
callq 0xc42a
movaps %xmm0, %xmm1
movsd (%rsp), %xmm0
callq 0x84e0
jmp 0x52cee
leal -0xc(%rax), %edx
cmpl $0x2, %edx
jb 0x52ce1
cmpl $0xe, %eax
je 0x52d6f
cmpl $0xb, %eax
jne 0x52d95
cmpq $0x0, 0x8(%rsi)
je 0x52db2
movq %rsi, %rdi
callq 0xc42a
callq 0x8150
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x52d17
movq %rbx, %rdi
movsd %xmm0, (%rsp)
callq 0x9c27
movsd (%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)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0xc08(%rbx), %rdx
pushq $0xd
popq %r8
pushq $0x1
popq %r9
movq %rbx, %rdi
jmp 0x52d63
movq 0xc08(%rbx), %rdx
pushq $0xd
popq %r8
pushq $0x2
popq %r9
movq %rbx, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xcd70
movsd 0x10(%rsi), %xmm1
xorpd %xmm0, %xmm0
mulsd %xmm1, %xmm0
addsd 0x8(%rsi), %xmm0
callq 0x8620
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xc152
movq 0xc08(%rbx), %rdx
movq 0xd15fd(%rip), %r8      # 0x1243a0
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xc736d
movq 0xc2b97(%rip), %rax     # 0x115950
jmp 0x52d32