double GetCombineCostFactor(int histo_size, int quality) {
  double combine_cost_factor = 0.16;
  if (quality < 90) {
    if (histo_size > 256)
      combine_cost_factor /= 2.;
    if (histo_size > 512)
      combine_cost_factor /= 2.;
    if (histo_size > 1024)
      combine_cost_factor /= 2.;
    if (quality <= 50)
      combine_cost_factor /= 2.;
  }
  return combine_cost_factor;
}


x86 assembly (clang, -O0):
<GetCombineCostFactor>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  0xeee(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
cmpl   $0x5a,-0x8(%rbp)
jge    11af <GetCombineCostFactor+0xaf>
cmpl   $0x100,-0x4(%rbp)
jle    1144 <GetCombineCostFactor+0x44>
movsd  -0x10(%rbp),%xmm0
movsd  0xecd(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
cmpl   $0x200,-0x4(%rbp)
jle    1167 <GetCombineCostFactor+0x67>
movsd  -0x10(%rbp),%xmm0
movsd  0xeaa(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
cmpl   $0x400,-0x4(%rbp)
jle    118a <GetCombineCostFactor+0x8a>
movsd  -0x10(%rbp),%xmm0
movsd  0xe87(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
cmpl   $0x32,-0x8(%rbp)
jg     11aa <GetCombineCostFactor+0xaa>
movsd  -0x10(%rbp),%xmm0
movsd  0xe67(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11af <GetCombineCostFactor+0xaf>
movsd  -0x10(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetCombineCostFactor>:
cmp    $0x59,%esi
jg     113a <GetCombineCostFactor+0x3a>
xor    %eax,%eax
cmp    $0x101,%edi
setge  %al
lea    0xef9(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm0
movsd  0xee4(%rip),%xmm1
cmp    $0x201,%edi
jge    1143 <GetCombineCostFactor+0x43>
cmp    $0x401,%edi
jge    114f <GetCombineCostFactor+0x4f>
cmp    $0x33,%esi
jl     1158 <GetCombineCostFactor+0x58>
ret
movsd  0xebe(%rip),%xmm0
ret
mulsd  %xmm1,%xmm0
cmp    $0x401,%edi
jl     1134 <GetCombineCostFactor+0x34>
mulsd  %xmm1,%xmm0
cmp    $0x33,%esi
jge    1139 <GetCombineCostFactor+0x39>
mulsd  %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @GetCombineCostFactor(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
store i32 %0, i32* %3
store i32 %1, i32* %4
store double 1.600000e-01, double* %5
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 90
br i1 %7, label %8, label %33
8: ; preds = %2
%9 = load i32, i32* %3
%10 = icmp sgt i32 %9, 256
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load double, double* %5
%13 = fdiv double %12, 2.000000e+00
store double %13, double* %5
br label %14
14: ; preds = %11, %8
%15 = load i32, i32* %3
%16 = icmp sgt i32 %15, 512
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load double, double* %5
%19 = fdiv double %18, 2.000000e+00
store double %19, double* %5
br label %20
20: ; preds = %17, %14
%21 = load i32, i32* %3
%22 = icmp sgt i32 %21, 1024
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load double, double* %5
%25 = fdiv double %24, 2.000000e+00
store double %25, double* %5
br label %26
26: ; preds = %23, %20
%27 = load i32, i32* %4
%28 = icmp sle i32 %27, 50
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load double, double* %5
%31 = fdiv double %30, 2.000000e+00
store double %31, double* %5
br label %32
32: ; preds = %29, %26
br label %33
33: ; preds = %32, %2
%34 = load double, double* %5
ret double %34
}

LLVM IR (-O2):
define double @GetCombineCostFactor(i32 %0, i32 %1) {
%3 = icmp slt i32 %1, 90
br i1 %3, label %4, label %16
4: ; preds = %2
%5 = icmp sgt i32 %0, 256
%6 = select i1 %5, double 8.000000e-02, double 1.600000e-01
%7 = icmp sgt i32 %0, 512
%8 = fmul double %6, 5.000000e-01
%9 = select i1 %7, double %8, double %6
%10 = icmp sgt i32 %0, 1024
%11 = fmul double %9, 5.000000e-01
%12 = select i1 %10, double %11, double %9
%13 = icmp slt i32 %1, 51
%14 = fmul double %12, 5.000000e-01
%15 = select i1 %13, double %14, double %12
br label %16
16: ; preds = %4, %2
%17 = phi double [ 1.600000e-01, %2 ], [ %15, %4 ]
ret double %17
}