#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 */
float GammaToLinearF(int);
int LinearToGammaF(float);
int ScaleDown(int a, int b, int c, int d) {
  const float A = GammaToLinearF(a);
  const float B = GammaToLinearF(b);
  const float C = GammaToLinearF(c);
  const float D = GammaToLinearF(d);
  return LinearToGammaF(0.25f * (A + B + C + D));
}


x86 assembly (clang, -O0):
<ScaleDown>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <GammaToLinearF@plt>
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <GammaToLinearF@plt>
movss  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <GammaToLinearF@plt>
movss  %xmm0,-0x1c(%rbp)
mov    -0x10(%rbp),%edi
call   1040 <GammaToLinearF@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0x14(%rbp),%xmm1
addss  -0x18(%rbp),%xmm1
addss  -0x1c(%rbp),%xmm1
addss  -0x20(%rbp),%xmm1
movss  0xe7c(%rip),%xmm0
mulss  %xmm1,%xmm0
call   1030 <LinearToGammaF@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ScaleDown>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %esi,%ebx
call   1040 <GammaToLinearF@plt>
movss  %xmm0,0xc(%rsp)
mov    %ebx,%edi
call   1040 <GammaToLinearF@plt>
movss  %xmm0,0x8(%rsp)
mov    %ebp,%edi
call   1040 <GammaToLinearF@plt>
movss  %xmm0,0x4(%rsp)
mov    %r14d,%edi
call   1040 <GammaToLinearF@plt>
movss  0x8(%rsp),%xmm1
addss  0xc(%rsp),%xmm1
addss  0x4(%rsp),%xmm1
addss  %xmm1,%xmm0
mulss  0xe86(%rip),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <LinearToGammaF@plt>

LLVM IR (-O0):
define i32 @ScaleDown(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
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%13 = load i32, i32* %5
%14 = call float @GammaToLinearF(i32 %13)
store float %14, float* %9
%15 = load i32, i32* %6
%16 = call float @GammaToLinearF(i32 %15)
store float %16, float* %10
%17 = load i32, i32* %7
%18 = call float @GammaToLinearF(i32 %17)
store float %18, float* %11
%19 = load i32, i32* %8
%20 = call float @GammaToLinearF(i32 %19)
store float %20, float* %12
%21 = load float, float* %9
%22 = load float, float* %10
%23 = fadd float %21, %22
%24 = load float, float* %11
%25 = fadd float %23, %24
%26 = load float, float* %12
%27 = fadd float %25, %26
%28 = fmul float 2.500000e-01, %27
%29 = call i32 @LinearToGammaF(float %28)
ret i32 %29
}

LLVM IR (-O2):
define i32 @ScaleDown(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call float @GammaToLinearF(i32 %0)
%6 = tail call float @GammaToLinearF(i32 %1)
%7 = tail call float @GammaToLinearF(i32 %2)
%8 = tail call float @GammaToLinearF(i32 %3)
%9 = fadd float %5, %6
%10 = fadd float %9, %7
%11 = fadd float %10, %8
%12 = fmul float %11, 2.500000e-01
%13 = tail call i32 @LinearToGammaF(float %12)
ret i32 %13
}