#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 */
typedef double vsquared;
typedef double rsquared;

/* Variables and functions */
double cos(double);
double sin(double);
double dot_product(double y, double aOverR, double esinE0, double ecosE0,
                   double n, double rsquared, double vsquared, double xdotv) {
  double y2, sy2, cy2, f, sy, cy, fdot, gdot, dotprod, g, fp;
  y2 = y / 2.0;
  sy2 = sin(y2);
  cy2 = cos(y2);
  f = 1.0 - aOverR * 2.0 * sy2 * sy2;
  sy = 2.0 * sy2 * cy2;
  cy = cy2 * cy2 - sy2 * sy2;
  g = (2.0 * sy2 * (esinE0 * sy2 + cy2 / aOverR)) / n;
  fp = 1.0 - cy * ecosE0 + sy * esinE0;
  fdot = -(aOverR / fp) * n * sy;
  gdot = 1.0 - 2.0 * sy2 * sy2 / fp;
  dotprod = f * fdot * (rsquared) + g * gdot * (vsquared) +
            (f * gdot + g * fdot) * (xdotv);
  return (dotprod);
}


x86 assembly (clang, -O0):
<dot_product>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  %xmm5,-0x30(%rbp)
movsd  %xmm6,-0x38(%rbp)
movsd  %xmm7,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xea8(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  0xe79(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe3f(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xe36(%rip),%xmm0
mulsd  -0x50(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xde7(%rip),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm3
movsd  -0x58(%rbp),%xmm2
divsd  -0x10(%rbp),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x70(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm0,%xmm1
movsd  0xd80(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
divsd  -0x98(%rbp),%xmm0
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x28(%rbp),%xmm0
mulsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xd2f(%rip),%xmm1
mulsd  -0x50(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
divsd  -0x98(%rbp),%xmm1
ff
movsd  0xd0d(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x60(%rbp),%xmm1
mulsd  -0x78(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x90(%rbp),%xmm0
ff
mulsd  -0x80(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
movsd  -0x80(%rbp),%xmm3
movsd  -0x90(%rbp),%xmm2
ff
mulsd  -0x78(%rbp),%xmm2
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
movsd  -0x40(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dot_product>:
sub    $0x58,%rsp
movsd  %xmm7,0x38(%rsp)
movsd  %xmm6,0x30(%rsp)
movsd  %xmm5,0x28(%rsp)
movsd  %xmm4,0x18(%rsp)
movsd  %xmm3,0x20(%rsp)
movsd  %xmm2,0x10(%rsp)
movaps %xmm1,0x40(%rsp)
mulsd  0xeab(%rip),%xmm0
movsd  %xmm0,(%rsp)
call   1030 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1040 <cos@plt>
movsd  0xe91(%rip),%xmm1
movapd 0x40(%rsp),%xmm10
mulsd  %xmm10,%xmm1
movsd  0x8(%rsp),%xmm6
mulsd  %xmm6,%xmm1
mulsd  %xmm6,%xmm1
movsd  0xe77(%rip),%xmm2
addsd  %xmm2,%xmm1
movapd %xmm6,%xmm3
addsd  %xmm6,%xmm3
movapd %xmm3,%xmm4
mulsd  %xmm0,%xmm4
movapd %xmm6,%xmm5
movapd %xmm6,%xmm9
mulsd  %xmm6,%xmm5
movapd %xmm0,%xmm6
mulsd  %xmm0,%xmm6
subsd  %xmm5,%xmm6
divsd  %xmm10,%xmm0
movapd %xmm4,%xmm5
movsd  0x10(%rsp),%xmm7
mulsd  %xmm7,%xmm5
mulsd  %xmm9,%xmm7
addsd  %xmm7,%xmm0
mulsd  %xmm3,%xmm0
movsd  0x18(%rsp),%xmm8
divsd  %xmm8,%xmm0
mulsd  0x20(%rsp),%xmm6
movapd %xmm2,%xmm7
subsd  %xmm6,%xmm7
addsd  %xmm5,%xmm7
movapd %xmm10,%xmm5
xorpd  0xe0f(%rip),%xmm5
divsd  %xmm7,%xmm5
mulsd  %xmm8,%xmm5
mulsd  %xmm4,%xmm5
mulsd  %xmm9,%xmm3
divsd  %xmm7,%xmm3
subsd  %xmm3,%xmm2
movapd %xmm0,%xmm3
mulsd  %xmm2,%xmm3
mulsd  %xmm1,%xmm2
mulsd  %xmm5,%xmm1
mulsd  0x30(%rsp),%xmm3
mulsd  0x28(%rsp),%xmm1
addsd  %xmm3,%xmm1
mulsd  %xmm5,%xmm0
addsd  %xmm2,%xmm0
mulsd  0x38(%rsp),%xmm0
addsd  %xmm1,%xmm0
add    $0x58,%rsp
ret

LLVM IR (-O0):
define double @dot_product(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7) {
%9 = alloca double
%10 = alloca double
%11 = alloca double
%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
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca double
store double %0, double* %9
store double %1, double* %10
store double %2, double* %11
store double %3, double* %12
store double %4, double* %13
store double %5, double* %14
store double %6, double* %15
store double %7, double* %16
%28 = load double, double* %9
%29 = fdiv double %28, 2.000000e+00
store double %29, double* %17
%30 = load double, double* %17
%31 = call double @sin(double %30)
store double %31, double* %18
%32 = load double, double* %17
%33 = call double @cos(double %32)
store double %33, double* %19
%34 = load double, double* %10
%35 = fmul double %34, 2.000000e+00
%36 = load double, double* %18
%37 = fmul double %35, %36
%38 = load double, double* %18
%39 = fneg double %37
%40 = call double @llvm.fmuladd.f64(double %39, double %38, double 1.000000e+00)
store double %40, double* %20
%41 = load double, double* %18
%42 = fmul double 2.000000e+00, %41
%43 = load double, double* %19
%44 = fmul double %42, %43
store double %44, double* %21
%45 = load double, double* %19
%46 = load double, double* %19
%47 = load double, double* %18
%48 = load double, double* %18
%49 = fmul double %47, %48
%50 = fneg double %49
%51 = call double @llvm.fmuladd.f64(double %45, double %46, double %50)
store double %51, double* %22
%52 = load double, double* %18
%53 = fmul double 2.000000e+00, %52
%54 = load double, double* %11
%55 = load double, double* %18
%56 = load double, double* %19
%57 = load double, double* %10
%58 = fdiv double %56, %57
%59 = call double @llvm.fmuladd.f64(double %54, double %55, double %58)
%60 = fmul double %53, %59
%61 = load double, double* %13
%62 = fdiv double %60, %61
store double %62, double* %26
%63 = load double, double* %22
%64 = load double, double* %12
%65 = fneg double %63
%66 = call double @llvm.fmuladd.f64(double %65, double %64, double 1.000000e+00)
%67 = load double, double* %21
%68 = load double, double* %11
%69 = call double @llvm.fmuladd.f64(double %67, double %68, double %66)
store double %69, double* %27
%70 = load double, double* %10
%71 = load double, double* %27
%72 = fdiv double %70, %71
%73 = fneg double %72
%74 = load double, double* %13
%75 = fmul double %73, %74
%76 = load double, double* %21
%77 = fmul double %75, %76
store double %77, double* %23
%78 = load double, double* %18
%79 = fmul double 2.000000e+00, %78
%80 = load double, double* %18
%81 = fmul double %79, %80
%82 = load double, double* %27
%83 = fdiv double %81, %82
%84 = fsub double 1.000000e+00, %83
store double %84, double* %24
%85 = load double, double* %20
%86 = load double, double* %23
%87 = fmul double %85, %86
%88 = load double, double* %14
%89 = load double, double* %26
%90 = load double, double* %24
%91 = fmul double %89, %90
%92 = load double, double* %15
%93 = fmul double %91, %92
%94 = call double @llvm.fmuladd.f64(double %87, double %88, double %93)
%95 = load double, double* %20
%96 = load double, double* %24
%97 = load double, double* %26
%98 = load double, double* %23
%99 = fmul double %97, %98
%100 = call double @llvm.fmuladd.f64(double %95, double %96, double %99)
%101 = load double, double* %16
%102 = call double @llvm.fmuladd.f64(double %100, double %101, double %94)
store double %102, double* %25
%103 = load double, double* %25
ret double %103
}

LLVM IR (-O2):
define double @dot_product(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7) {
%9 = fmul double %0, 5.000000e-01
%10 = tail call double @sin(double %9)
%11 = tail call double @cos(double %9)
%12 = fmul double %1, -2.000000e+00
%13 = fmul double %12, %10
%14 = tail call double @llvm.fmuladd.f64(double %13, double %10, double 1.000000e+00)
%15 = fmul double %10, 2.000000e+00
%16 = fmul double %15, %11
%17 = fneg double %10
%18 = fmul double %10, %17
%19 = tail call double @llvm.fmuladd.f64(double %11, double %11, double %18)
%20 = fdiv double %11, %1
%21 = tail call double @llvm.fmuladd.f64(double %2, double %10, double %20)
%22 = fmul double %15, %21
%23 = fdiv double %22, %4
%24 = fneg double %19
%25 = tail call double @llvm.fmuladd.f64(double %24, double %3, double 1.000000e+00)
%26 = tail call double @llvm.fmuladd.f64(double %16, double %2, double %25)
%27 = fneg double %1
%28 = fdiv double %27, %26
%29 = fmul double %28, %4
%30 = fmul double %16, %29
%31 = fmul double %10, %15
%32 = fdiv double %31, %26
%33 = fsub double 1.000000e+00, %32
%34 = fmul double %14, %30
%35 = fmul double %23, %33
%36 = fmul double %35, %6
%37 = tail call double @llvm.fmuladd.f64(double %34, double %5, double %36)
%38 = fmul double %23, %30
%39 = tail call double @llvm.fmuladd.f64(double %14, double %33, double %38)
%40 = tail call double @llvm.fmuladd.f64(double %39, double %7, double %37)
ret double %40
}