#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 fabs(double);
int /*<<< orphan*/ mycosA(int, double, double *, double *, int);
double sin(double);
double sqrtl(double);
int feval(int n, double theta, double C, double *f, double *fp, int k) {
  double sinT = sin(theta), cosT = cos(theta), cotT = cosT / sinT;
  double alpha, cosA, sinA, denom, df, dfp, tmp;
  int m;
  denom = sqrtl(2.0 * sinT);
  mycosA(n, theta, &cosA, &sinA, k);
  *f = C * cosA / denom;
  *fp = C * (0.5 * (cosA * cotT + sinA) + n * sinA) / denom;
  for (m = 1; m <= 30; m++) {
    C *= (1.0 - 0.5 / m) * (m - 0.5) / (n + m + 0.5);
    denom *= 2.0 * sinT;
    tmp = cosA * sinT + sinA * cosT;
    sinA = sinA * sinT - cosA * cosT;
    cosA = tmp;
    df = C * cosA / denom;
    dfp = C * ((m + 0.5) * (cosA * cotT + sinA) + n * sinA) / denom;
    *f += df;
    *fp += dfp;
    if (fabs(df) + fabs(dfp) < 2.2204460492503131e-16 / 100) {
      break;
    }
  }
}


x86 assembly (clang, -O0):
<feval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %ecx,-0x2c(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe70(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
call   1050 <sqrtl@plt>
movsd  %xmm0,-0x68(%rbp)
mov    -0x8(%rbp),%edi
movsd  -0x10(%rbp),%xmm0
mov    -0x2c(%rbp),%ecx
lea    -0x58(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   1030 <mycosA@plt>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
divsd  -0x68(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm3
movsd  -0x60(%rbp),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
cvtsi2sdl -0x8(%rbp),%xmm2
mulsd  -0x60(%rbp),%xmm2
movsd  0xdfc(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x68(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x84(%rbp)
cmpl   $0x1e,-0x84(%rbp)
jg     13e7 <feval+0x2a7>
cvtsi2sdl -0x84(%rbp),%xmm0
ff
movsd  0xdbc(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  0xdc8(%rip),%xmm0
subsd  %xmm1,%xmm0
cvtsi2sdl -0x84(%rbp),%xmm1
ff
movsd  0xd9c(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%eax
add    -0x84(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd  0xd7f(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xd6d(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
mulsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
divsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x84(%rbp),%xmm1
ff
movsd  0xcca(%rip),%xmm2
addsd  %xmm2,%xmm1
movsd  -0x58(%rbp),%xmm3
movsd  -0x48(%rbp),%xmm4
movsd  -0x60(%rbp),%xmm2
mulsd  %xmm4,%xmm3
addsd  %xmm2,%xmm3
cvtsi2sdl -0x8(%rbp),%xmm2
mulsd  -0x60(%rbp),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x70(%rbp),%xmm0
mov    -0x20(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
movsd  -0x78(%rbp),%xmm0
mov    -0x28(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
movsd  -0x70(%rbp),%xmm1
movaps 0xc81(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
movaps 0xc71(%rip),%xmm2
pand   %xmm2,%xmm0
addsd  %xmm0,%xmm1
movsd  0xc51(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    13ce <feval+0x28e>
jmp    13e7 <feval+0x2a7>
jmp    13d3 <feval+0x293>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    1227 <feval+0xe7>
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<feval>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %ecx,%ebp
mov    %rdx,%r14
mov    %rsi,%rbx
movaps %xmm1,0x70(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %edi,%r15d
call   1040 <sin@plt>
movaps %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1060 <cos@plt>
movapd %xmm0,0x60(%rsp)
movapd %xmm0,%xmm1
movapd 0x20(%rsp),%xmm0
divsd  %xmm0,%xmm1
movapd %xmm1,0x50(%rsp)
addsd  %xmm0,%xmm0
movapd %xmm0,0x30(%rsp)
call   1050 <sqrtl@plt>
movapd %xmm0,0x40(%rsp)
lea    0x18(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %r15d,%edi
movsd  0x8(%rsp),%xmm0
mov    %ebp,%ecx
call   1030 <mycosA@plt>
movapd 0x30(%rsp),%xmm15
movapd 0x50(%rsp),%xmm14
movapd 0x60(%rsp),%xmm13
movapd 0x70(%rsp),%xmm7
movapd 0x20(%rsp),%xmm12
movsd  0x18(%rsp),%xmm0
movapd %xmm0,%xmm1
mulsd  %xmm7,%xmm1
movapd 0x40(%rsp),%xmm4
divsd  %xmm4,%xmm1
movsd  %xmm1,(%rbx)
movsd  0x10(%rsp),%xmm2
movapd %xmm0,%xmm3
mulsd  %xmm14,%xmm3
addsd  %xmm2,%xmm3
xorps  %xmm1,%xmm1
cvtsi2sd %r15d,%xmm1
unpcklpd %xmm2,%xmm0
mulsd  %xmm1,%xmm2
mulsd  0xdd6(%rip),%xmm3
addsd  %xmm2,%xmm3
mulsd  %xmm7,%xmm3
movapd %xmm4,%xmm2
movapd %xmm4,%xmm9
divsd  %xmm4,%xmm3
movsd  %xmm3,(%r14)
unpcklpd %xmm12,%xmm12
unpcklpd %xmm13,%xmm13
mov    $0x1,%eax
movsd  0xdad(%rip),%xmm6
movsd  0xd9d(%rip),%xmm4
movapd 0xdc4(%rip),%xmm10
movsd  0xda3(%rip),%xmm11
cs nopw 0x0(%rax,%rax,1)
nop
movapd %xmm7,%xmm5
xorps  %xmm3,%xmm3
cvtsi2sd %eax,%xmm3
movapd %xmm6,%xmm2
divsd  %xmm3,%xmm2
addsd  0xd75(%rip),%xmm2
movapd %xmm3,%xmm7
addsd  %xmm6,%xmm7
mulsd  %xmm2,%xmm7
lea    (%r15,%rax,1),%ecx
xorps  %xmm2,%xmm2
cvtsi2sd %ecx,%xmm2
addsd  %xmm4,%xmm2
divsd  %xmm2,%xmm7
mulsd  %xmm5,%xmm7
movapd %xmm0,%xmm2
xorpd  0xd56(%rip),%xmm2
movapd %xmm0,%xmm5
shufpd $0x1,%xmm2,%xmm5
mulpd  %xmm13,%xmm5
mulpd  %xmm12,%xmm0
addpd  %xmm5,%xmm0
addsd  %xmm4,%xmm3
movapd %xmm0,%xmm2
unpckhpd %xmm0,%xmm2
movapd %xmm0,%xmm5
mulsd  %xmm14,%xmm5
addsd  %xmm2,%xmm5
mulsd  %xmm3,%xmm5
movapd %xmm9,%xmm8
mulsd  %xmm15,%xmm8
mulsd  %xmm1,%xmm2
addsd  %xmm5,%xmm2
movapd %xmm0,%xmm3
unpcklpd %xmm2,%xmm3
movapd %xmm7,%xmm2
unpcklpd %xmm7,%xmm2
mulpd  %xmm2,%xmm3
movapd %xmm8,%xmm9
unpcklpd %xmm8,%xmm8
divpd  %xmm8,%xmm3
movsd  (%rbx),%xmm2
addsd  %xmm3,%xmm2
movsd  %xmm2,(%rbx)
movapd %xmm3,%xmm2
unpckhpd %xmm3,%xmm2
addsd  (%r14),%xmm2
movsd  %xmm2,(%r14)
andpd  %xmm10,%xmm3
pshufd $0xee,%xmm3,%xmm2
addsd  %xmm3,%xmm2
ucomisd %xmm2,%xmm11
ja     1374 <feval+0x234>
lea    0x1(%rax),%ecx
cmp    $0x1e,%eax
mov    %ecx,%eax
jne    1280 <feval+0x140>
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @feval(i32 %0, double %1, double %2, double* nocapture %3, double* nocapture %4, i32 %5) {
%7 = alloca double
%8 = alloca double
%9 = tail call double @sin(double %1)
%10 = tail call double @cos(double %1)
%11 = fdiv double %10, %9
%12 = bitcast double* %7 to i8*
%13 = bitcast double* %8 to i8*
%14 = fmul double %9, 2.000000e+00
%15 = tail call double @sqrtl(double %14)
%16 = call i32 @mycosA(i32 %0, double %1, double* %7, double* %8, i32 %5)
%17 = load double, double* %7
%18 = fmul double %17, %2
%19 = fdiv double %18, %15
store double %19, double* %3
%20 = load double, double* %8
%21 = call double @llvm.fmuladd.f64(double %17, double %11, double %20)
%22 = sitofp i32 %0 to double
%23 = fmul double %20, %22
%24 = call double @llvm.fmuladd.f64(double %21, double 5.000000e-01, double %23)
%25 = fmul double %24, %2
%26 = fdiv double %25, %15
store double %26, double* %4
%27 = insertelement <2 x double> poison, double %17, i64 0
%28 = insertelement <2 x double> %27, double %20, i64 1
%29 = insertelement <2 x double> poison, double %9, i64 0
%30 = shufflevector <2 x double> %29, <2 x double> poison, <2 x i32> zeroinitializer
%31 = insertelement <2 x double> poison, double %10, i64 0
%32 = shufflevector <2 x double> %31, <2 x double> poison, <2 x i32> zeroinitializer
br label %33
33: ; preds = %33, %6
%34 = phi i32 [ 1, %6 ], [ %80, %33 ]
%35 = phi double [ %2, %6 ], [ %47, %33 ]
%36 = phi double [ %15, %6 ], [ %48, %33 ]
%37 = phi <2 x double> [ %28, %6 ], [ %55, %33 ]
%38 = sitofp i32 %34 to double
%39 = fdiv double 5.000000e-01, %38
%40 = fsub double 1.000000e+00, %39
%41 = fadd double %38, -5.000000e-01
%42 = fmul double %41, %40
%43 = add nsw i32 %34, %0
%44 = sitofp i32 %43 to double
%45 = fadd double %44, 5.000000e-01
%46 = fdiv double %42, %45
%47 = fmul double %35, %46
%48 = fmul double %14, %36
%49 = extractelement <2 x double> %37, i64 0
%50 = fneg double %49
%51 = extractelement <2 x double> %37, i64 1
%52 = insertelement <2 x double> poison, double %51, i64 0
%53 = insertelement <2 x double> %52, double %50, i64 1
%54 = fmul <2 x double> %32, %53
%55 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %37, <2 x double> %30, <2 x double> %54)
%56 = extractelement <2 x double> %55, i64 0
%57 = fadd double %38, 5.000000e-01
%58 = extractelement <2 x double> %55, i64 1
%59 = call double @llvm.fmuladd.f64(double %56, double %11, double %58)
%60 = fmul double %58, %22
%61 = call double @llvm.fmuladd.f64(double %57, double %59, double %60)
%62 = insertelement <2 x double> poison, double %47, i64 0
%63 = shufflevector <2 x double> %62, <2 x double> poison, <2 x i32> zeroinitializer
%64 = insertelement <2 x double> %55, double %61, i64 1
%65 = fmul <2 x double> %63, %64
%66 = insertelement <2 x double> poison, double %48, i64 0
%67 = shufflevector <2 x double> %66, <2 x double> poison, <2 x i32> zeroinitializer
%68 = fdiv <2 x double> %65, %67
%69 = load double, double* %3
%70 = extractelement <2 x double> %68, i64 0
%71 = fadd double %69, %70
store double %71, double* %3
%72 = load double, double* %4
%73 = extractelement <2 x double> %68, i64 1
%74 = fadd double %72, %73
store double %74, double* %4
%75 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %68)
%76 = shufflevector <2 x double> %75, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%77 = fadd <2 x double> %75, %76
%78 = extractelement <2 x double> %77, i64 0
%79 = fcmp olt double %78, 0x3C447AE147AE147B
%80 = add nuw nsw i32 %34, 1
%81 = icmp eq i32 %80, 31
%82 = select i1 %79, i1 true, i1 %81
br i1 %82, label %83, label %33
83: ; preds = %33
ret i32 undef
}