float estimateAngle(int acc, int gyro, float oldAng, int elapsed) {
  float angleAcc, angleInc, estAngle;
  float secs;
  secs = (float)elapsed / 1e6f;
  angleAcc = (float)acc * 90.0f / 256.0f;
  angleInc = (float)gyro * secs * 2000.0f / 32768.0f;
  estAngle = 0.75 * (oldAng + angleInc) + 0.25 * angleAcc;
  return estAngle;
}


x86 assembly (clang, -O0):
<estimateAngle>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cvtsi2ssl -0x10(%rbp),%xmm0
movss  0xf01(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
cvtsi2ssl -0x4(%rbp),%xmm0
movss  0xee7(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xed7(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
cvtsi2ssl -0x8(%rbp),%xmm0
mulss  -0x20(%rbp),%xmm0
movss  0xeb8(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xea8(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
addss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x14(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
movsd  0xe78(%rip),%xmm1
mulsd  %xmm2,%xmm1
movsd  0xe64(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<estimateAngle>:
cvtsi2ss %edx,%xmm1
divss  0xef4(%rip),%xmm1
cvtsi2ss %edi,%xmm2
mulss  0xeec(%rip),%xmm2
mulss  0xee8(%rip),%xmm2
cvtsi2ss %esi,%xmm3
mulss  %xmm1,%xmm3
mulss  0xedc(%rip),%xmm3
mulss  0xed8(%rip),%xmm3
addss  %xmm0,%xmm3
xorps  %xmm0,%xmm0
cvtss2sd %xmm3,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
mulsd  0xec6(%rip),%xmm1
mulsd  0xec6(%rip),%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
ret

LLVM IR (-O0):
define float @estimateAngle(i32 %0, i32 %1, float %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca float
%8 = alloca i32
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
store i32 %0, i32* %5
store i32 %1, i32* %6
store float %2, float* %7
store i32 %3, i32* %8
%13 = load i32, i32* %8
%14 = sitofp i32 %13 to float
%15 = fdiv float %14, 1.000000e+06
store float %15, float* %12
%16 = load i32, i32* %5
%17 = sitofp i32 %16 to float
%18 = fmul float %17, 9.000000e+01
%19 = fdiv float %18, 2.560000e+02
store float %19, float* %9
%20 = load i32, i32* %6
%21 = sitofp i32 %20 to float
%22 = load float, float* %12
%23 = fmul float %21, %22
%24 = fmul float %23, 2.000000e+03
%25 = fdiv float %24, 3.276800e+04
store float %25, float* %10
%26 = load float, float* %7
%27 = load float, float* %10
%28 = fadd float %26, %27
%29 = fpext float %28 to double
%30 = load float, float* %9
%31 = fpext float %30 to double
%32 = fmul double 2.500000e-01, %31
%33 = call double @llvm.fmuladd.f64(double 7.500000e-01, double %29, double %32)
%34 = fptrunc double %33 to float
store float %34, float* %11
%35 = load float, float* %11
ret float %35
}

LLVM IR (-O2):
define float @estimateAngle(i32 %0, i32 %1, float %2, i32 %3) {
%5 = sitofp i32 %3 to float
%6 = fdiv float %5, 1.000000e+06
%7 = sitofp i32 %0 to float
%8 = fmul float %7, 9.000000e+01
%9 = fmul float %8, 3.906250e-03
%10 = sitofp i32 %1 to float
%11 = fmul float %6, %10
%12 = fmul float %11, 2.000000e+03
%13 = fmul float %12, 0x3F00000000000000
%14 = fadd float %13, %2
%15 = fpext float %14 to double
%16 = fpext float %9 to double
%17 = fmul double %16, 2.500000e-01
%18 = tail call double @llvm.fmuladd.f64(double %15, double 7.500000e-01, double %17)
%19 = fptrunc double %18 to float
ret float %19
}