#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double cos(double);
double sin(double);
double sqrt(double);
void sncn_limit(double u, double rk, double *sn, double *cn) {
  double k, m, s, c, r;
  k = rk / sqrt(1.0 + rk * rk);
  m = k * k;
  s = sin(u);
  c = cos(u);
  r = 0.25 * m * (u - s * c);
  (*sn) = s - r * c;
  (*cn) = c + r * s;
}


x86 assembly (clang, -O0):
<sncn_limit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe9e(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  0xe47(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm3
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sncn_limit>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movsd  %xmm1,(%rsp)
mulsd  %xmm1,%xmm1
addsd  0xeb8(%rip),%xmm1
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  %xmm0,0x8(%rsp)
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jb     1167 <sncn_limit+0x37>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
jmp    1170 <sncn_limit+0x40>
movapd %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
mulsd  %xmm1,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
movsd  (%rsp),%xmm4
mulsd  0xe5d(%rip),%xmm4
movsd  0x10(%rsp),%xmm3
movapd %xmm3,%xmm1
mulsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm2
subsd  %xmm1,%xmm2
mulsd  %xmm4,%xmm2
movapd %xmm2,%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm3,%xmm2
subsd  %xmm1,%xmm3
movsd  %xmm3,(%rbx)
addsd  %xmm0,%xmm2
movsd  %xmm2,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @sncn_limit(double %0, double %1, double* %2, double* %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
store double %0, double* %5
store double %1, double* %6
store double* %2, double** %7
store double* %3, double** %8
%14 = load double, double* %6
%15 = load double, double* %6
%16 = load double, double* %6
%17 = call double @llvm.fmuladd.f64(double %15, double %16, double 1.000000e+00)
%18 = call double @sqrt(double %17)
%19 = fdiv double %14, %18
store double %19, double* %9
%20 = load double, double* %9
%21 = load double, double* %9
%22 = fmul double %20, %21
store double %22, double* %10
%23 = load double, double* %5
%24 = call double @sin(double %23)
store double %24, double* %11
%25 = load double, double* %5
%26 = call double @cos(double %25)
store double %26, double* %12
%27 = load double, double* %10
%28 = fmul double 2.500000e-01, %27
%29 = load double, double* %5
%30 = load double, double* %11
%31 = load double, double* %12
%32 = fneg double %30
%33 = call double @llvm.fmuladd.f64(double %32, double %31, double %29)
%34 = fmul double %28, %33
store double %34, double* %13
%35 = load double, double* %11
%36 = load double, double* %13
%37 = load double, double* %12
%38 = fneg double %36
%39 = call double @llvm.fmuladd.f64(double %38, double %37, double %35)
%40 = load double*, double** %7
store double %39, double* %40
%41 = load double, double* %12
%42 = load double, double* %13
%43 = load double, double* %11
%44 = call double @llvm.fmuladd.f64(double %42, double %43, double %41)
%45 = load double*, double** %8
store double %44, double* %45
ret void
}

LLVM IR (-O2):
define void @sncn_limit(double %0, double %1, double* nocapture writeonly %2, double* nocapture writeonly %3) {
%5 = tail call double @llvm.fmuladd.f64(double %1, double %1, double 1.000000e+00)
%6 = tail call double @sqrt(double %5)
%7 = fdiv double %1, %6
%8 = fmul double %7, %7
%9 = tail call double @sin(double %0)
%10 = tail call double @cos(double %0)
%11 = fmul double %8, 2.500000e-01
%12 = fneg double %9
%13 = tail call double @llvm.fmuladd.f64(double %12, double %10, double %0)
%14 = fmul double %11, %13
%15 = fneg double %14
%16 = tail call double @llvm.fmuladd.f64(double %15, double %10, double %9)
store double %16, double* %2
%17 = tail call double @llvm.fmuladd.f64(double %14, double %9, double %10)
store double %17, double* %3
ret void
}