// File: /workspace/github_c_makefile_star2_O1/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 0x6c680
leaq 0xe6357(%rip), %rdi     # 0x1529b0
cmpb $0x0, (%rax,%rdi)
je 0x6c6b3
movq 0x8(%rdx), %r14
movzbl (%r14), %edx
cmpb $0x0, (%rdx,%rdi)
je 0x6c6e8
cmpl $0xd, %eax
jne 0x6c750
movsd 0x8(%rsi), %xmm0
jmp 0x6c763
leal -0xb(%rax), %edx
cmpl $0x3, %edx
ja 0x6c733
leaq 0xa42c1(%rip), %rcx     # 0x110954
movslq (%rcx,%rdx,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
cmpq $0x0, 0x8(%rsi)
je 0x6c7e5
cmpl $0xd, %eax
jne 0x6c6cb
movsd 0x8(%rsi), %xmm0
jmp 0x6c6de
movq 0xc08(%rbx), %rdx
movq %rbx, %rdi
movl $0xd, %r8d
movl $0x1, %r9d
jmp 0x6c701
movq 0xe635e(%rip), %rdi     # 0x152a30
leaq 0xa688f(%rip), %rdx     # 0x112f68
callq 0xe212
callq 0x9150
jmp 0x6c799
movq 0xc08(%rbx), %rdx
movq %rbx, %rdi
movq %r14, %rsi
movl $0xd, %r8d
movl $0x2, %r9d
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xf1ae
movsd 0x10(%rsi), %xmm1
xorpd %xmm0, %xmm0
mulsd %xmm1, %xmm0
addsd 0x8(%rsi), %xmm0
callq 0x9620
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xe101
movq 0xc08(%rbx), %rdx
movq 0xf0c5f(%rip), %r8      # 0x15d3a0
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x103001
movq 0xe62d9(%rip), %rdi     # 0x152a30
leaq 0xa680a(%rip), %rdx     # 0x112f68
callq 0xe212
cmpb $0xd, (%r14)
jne 0x6c771
movsd 0x8(%r14), %xmm1
jmp 0x6c794
movq 0xe62b8(%rip), %rdi     # 0x152a30
leaq 0xa67e9(%rip), %rdx     # 0x112f68
movq %r14, %rsi
movsd %xmm0, (%rsp)
callq 0xe212
movaps %xmm0, %xmm1
movsd (%rsp), %xmm0
callq 0x94e0
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x6c7bb
movq %rbx, %rdi
movsd %xmm0, (%rsp)
callq 0xb389
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 0xe2164(%rip), %rax     # 0x14e950
jmp 0x6c7dd