int rd_pic_decision(double snrY_version1, double snrY_version2,
                    int bits_version1, int bits_version2,
                    double lambda_picture) {
  double cost_version1, cost_version2;
  cost_version1 = (double)bits_version1 * lambda_picture + snrY_version1;
  cost_version2 = (double)bits_version2 * lambda_picture + snrY_version2;
  if (cost_version2 > cost_version1 ||
      (cost_version2 == cost_version1 && snrY_version2 >= snrY_version1))
    return (0);
  else
    return (1);
}


x86 assembly (clang, -O0):
<rd_pic_decision>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
mov    %esi,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
cvtsi2sdl -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
ja     1187 <rd_pic_decision+0x87>
movsd  -0x38(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jne    1193 <rd_pic_decision+0x93>
jp     1193 <rd_pic_decision+0x93>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1193 <rd_pic_decision+0x93>
movl   $0x0,-0x4(%rbp)
jmp    119a <rd_pic_decision+0x9a>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<rd_pic_decision>:
cvtsi2sd %edi,%xmm3
mulsd  %xmm2,%xmm3
addsd  %xmm0,%xmm3
cvtsi2sd %esi,%xmm4
mulsd  %xmm2,%xmm4
addsd  %xmm1,%xmm4
ucomisd %xmm3,%xmm4
setbe  %al
setp   %cl
setne  %dl
or     %cl,%dl
ucomisd %xmm0,%xmm1
setb   %cl
or     %dl,%cl
and    %al,%cl
movzbl %cl,%eax
ret

LLVM IR (-O0):
define i32 @rd_pic_decision(double %0, double %1, i32 %2, i32 %3, double %4) {
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca double
store double %0, double* %7
store double %1, double* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store double %4, double* %11
%14 = load i32, i32* %9
%15 = sitofp i32 %14 to double
%16 = load double, double* %11
%17 = load double, double* %7
%18 = call double @llvm.fmuladd.f64(double %15, double %16, double %17)
store double %18, double* %12
%19 = load i32, i32* %10
%20 = sitofp i32 %19 to double
%21 = load double, double* %11
%22 = load double, double* %8
%23 = call double @llvm.fmuladd.f64(double %20, double %21, double %22)
store double %23, double* %13
%24 = load double, double* %13
%25 = load double, double* %12
%26 = fcmp ogt double %24, %25
br i1 %26, label %35, label %27
27: ; preds = %5
%28 = load double, double* %13
%29 = load double, double* %12
%30 = fcmp oeq double %28, %29
br i1 %30, label %31, label %36
31: ; preds = %27
%32 = load double, double* %8
%33 = load double, double* %7
%34 = fcmp oge double %32, %33
br i1 %34, label %35, label %36
35: ; preds = %31, %5
store i32 0, i32* %6
br label %37
36: ; preds = %31, %27
store i32 1, i32* %6
br label %37
37: ; preds = %36, %35
%38 = load i32, i32* %6
ret i32 %38
}

LLVM IR (-O2):
define i32 @rd_pic_decision(double %0, double %1, i32 %2, i32 %3, double %4) {
%6 = sitofp i32 %2 to double
%7 = tail call double @llvm.fmuladd.f64(double %6, double %4, double %0)
%8 = sitofp i32 %3 to double
%9 = tail call double @llvm.fmuladd.f64(double %8, double %4, double %1)
%10 = fcmp ule double %9, %7
%11 = fcmp une double %9, %7
%12 = fcmp ult double %1, %0
%13 = or i1 %12, %11
%14 = and i1 %10, %13
%15 = zext i1 %14 to i32
ret i32 %15
}