float ssim_end1_10b(int s1, int s2, int ss, int s12) {
  static const float ssim_c1 =
      .01 * .01 * ((1 << 10) - 1) * ((1 << 10) - 1) * 64;
  static const float ssim_c2 =
      .03 * .03 * ((1 << 10) - 1) * ((1 << 10) - 1) * 64 * 63;
  float fs1 = s1;
  float fs2 = s2;
  float fss = ss;
  float fs12 = s12;
  float vars = fss * 64 - fs1 * fs1 - fs2 * fs2;
  float covar = fs12 * 64 - fs1 * fs2;
  return (float)(2 * fs1 * fs2 + ssim_c1) * (float)(2 * covar + ssim_c2) /
         ((float)(fs1 * fs1 + fs2 * fs2 + ssim_c1) * (float)(vars + ssim_c2));
}


x86 assembly (clang, -O0):
<ssim_end1_10b>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
cvtsi2ssl -0x4(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
cvtsi2ssl -0x8(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
cvtsi2ssl -0x10(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x1c(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  0xeb0(%rip),%xmm2
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0x18(%rbp),%xmm0
movss  -0x18(%rbp),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x20(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
mulss  -0x18(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
movss  0xe60(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  0xe47(%rip),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xe2d(%rip),%xmm1
addss  %xmm1,%xmm0
movss  -0x28(%rbp),%xmm1
addss  %xmm1,%xmm1
movss  0xe14(%rip),%xmm2
addss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  -0x14(%rbp),%xmm1
movss  -0x14(%rbp),%xmm3
movss  -0x18(%rbp),%xmm2
mulss  -0x18(%rbp),%xmm2
mulss  %xmm3,%xmm1
addss  %xmm2,%xmm1
movss  0xdec(%rip),%xmm2
addss  %xmm2,%xmm1
movss  0xddc(%rip),%xmm2
addss  -0x24(%rbp),%xmm2
mulss  %xmm2,%xmm1
divss  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<ssim_end1_10b>:
movd   %esi,%xmm0
movd   %edi,%xmm1
punpckldq %xmm0,%xmm1
cvtdq2ps %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2ss %edx,%xmm1
movaps %xmm0,%xmm3
shufps $0x55,%xmm0,%xmm3
movaps 0xeec(%rip),%xmm2
xorps  %xmm3,%xmm2
movaps %xmm3,%xmm4
movaps %xmm0,%xmm5
shufps $0x11,0xeeb(%rip),%xmm5
11
mulss  %xmm0,%xmm4
movaps %xmm0,%xmm6
shufps $0xe8,%xmm0,%xmm5
movlhps %xmm0,%xmm2
shufps $0xe2,%xmm0,%xmm2
mulps  %xmm0,%xmm2
mulss  %xmm0,%xmm0
movss  0xeaa(%rip),%xmm7
mulss  %xmm7,%xmm1
subss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2ss %ecx,%xmm0
mulss  %xmm7,%xmm0
subss  %xmm4,%xmm0
addss  %xmm6,%xmm6
unpcklps %xmm0,%xmm6
mulps  %xmm6,%xmm5
movaps 0xeb2(%rip),%xmm4
addps  %xmm4,%xmm5
movaps %xmm5,%xmm0
shufps $0x55,%xmm5,%xmm0
mulss  %xmm5,%xmm0
mulss  %xmm3,%xmm3
unpcklps %xmm1,%xmm3
addps  %xmm3,%xmm2
addps  %xmm4,%xmm2
movaps %xmm2,%xmm1
shufps $0x55,%xmm2,%xmm1
mulss  %xmm2,%xmm1
divss  %xmm1,%xmm0
ret

LLVM IR (-O0):
@ssim_end1_10b.ssim_c1 = internal constant float 0x40BA29C920000000
@ssim_end1_10b.ssim_c2 = internal constant float 0x414CF94640000000
define float @ssim_end1_10b(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%15 = load i32, i32* %5
%16 = sitofp i32 %15 to float
store float %16, float* %9
%17 = load i32, i32* %6
%18 = sitofp i32 %17 to float
store float %18, float* %10
%19 = load i32, i32* %7
%20 = sitofp i32 %19 to float
store float %20, float* %11
%21 = load i32, i32* %8
%22 = sitofp i32 %21 to float
store float %22, float* %12
%23 = load float, float* %11
%24 = load float, float* %9
%25 = load float, float* %9
%26 = fmul float %24, %25
%27 = fneg float %26
%28 = call float @llvm.fmuladd.f32(float %23, float 6.400000e+01, float %27)
%29 = load float, float* %10
%30 = load float, float* %10
%31 = fneg float %29
%32 = call float @llvm.fmuladd.f32(float %31, float %30, float %28)
store float %32, float* %13
%33 = load float, float* %12
%34 = load float, float* %9
%35 = load float, float* %10
%36 = fmul float %34, %35
%37 = fneg float %36
%38 = call float @llvm.fmuladd.f32(float %33, float 6.400000e+01, float %37)
store float %38, float* %14
%39 = load float, float* %9
%40 = fmul float 2.000000e+00, %39
%41 = load float, float* %10
%42 = call float @llvm.fmuladd.f32(float %40, float %41, float 0x40BA29C920000000)
%43 = load float, float* %14
%44 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %43, float 0x414CF94640000000)
%45 = fmul float %42, %44
%46 = load float, float* %9
%47 = load float, float* %9
%48 = load float, float* %10
%49 = load float, float* %10
%50 = fmul float %48, %49
%51 = call float @llvm.fmuladd.f32(float %46, float %47, float %50)
%52 = fadd float %51, 0x40BA29C920000000
%53 = load float, float* %13
%54 = fadd float %53, 0x414CF94640000000
%55 = fmul float %52, %54
%56 = fdiv float %45, %55
ret float %56
}

LLVM IR (-O2):
define float @ssim_end1_10b(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = insertelement <2 x i32> poison, i32 %0, i64 0
%6 = insertelement <2 x i32> %5, i32 %1, i64 1
%7 = sitofp <2 x i32> %6 to <2 x float>
%8 = sitofp i32 %2 to float
%9 = sitofp i32 %3 to float
%10 = extractelement <2 x float> %7, i64 0
%11 = fneg float %10
%12 = fmul float %10, %11
%13 = tail call float @llvm.fmuladd.f32(float %8, float 6.400000e+01, float %12)
%14 = extractelement <2 x float> %7, i64 1
%15 = fneg float %14
%16 = fmul float %14, %11
%17 = tail call float @llvm.fmuladd.f32(float %9, float 6.400000e+01, float %16)
%18 = fmul float %10, 2.000000e+00
%19 = insertelement <2 x float> poison, float %18, i64 0
%20 = insertelement <2 x float> %19, float %17, i64 1
%21 = shufflevector <2 x float> <float poison, float 2.000000e+00>, <2 x float> %7, <2 x i32> <i32 3, i32 1>
%22 = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %20, <2 x float> %21, <2 x float> <float 0x40BA29C920000000, float 0x414CF94640000000>)
%23 = shufflevector <2 x float> %22, <2 x float> poison, <2 x i32> <i32 1, i32 undef>
%24 = fmul <2 x float> %22, %23
%25 = extractelement <2 x float> %24, i64 0
%26 = fmul float %14, %14
%27 = insertelement <2 x float> %7, float %15, i64 1
%28 = insertelement <2 x float> poison, float %26, i64 0
%29 = insertelement <2 x float> %28, float %13, i64 1
%30 = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %27, <2 x float> %7, <2 x float> %29)
%31 = fadd <2 x float> %30, <float 0x40BA29C920000000, float 0x414CF94640000000>
%32 = shufflevector <2 x float> %31, <2 x float> poison, <2 x i32> <i32 1, i32 undef>
%33 = fmul <2 x float> %31, %32
%34 = extractelement <2 x float> %33, i64 0
%35 = fdiv float %25, %34
ret float %35
}