#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(int);
double fabs(double);
double ComputeA(double freq, int r, double ad[], double x[], double y[]) {
  int i;
  double xc, c, denom, numer;
  denom = numer = 0;
  xc = cos((2. * 3.1415926535897932384626433832795029) * freq);
  for (i = 0; i <= r; i++) {
    c = xc - x[i];
    if (fabs(c) < 1.0e-7) {
      numer = y[i];
      denom = 1;
      break;
    }
    c = ad[i] / c;
    denom += c;
    numer += c * y[i];
  }
  return numer / denom;
}


x86 assembly (clang, -O0):
<ComputeA>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xebc(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     121f <ComputeA+0x10f>
movsd  -0x38(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm1
movaps 0xe93(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xe6f(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11c7 <ComputeA+0xb7>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe53(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    121f <ComputeA+0x10f>
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x50(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    115e <ComputeA+0x4e>
movsd  -0x50(%rbp),%xmm0
divsd  -0x48(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ComputeA>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%r15
mov    %edi,%ebx
mulsd  0xed5(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
test   %ebx,%ebx
js     119b <ComputeA+0x8b>
movapd %xmm0,%xmm1
add    $0x1,%ebx
xorpd  %xmm0,%xmm0
xor    %eax,%eax
movapd 0xed3(%rip),%xmm3
movsd  0xeb3(%rip),%xmm4
xorpd  %xmm2,%xmm2
nopl   0x0(%rax)
movapd %xmm1,%xmm5
subsd  (%r12,%rax,8),%xmm5
movapd %xmm5,%xmm6
andpd  %xmm3,%xmm6
ucomisd %xmm6,%xmm4
ja     11a5 <ComputeA+0x95>
movsd  (%r15,%rax,8),%xmm6
divsd  %xmm5,%xmm6
addsd  %xmm6,%xmm2
mulsd  (%r14,%rax,8),%xmm6
addsd  %xmm6,%xmm0
add    $0x1,%rax
cmp    %rax,%rbx
jne    1160 <ComputeA+0x50>
jmp    11b3 <ComputeA+0xa3>
xorpd  %xmm2,%xmm2
xorpd  %xmm0,%xmm0
jmp    11b3 <ComputeA+0xa3>
movsd  (%r14,%rax,8),%xmm0
movsd  0xe5d(%rip),%xmm2
divsd  %xmm2,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @ComputeA(double %0, i32 %1, double* %2, double* %3, double* %4) {
%6 = alloca double
%7 = alloca i32
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
store double %0, double* %6
store i32 %1, i32* %7
store double* %2, double** %8
store double* %3, double** %9
store double* %4, double** %10
store double 0.000000e+00, double* %15
store double 0.000000e+00, double* %14
%16 = load double, double* %6
%17 = fmul double 0x401921FB54442D18, %16
%18 = fptosi double %17 to i32
%19 = call double @cos(i32 %18)
store double %19, double* %12
store i32 0, i32* %11
br label %20
20: ; preds = %60, %5
%21 = load i32, i32* %11
%22 = load i32, i32* %7
%23 = icmp sle i32 %21, %22
br i1 %23, label %24, label %63
24: ; preds = %20
%25 = load double, double* %12
%26 = load double*, double** %9
%27 = load i32, i32* %11
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %26, i64 %28
%30 = load double, double* %29
%31 = fsub double %25, %30
store double %31, double* %13
%32 = load double, double* %13
%33 = call double @llvm.fabs.f64(double %32)
%34 = fcmp olt double %33, 0x3E7AD7F29ABCAF48
br i1 %34, label %35, label %41
35: ; preds = %24
%36 = load double*, double** %10
%37 = load i32, i32* %11
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %36, i64 %38
%40 = load double, double* %39
store double %40, double* %15
store double 1.000000e+00, double* %14
br label %63
41: ; preds = %24
%42 = load double*, double** %8
%43 = load i32, i32* %11
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %42, i64 %44
%46 = load double, double* %45
%47 = load double, double* %13
%48 = fdiv double %46, %47
store double %48, double* %13
%49 = load double, double* %13
%50 = load double, double* %14
%51 = fadd double %50, %49
store double %51, double* %14
%52 = load double, double* %13
%53 = load double*, double** %10
%54 = load i32, i32* %11
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %53, i64 %55
%57 = load double, double* %56
%58 = load double, double* %15
%59 = call double @llvm.fmuladd.f64(double %52, double %57, double %58)
store double %59, double* %15
br label %60
60: ; preds = %41
%61 = load i32, i32* %11
%62 = add nsw i32 %61, 1
store i32 %62, i32* %11
br label %20
63: ; preds = %35, %20
%64 = load double, double* %15
%65 = load double, double* %14
%66 = fdiv double %64, %65
ret double %66
}

LLVM IR (-O2):
define double @ComputeA(double %0, i32 %1, double* nocapture %2, double* nocapture %3, double* nocapture %4) {
%6 = fmul double %0, 0x401921FB54442D18
%7 = fptosi double %6 to i32
%8 = tail call double @cos(i32 %7)
%9 = icmp slt i32 %1, 0
br i1 %9, label %36, label %10
10: ; preds = %5
%11 = add nuw i32 %1, 1
%12 = zext i32 %11 to i64
br label %13
13: ; preds = %10, %26
%14 = phi i64 [ 0, %10 ], [ %34, %26 ]
%15 = phi double [ 0.000000e+00, %10 ], [ %33, %26 ]
%16 = phi double [ 0.000000e+00, %10 ], [ %30, %26 ]
%17 = getelementptr inbounds double, double* %3, i64 %14
%18 = load double, double* %17
%19 = fsub double %8, %18
%20 = tail call double @llvm.fabs.f64(double %19)
%21 = fcmp olt double %20, 0x3E7AD7F29ABCAF48
br i1 %21, label %22, label %26
22: ; preds = %13
%23 = and i64 %14, 4294967295
%24 = getelementptr inbounds double, double* %4, i64 %23
%25 = load double, double* %24
br label %36
26: ; preds = %13
%27 = getelementptr inbounds double, double* %2, i64 %14
%28 = load double, double* %27
%29 = fdiv double %28, %19
%30 = fadd double %16, %29
%31 = getelementptr inbounds double, double* %4, i64 %14
%32 = load double, double* %31
%33 = tail call double @llvm.fmuladd.f64(double %29, double %32, double %15)
%34 = add nuw nsw i64 %14, 1
%35 = icmp eq i64 %34, %12
br i1 %35, label %36, label %13
36: ; preds = %26, %5, %22
%37 = phi double [ 1.000000e+00, %22 ], [ 0.000000e+00, %5 ], [ %30, %26 ]
%38 = phi double [ %25, %22 ], [ 0.000000e+00, %5 ], [ %33, %26 ]
%39 = fdiv double %38, %37
ret double %39
}