unsigned V2Code(float f, unsigned long RB, unsigned long RW, int CR) {
  unsigned int c = (unsigned int)((((f) * (RW - RB) / CR) + RB) + .5);
  return (c > 255 ? 255 : c);
}


x86 assembly (clang, -O0):
<V2Code>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    %rcx,-0x30(%rbp)
sub    %rcx,%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0x28(%rbp)
test   %rax,%rax
movss  %xmm0,-0x24(%rbp)
js     1166 <V2Code+0x66>
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x30(%rbp),%rax
movss  -0x34(%rbp),%xmm0
movss  -0x24(%rbp),%xmm1
mulss  %xmm1,%xmm0
cvtsi2ssl -0x1c(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x40(%rbp)
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0x3c(%rbp)
test   %rax,%rax
movss  %xmm0,-0x38(%rbp)
js     11bf <V2Code+0xbf>
movss  -0x3c(%rbp),%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x40(%rbp),%xmm0
movss  -0x38(%rbp),%xmm1
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe27(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,-0x20(%rbp)
cmpl   $0xff,-0x20(%rbp)
jbe    11ff <V2Code+0xff>
mov    $0xff,%eax
mov    %eax,-0x44(%rbp)
jmp    1205 <V2Code+0x105>
mov    -0x20(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<V2Code>:
sub    %rdi,%rsi
js     110c <V2Code+0xc>
cvtsi2ss %rsi,%xmm1
jmp    1121 <V2Code+0x21>
mov    %rsi,%rax
shr    %rax
and    $0x1,%esi
or     %rax,%rsi
cvtsi2ss %rsi,%xmm1
addss  %xmm1,%xmm1
cvtsi2ss %edx,%xmm2
mulss  %xmm0,%xmm1
divss  %xmm2,%xmm1
test   %rdi,%rdi
js     113c <V2Code+0x3c>
xorps  %xmm0,%xmm0
cvtsi2ss %rdi,%xmm0
jmp    1154 <V2Code+0x54>
mov    %rdi,%rax
shr    %rax
and    $0x1,%edi
or     %rax,%rdi
xorps  %xmm0,%xmm0
cvtsi2ss %rdi,%xmm0
addss  %xmm0,%xmm0
addss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
addsd  0xe99(%rip),%xmm0
cvttsd2si %xmm0,%rcx
cmp    $0xff,%ecx
mov    $0xff,%eax
cmovb  %ecx,%eax
ret

LLVM IR (-O0):
define i32 @V2Code(float %0, i64 %1, i64 %2, i32 %3) {
%5 = alloca float
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
store float %0, float* %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i32 %3, i32* %8
%10 = load float, float* %5
%11 = load i64, i64* %7
%12 = load i64, i64* %6
%13 = sub i64 %11, %12
%14 = uitofp i64 %13 to float
%15 = fmul float %10, %14
%16 = load i32, i32* %8
%17 = sitofp i32 %16 to float
%18 = fdiv float %15, %17
%19 = load i64, i64* %6
%20 = uitofp i64 %19 to float
%21 = fadd float %18, %20
%22 = fpext float %21 to double
%23 = fadd double %22, 5.000000e-01
%24 = fptoui double %23 to i32
store i32 %24, i32* %9
%25 = load i32, i32* %9
%26 = icmp ugt i32 %25, 255
br i1 %26, label %27, label %28
27: ; preds = %4
br label %30
28: ; preds = %4
%29 = load i32, i32* %9
br label %30
30: ; preds = %28, %27
%31 = phi i32 [ 255, %27 ], [ %29, %28 ]
ret i32 %31
}

LLVM IR (-O2):
define i32 @V2Code(float %0, i64 %1, i64 %2, i32 %3) {
%5 = sub i64 %2, %1
%6 = uitofp i64 %5 to float
%7 = fmul float %6, %0
%8 = sitofp i32 %3 to float
%9 = fdiv float %7, %8
%10 = uitofp i64 %1 to float
%11 = fadd float %9, %10
%12 = fpext float %11 to double
%13 = fadd double %12, 5.000000e-01
%14 = fptoui double %13 to i32
%15 = icmp ult i32 %14, 255
%16 = select i1 %15, i32 %14, i32 255
ret i32 %16
}