unsigned char smoothing(unsigned char px0, unsigned char px1, unsigned char px2,
                        unsigned char px3, unsigned char px4, unsigned char px5,
                        unsigned char px6, unsigned char px7,
                        unsigned char px8) {
  double px[9] = {px0, px1, px2, px3, px4, px5, px6, px7, px8};
  double px_out = 0.0;
  for (int i = 0; i < 9; i++) {
    if (i == 4) {
      px[i] *= 2;
    }
    px_out += px[i];
  }
  px_out /= 10;
  return (unsigned char)px_out;
}


x86 assembly (clang, -O0):
<smoothing>:
push   %rbp
mov    %rsp,%rbp
mov    %r8d,-0x6c(%rbp)
mov    %ecx,%eax
mov    -0x6c(%rbp),%ecx
mov    %eax,-0x68(%rbp)
mov    %edx,%eax
mov    -0x68(%rbp),%edx
mov    %eax,-0x64(%rbp)
mov    %esi,%eax
mov    -0x64(%rbp),%esi
mov    %eax,-0x60(%rbp)
mov    %edi,%r8d
mov    -0x60(%rbp),%edi
mov    %r9b,%al
mov    0x20(%rbp),%r9b
mov    0x18(%rbp),%r9b
mov    0x10(%rbp),%r9b
mov    %r8b,-0x1(%rbp)
mov    %dil,-0x2(%rbp)
mov    %sil,-0x3(%rbp)
mov    %dl,-0x4(%rbp)
mov    %cl,-0x5(%rbp)
mov    %al,-0x6(%rbp)
movzbl -0x1(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x50(%rbp)
movzbl -0x2(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x48(%rbp)
movzbl -0x3(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x40(%rbp)
movzbl -0x4(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x38(%rbp)
movzbl -0x5(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x30(%rbp)
movzbl -0x6(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movzbl 0x10(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movzbl 0x18(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movzbl 0x20(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
cmpl   $0x9,-0x5c(%rbp)
jge    121c <smoothing+0x11c>
cmpl   $0x4,-0x5c(%rbp)
jne    11fa <smoothing+0xfa>
movslq -0x5c(%rbp),%rax
movsd  0xe1a(%rip),%xmm0
mulsd  -0x50(%rbp,%rax,8),%xmm0
movsd  %xmm0,-0x50(%rbp,%rax,8)
movslq -0x5c(%rbp),%rax
movsd  -0x50(%rbp,%rax,8),%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11ce <smoothing+0xce>
movsd  -0x58(%rbp),%xmm0
movsd  0xdd7(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
cvttsd2si -0x58(%rbp),%eax
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<smoothing>:
movzbl 0x18(%rsp),%r10d
movzbl 0x10(%rsp),%r11d
movzbl 0x8(%rsp),%eax
cvtsi2sd %r8d,%xmm0
addsd  %xmm0,%xmm0
cvtsi2sd %edi,%xmm1
cvtsi2sd %esi,%xmm2
addsd  %xmm1,%xmm2
xorps  %xmm1,%xmm1
cvtsi2sd %edx,%xmm1
addsd  %xmm2,%xmm1
xorps  %xmm2,%xmm2
cvtsi2sd %ecx,%xmm2
addsd  %xmm1,%xmm2
addsd  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtsi2sd %r9d,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
addsd  %xmm2,%xmm0
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %r11d,%xmm0
addsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %r10d,%xmm1
addsd  %xmm0,%xmm1
divsd  0xe89(%rip),%xmm1
cvttsd2si %xmm1,%eax
ret

LLVM IR (-O0):
define zeroext i8 @smoothing(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, i8 zeroext %3, i8 zeroext %4, i8 zeroext %5, i8 zeroext %6, i8 zeroext %7, i8 zeroext %8) {
%10 = alloca i8
%11 = alloca i8
%12 = alloca i8
%13 = alloca i8
%14 = alloca i8
%15 = alloca i8
%16 = alloca i8
%17 = alloca i8
%18 = alloca i8
%19 = alloca [9 x double]
%20 = alloca double
%21 = alloca i32
store i8 %0, i8* %10
store i8 %1, i8* %11
store i8 %2, i8* %12
store i8 %3, i8* %13
store i8 %4, i8* %14
store i8 %5, i8* %15
store i8 %6, i8* %16
store i8 %7, i8* %17
store i8 %8, i8* %18
%22 = getelementptr inbounds [9 x double], [9 x double]* %19, i64 0, i64 0
%23 = load i8, i8* %10
%24 = uitofp i8 %23 to double
store double %24, double* %22
%25 = getelementptr inbounds double, double* %22, i64 1
%26 = load i8, i8* %11
%27 = uitofp i8 %26 to double
store double %27, double* %25
%28 = getelementptr inbounds double, double* %25, i64 1
%29 = load i8, i8* %12
%30 = uitofp i8 %29 to double
store double %30, double* %28
%31 = getelementptr inbounds double, double* %28, i64 1
%32 = load i8, i8* %13
%33 = uitofp i8 %32 to double
store double %33, double* %31
%34 = getelementptr inbounds double, double* %31, i64 1
%35 = load i8, i8* %14
%36 = uitofp i8 %35 to double
store double %36, double* %34
%37 = getelementptr inbounds double, double* %34, i64 1
%38 = load i8, i8* %15
%39 = uitofp i8 %38 to double
store double %39, double* %37
%40 = getelementptr inbounds double, double* %37, i64 1
%41 = load i8, i8* %16
%42 = uitofp i8 %41 to double
store double %42, double* %40
%43 = getelementptr inbounds double, double* %40, i64 1
%44 = load i8, i8* %17
%45 = uitofp i8 %44 to double
store double %45, double* %43
%46 = getelementptr inbounds double, double* %43, i64 1
%47 = load i8, i8* %18
%48 = uitofp i8 %47 to double
store double %48, double* %46
store double 0.000000e+00, double* %20
store i32 0, i32* %21
br label %49
49: ; preds = %68, %9
%50 = load i32, i32* %21
%51 = icmp slt i32 %50, 9
br i1 %51, label %52, label %71
52: ; preds = %49
%53 = load i32, i32* %21
%54 = icmp eq i32 %53, 4
br i1 %54, label %55, label %61
55: ; preds = %52
%56 = load i32, i32* %21
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [9 x double], [9 x double]* %19, i64 0, i64 %57
%59 = load double, double* %58
%60 = fmul double %59, 2.000000e+00
store double %60, double* %58
br label %61
61: ; preds = %55, %52
%62 = load i32, i32* %21
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [9 x double], [9 x double]* %19, i64 0, i64 %63
%65 = load double, double* %64
%66 = load double, double* %20
%67 = fadd double %66, %65
store double %67, double* %20
br label %68
68: ; preds = %61
%69 = load i32, i32* %21
%70 = add nsw i32 %69, 1
store i32 %70, i32* %21
br label %49
71: ; preds = %49
%72 = load double, double* %20
%73 = fdiv double %72, 1.000000e+01
store double %73, double* %20
%74 = load double, double* %20
%75 = fptoui double %74 to i8
ret i8 %75
}

LLVM IR (-O2):
define zeroext i8 @smoothing(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, i8 zeroext %3, i8 zeroext %4, i8 zeroext %5, i8 zeroext %6, i8 zeroext %7, i8 zeroext %8) {
%10 = uitofp i8 %4 to double
%11 = fmul double %10, 2.000000e+00
%12 = uitofp i8 %0 to double
%13 = uitofp i8 %1 to double
%14 = fadd double %12, %13
%15 = uitofp i8 %2 to double
%16 = fadd double %14, %15
%17 = uitofp i8 %3 to double
%18 = fadd double %16, %17
%19 = fadd double %18, %11
%20 = uitofp i8 %5 to double
%21 = fadd double %19, %20
%22 = uitofp i8 %6 to double
%23 = fadd double %21, %22
%24 = uitofp i8 %7 to double
%25 = fadd double %23, %24
%26 = uitofp i8 %8 to double
%27 = fadd double %25, %26
%28 = fdiv double %27, 1.000000e+01
%29 = fptoui double %28 to i8
ret i8 %29
}