#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(float);
float Interpolate(float a, float b, float x) {
  float f = (1.0 - cos(x * 3.1415927)) * 0.5;
  return a * (1.0 - f) + b * f;
}


x86 assembly (clang, -O0):
<Interpolate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xed8(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <cos@plt>
movaps %xmm0,%xmm1
movsd  0xeb0(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  0xeac(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xe7d(%rip),%xmm2
subsd  %xmm1,%xmm2
movss  -0x8(%rbp),%xmm1
mulss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Interpolate>:
push   %rax
movss  %xmm1,0x4(%rsp)
movss  %xmm0,(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
mulsd  0xed5(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <cos@plt>
movsd  0xecc(%rip),%xmm1
movapd %xmm1,%xmm2
subsd  %xmm0,%xmm2
mulsd  0xec4(%rip),%xmm2
xorps  %xmm0,%xmm0
cvtsd2ss %xmm2,%xmm0
movss  (%rsp),%xmm2
cvtss2sd %xmm2,%xmm2
cvtss2sd %xmm0,%xmm3
subsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm1
movss  0x4(%rsp),%xmm2
mulss  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @Interpolate(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store float %0, float* %4
store float %1, float* %5
store float %2, float* %6
%8 = load float, float* %6
%9 = fpext float %8 to double
%10 = fmul double %9, 0x400921FB5A7ED197
%11 = fptrunc double %10 to float
%12 = call double @cos(float %11)
%13 = fsub double 1.000000e+00, %12
%14 = fmul double %13, 5.000000e-01
%15 = fptrunc double %14 to float
store float %15, float* %7
%16 = load float, float* %4
%17 = fpext float %16 to double
%18 = load float, float* %7
%19 = fpext float %18 to double
%20 = fsub double 1.000000e+00, %19
%21 = load float, float* %5
%22 = load float, float* %7
%23 = fmul float %21, %22
%24 = fpext float %23 to double
%25 = call double @llvm.fmuladd.f64(double %17, double %20, double %24)
%26 = fptrunc double %25 to float
ret float %26
}

LLVM IR (-O2):
define float @Interpolate(float %0, float %1, float %2) {
%4 = fpext float %2 to double
%5 = fmul double %4, 0x400921FB5A7ED197
%6 = fptrunc double %5 to float
%7 = tail call double @cos(float %6)
%8 = fsub double 1.000000e+00, %7
%9 = fmul double %8, 5.000000e-01
%10 = fptrunc double %9 to float
%11 = fpext float %0 to double
%12 = fpext float %10 to double
%13 = fsub double 1.000000e+00, %12
%14 = fmul float %10, %1
%15 = fpext float %14 to double
%16 = tail call double @llvm.fmuladd.f64(double %11, double %13, double %15)
%17 = fptrunc double %16 to float
ret float %17
}