int mycosA(int n, double theta, double *cosA, double *sinA, int k) {
  int j;
  double dh, tmp = 0.0, DH, dh2, lo, hi = theta,
             fixsgn = (double)(1 - 2 * (k % 2));
  double k025 = (k - .25), rho = n + .5, sgn = 1.0, fact = 1.0, hi2;
  hi = (double)((float)hi);
  lo = theta - hi;
  dh = (hi * rho - k025 * 3.141592741012573242187) + lo * rho -
       k025 * -0.00000008742278000372485127293903;
  DH = dh;
  dh2 = dh * dh;
  for (j = 0; j <= 5; j++) {
    tmp += sgn * DH / fact;
    sgn = -sgn;
    fact = fact * (double)((2 * j + 3) * (2 * j + 2));
    DH *= dh2;
  }
  *cosA = tmp * fixsgn;
  tmp = 0.0;
  sgn = 1.0;
  fact = 1.0;
  DH = 1.0;
  for (j = 0; j <= 5; j++) {
    tmp += sgn * DH / fact;
    sgn = -sgn;
    fact = fact * (double)((2 * j + 2) * (2 * j + 1));
    DH *= dh2;
  }
  *sinA = -tmp * fixsgn;
  return 0;
}


x86 assembly (clang, -O0):
<mycosA>:
push   %rbp
mov    %rsp,%rbp
push   %rax
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x24(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
shl    $0x1,%edx
mov    $0x1,%eax
sub    %edx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x60(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm0
movsd  0xecb(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xead(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xe94(%rip),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xe87(%rip),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x58(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm2
movsd  0xe47(%rip),%xmm1
mulsd  -0x68(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  -0x70(%rbp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xde5(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x5,-0x28(%rbp)
jg     12d0 <mycosA+0x1d0>
movsd  -0x78(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
divsd  -0x80(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x78(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x80(%rbp),%xmm0
mov    -0x28(%rbp),%eax
shl    $0x1,%eax
add    $0x3,%eax
mov    -0x28(%rbp),%ecx
shl    $0x1,%ecx
add    $0x2,%ecx
imul   %ecx,%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1248 <mycosA+0x148>
movsd  -0x38(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xd1e(%rip),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xd11(%rip),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  0xd04(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x5,-0x28(%rbp)
jg     13a0 <mycosA+0x2a0>
movsd  -0x78(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
divsd  -0x80(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x78(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x80(%rbp),%xmm0
mov    -0x28(%rbp),%eax
shl    $0x1,%eax
add    $0x2,%eax
mov    -0x28(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
imul   %ecx,%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1318 <mycosA+0x218>
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x60(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mycosA>:
mov    %ecx,%eax
shr    $0x1f,%eax
add    %ecx,%eax
cvtsi2sd %ecx,%xmm1
and    $0x7ffffffe,%eax
sub    %eax,%ecx
add    %ecx,%ecx
mov    $0x1,%eax
addsd  0xedf(%rip),%xmm1
cvtsi2sd %edi,%xmm2
addsd  0xedb(%rip),%xmm2
cvtsd2ss %xmm0,%xmm3
sub    %ecx,%eax
cvtss2sd %xmm3,%xmm3
subsd  %xmm3,%xmm0
movsd  0xecd(%rip),%xmm4
mulsd  %xmm1,%xmm4
mulsd  %xmm2,%xmm3
addsd  %xmm4,%xmm3
mulsd  %xmm2,%xmm0
addsd  %xmm3,%xmm0
mulsd  0xeb9(%rip),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
xorpd  %xmm2,%xmm2
addsd  %xmm1,%xmm2
mulsd  %xmm0,%xmm1
movapd %xmm0,%xmm3
mulsd  %xmm1,%xmm3
divsd  0xe99(%rip),%xmm1
addsd  %xmm2,%xmm1
movapd %xmm0,%xmm2
mulsd  %xmm3,%xmm2
divsd  0xe8d(%rip),%xmm3
addsd  %xmm1,%xmm3
movapd %xmm0,%xmm1
mulsd  %xmm2,%xmm1
divsd  0xe81(%rip),%xmm2
addsd  %xmm3,%xmm2
movapd %xmm1,%xmm3
divsd  0xe79(%rip),%xmm3
addsd  %xmm2,%xmm3
mulsd  %xmm0,%xmm1
divsd  0xe71(%rip),%xmm1
addsd  %xmm3,%xmm1
movsd  0xe6d(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xe69(%rip),%xmm2
movapd %xmm0,%xmm3
mulsd  %xmm0,%xmm3
movapd %xmm0,%xmm4
mulsd  %xmm3,%xmm4
divsd  0xe59(%rip),%xmm3
addsd  %xmm2,%xmm3
movapd %xmm0,%xmm2
mulsd  %xmm4,%xmm2
divsd  0xe4d(%rip),%xmm4
addsd  %xmm3,%xmm4
movapd %xmm2,%xmm3
mulsd  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  %xmm0,%xmm1
divsd  0xe36(%rip),%xmm3
divsd  0xe36(%rip),%xmm2
addsd  %xmm4,%xmm3
addsd  %xmm3,%xmm2
xorpd  0xe36(%rip),%xmm2
movsd  %xmm1,(%rsi)
mulsd  %xmm0,%xmm2
movsd  %xmm2,(%rdx)
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @mycosA(i32 %0, double %1, double* %2, double* %3, i32 %4) {
%6 = alloca i32
%7 = alloca double
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
store i32 %0, i32* %6
store double %1, double* %7
store double* %2, double** %8
store double* %3, double** %9
store i32 %4, i32* %10
store double 0.000000e+00, double* %13
%24 = load double, double* %7
store double %24, double* %17
%25 = load i32, i32* %10
%26 = srem i32 %25, 2
%27 = mul nsw i32 2, %26
%28 = sub nsw i32 1, %27
%29 = sitofp i32 %28 to double
store double %29, double* %18
%30 = load i32, i32* %10
%31 = sitofp i32 %30 to double
%32 = fsub double %31, 2.500000e-01
store double %32, double* %19
%33 = load i32, i32* %6
%34 = sitofp i32 %33 to double
%35 = fadd double %34, 5.000000e-01
store double %35, double* %20
store double 1.000000e+00, double* %21
store double 1.000000e+00, double* %22
%36 = load double, double* %17
%37 = fptrunc double %36 to float
%38 = fpext float %37 to double
store double %38, double* %17
%39 = load double, double* %7
%40 = load double, double* %17
%41 = fsub double %39, %40
store double %41, double* %16
%42 = load double, double* %17
%43 = load double, double* %20
%44 = load double, double* %19
%45 = fmul double %44, 0x400921FB60000000
%46 = fneg double %45
%47 = call double @llvm.fmuladd.f64(double %42, double %43, double %46)
%48 = load double, double* %16
%49 = load double, double* %20
%50 = call double @llvm.fmuladd.f64(double %48, double %49, double %47)
%51 = load double, double* %19
%52 = fneg double %51
%53 = call double @llvm.fmuladd.f64(double %52, double 0xBE7777A5CF72CECE, double %50)
store double %53, double* %12
%54 = load double, double* %12
store double %54, double* %14
%55 = load double, double* %12
%56 = load double, double* %12
%57 = fmul double %55, %56
store double %57, double* %15
store i32 0, i32* %11
br label %58
58: ; preds = %84, %5
%59 = load i32, i32* %11
%60 = icmp sle i32 %59, 5
br i1 %60, label %61, label %87
61: ; preds = %58
%62 = load double, double* %21
%63 = load double, double* %14
%64 = fmul double %62, %63
%65 = load double, double* %22
%66 = fdiv double %64, %65
%67 = load double, double* %13
%68 = fadd double %67, %66
store double %68, double* %13
%69 = load double, double* %21
%70 = fneg double %69
store double %70, double* %21
%71 = load double, double* %22
%72 = load i32, i32* %11
%73 = mul nsw i32 2, %72
%74 = add nsw i32 %73, 3
%75 = load i32, i32* %11
%76 = mul nsw i32 2, %75
%77 = add nsw i32 %76, 2
%78 = mul nsw i32 %74, %77
%79 = sitofp i32 %78 to double
%80 = fmul double %71, %79
store double %80, double* %22
%81 = load double, double* %15
%82 = load double, double* %14
%83 = fmul double %82, %81
store double %83, double* %14
br label %84
84: ; preds = %61
%85 = load i32, i32* %11
%86 = add nsw i32 %85, 1
store i32 %86, i32* %11
br label %58
87: ; preds = %58
%88 = load double, double* %13
%89 = load double, double* %18
%90 = fmul double %88, %89
%91 = load double*, double** %8
store double %90, double* %91
store double 0.000000e+00, double* %13
store double 1.000000e+00, double* %21
store double 1.000000e+00, double* %22
store double 1.000000e+00, double* %14
store i32 0, i32* %11
br label %92
92: ; preds = %118, %87
%93 = load i32, i32* %11
%94 = icmp sle i32 %93, 5
br i1 %94, label %95, label %121
95: ; preds = %92
%96 = load double, double* %21
%97 = load double, double* %14
%98 = fmul double %96, %97
%99 = load double, double* %22
%100 = fdiv double %98, %99
%101 = load double, double* %13
%102 = fadd double %101, %100
store double %102, double* %13
%103 = load double, double* %21
%104 = fneg double %103
store double %104, double* %21
%105 = load double, double* %22
%106 = load i32, i32* %11
%107 = mul nsw i32 2, %106
%108 = add nsw i32 %107, 2
%109 = load i32, i32* %11
%110 = mul nsw i32 2, %109
%111 = add nsw i32 %110, 1
%112 = mul nsw i32 %108, %111
%113 = sitofp i32 %112 to double
%114 = fmul double %105, %113
store double %114, double* %22
%115 = load double, double* %15
%116 = load double, double* %14
%117 = fmul double %116, %115
store double %117, double* %14
br label %118
118: ; preds = %95
%119 = load i32, i32* %11
%120 = add nsw i32 %119, 1
store i32 %120, i32* %11
br label %92
121: ; preds = %92
%122 = load double, double* %13
%123 = fneg double %122
%124 = load double, double* %18
%125 = fmul double %123, %124
%126 = load double*, double** %9
store double %125, double* %126
ret i32 0
}

LLVM IR (-O2):
define i32 @mycosA(i32 %0, double %1, double* nocapture writeonly %2, double* nocapture writeonly %3, i32 %4) {
%6 = srem i32 %4, 2
%7 = mul nsw i32 %6, -2
%8 = or i32 %7, 1
%9 = sitofp i32 %4 to double
%10 = fadd double %9, -2.500000e-01
%11 = sitofp i32 %0 to double
%12 = fadd double %11, 5.000000e-01
%13 = fptrunc double %1 to float
%14 = fpext float %13 to double
%15 = fsub double %1, %14
%16 = fmul double %10, 0xC00921FB60000000
%17 = tail call double @llvm.fmuladd.f64(double %14, double %12, double %16)
%18 = tail call double @llvm.fmuladd.f64(double %15, double %12, double %17)
%19 = fneg double %10
%20 = tail call double @llvm.fmuladd.f64(double %19, double 0xBE7777A5CF72CECE, double %18)
%21 = fmul double %20, %20
%22 = fadd double %20, 0.000000e+00
%23 = fmul double %21, %20
%24 = fdiv double %23, -6.000000e+00
%25 = fadd double %22, %24
%26 = fmul double %21, %23
%27 = fdiv double %26, 1.200000e+02
%28 = fadd double %25, %27
%29 = fmul double %21, %26
%30 = fdiv double %29, -5.040000e+03
%31 = fadd double %28, %30
%32 = fmul double %21, %29
%33 = fdiv double %32, 3.628800e+05
%34 = fadd double %31, %33
%35 = fneg double %21
%36 = fmul double %32, %35
%37 = fdiv double %36, 3.991680e+07
%38 = fadd double %34, %37
%39 = sitofp i32 %8 to double
%40 = fmul double %38, %39
store double %40, double* %2
%41 = fmul double %21, -5.000000e-01
%42 = fadd double %41, 1.000000e+00
%43 = fmul double %21, %21
%44 = fdiv double %43, 2.400000e+01
%45 = fadd double %42, %44
%46 = fmul double %21, %43
%47 = fdiv double %46, -7.200000e+02
%48 = fadd double %45, %47
%49 = fmul double %21, %46
%50 = fdiv double %49, 4.032000e+04
%51 = fadd double %48, %50
%52 = fneg double %21
%53 = fmul double %49, %52
%54 = fdiv double %53, 3.628800e+06
%55 = fadd double %51, %54
%56 = fneg double %55
%57 = fmul double %39, %56
store double %57, double* %3
ret i32 0
}