double statistics_weighted_compute_percent_missing(int number_in_array,
                                                   long weighted_input_count,
                                                   long count) {
  if (number_in_array > 0) {
    return (double)(weighted_input_count - count) /
           (double)weighted_input_count * 100.0;
  } else if (number_in_array == -1) {
    if (weighted_input_count) {
      return (double)(weighted_input_count - count) /
             (double)weighted_input_count * 100.0;
    } else {
      return -1.0;
    }
  } else {
    if (weighted_input_count)
      return 100.00;
    else
      return -1.0;
  }
}


x86 assembly (clang, -O0):
<statistics_weighted_compute_percent_missing>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    1146 <statistics_weighted_compute_percent_missing+0x46>
mov    -0x18(%rbp),%rax
sub    -0x20(%rbp),%rax
cvtsi2sd %rax,%xmm0
cvtsi2sdq -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  0xed0(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11c4 <statistics_weighted_compute_percent_missing+0xc4>
cmpl   $0xffffffff,-0xc(%rbp)
jne    119a <statistics_weighted_compute_percent_missing+0x9a>
cmpq   $0x0,-0x18(%rbp)
je     1188 <statistics_weighted_compute_percent_missing+0x88>
mov    -0x18(%rbp),%rax
sub    -0x20(%rbp),%rax
cvtsi2sd %rax,%xmm0
cvtsi2sdq -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe8e(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11c4 <statistics_weighted_compute_percent_missing+0xc4>
movsd  0xe70(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11c4 <statistics_weighted_compute_percent_missing+0xc4>
cmpq   $0x0,-0x18(%rbp)
je     11b7 <statistics_weighted_compute_percent_missing+0xb7>
movsd  0xe5b(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11c4 <statistics_weighted_compute_percent_missing+0xc4>
movsd  0xe41(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<statistics_weighted_compute_percent_missing>:
test   %edi,%edi
jle    111e <statistics_weighted_compute_percent_missing+0x1e>
cvtsi2sd %rsi,%xmm1
sub    %rdx,%rsi
cvtsi2sd %rsi,%xmm0
divsd  %xmm1,%xmm0
mulsd  0xefb(%rip),%xmm0
ret
cmp    $0xffffffff,%edi
je     1138 <statistics_weighted_compute_percent_missing+0x38>
xor    %eax,%eax
test   %rsi,%rsi
sete   %al
lea    0xece(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm0
ret
test   %rsi,%rsi
jne    1104 <statistics_weighted_compute_percent_missing+0x4>
movsd  0xecb(%rip),%xmm0
ret

LLVM IR (-O0):
define double @statistics_weighted_compute_percent_missing(i32 %0, i64 %1, i64 %2) {
%4 = alloca double
%5 = alloca i32
%6 = alloca i64
%7 = alloca i64
store i32 %0, i32* %5
store i64 %1, i64* %6
store i64 %2, i64* %7
%8 = load i32, i32* %5
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %19
10: ; preds = %3
%11 = load i64, i64* %6
%12 = load i64, i64* %7
%13 = sub nsw i64 %11, %12
%14 = sitofp i64 %13 to double
%15 = load i64, i64* %6
%16 = sitofp i64 %15 to double
%17 = fdiv double %14, %16
%18 = fmul double %17, 1.000000e+02
store double %18, double* %4
br label %40
19: ; preds = %3
%20 = load i32, i32* %5
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %35
22: ; preds = %19
%23 = load i64, i64* %6
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %34
25: ; preds = %22
%26 = load i64, i64* %6
%27 = load i64, i64* %7
%28 = sub nsw i64 %26, %27
%29 = sitofp i64 %28 to double
%30 = load i64, i64* %6
%31 = sitofp i64 %30 to double
%32 = fdiv double %29, %31
%33 = fmul double %32, 1.000000e+02
store double %33, double* %4
br label %40
34: ; preds = %22
store double -1.000000e+00, double* %4
br label %40
35: ; preds = %19
%36 = load i64, i64* %6
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %35
store double 1.000000e+02, double* %4
br label %40
39: ; preds = %35
store double -1.000000e+00, double* %4
br label %40
40: ; preds = %39, %38, %34, %25, %10
%41 = load double, double* %4
ret double %41
}

LLVM IR (-O2):
define double @statistics_weighted_compute_percent_missing(i32 %0, i64 %1, i64 %2) {
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %11
5: ; preds = %3
%6 = sub nsw i64 %1, %2
%7 = sitofp i64 %6 to double
%8 = sitofp i64 %1 to double
%9 = fdiv double %7, %8
%10 = fmul double %9, 1.000000e+02
br label %23
11: ; preds = %3
%12 = icmp eq i32 %0, -1
%13 = icmp eq i64 %1, 0
br i1 %12, label %14, label %21
14: ; preds = %11
br i1 %13, label %23, label %15
15: ; preds = %14
%16 = sub nsw i64 %1, %2
%17 = sitofp i64 %16 to double
%18 = sitofp i64 %1 to double
%19 = fdiv double %17, %18
%20 = fmul double %19, 1.000000e+02
br label %23
21: ; preds = %11
%22 = select i1 %13, double -1.000000e+00, double 1.000000e+02
br label %23
23: ; preds = %21, %14, %15, %5
%24 = phi double [ %10, %5 ], [ %20, %15 ], [ -1.000000e+00, %14 ], [ %22, %21 ]
ret double %24
}