int getCarrierFrequencyDeviation(float *const freq,
                                 int (*spiTransfer)(unsigned char *const,
                                                    unsigned int,
                                                    void *const customData),
                                 void *const customData) {
  unsigned char data[] = {0x05, 0x00, 0x00};
  int res = (*spiTransfer)(data, 3, customData);
  if (res < 0) {
    return res;
  }
  *freq = 32.0 / 524288.0 *
          (((unsigned long)data[1] << 8) + (unsigned long)data[2]);
  return 0;
}


x86 assembly (clang, -O0):
<getCarrierFrequencyDeviation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    0xeed(%rip),%ax
mov    %ax,-0x23(%rbp)
mov    0xee5(%rip),%al
mov    %al,-0x21(%rbp)
mov    -0x18(%rbp),%rax
lea    -0x23(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x3,%esi
call   *%rax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    1153 <getCarrierFrequencyDeviation+0x53>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    117f <getCarrierFrequencyDeviation+0x7f>
movzwl -0x22(%rbp),%eax
shl    $0x10,%eax
bswap  %eax
cvtsi2sd %eax,%xmm1
movsd  0xe98(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCarrierFrequencyDeviation>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rax
mov    %rdi,%rbx
movb   $0x0,0xe(%rsp)
movw   $0x5,0xc(%rsp)
lea    0xc(%rsp),%rdi
mov    $0x3,%esi
call   *%rax
test   %eax,%eax
js     1147 <getCarrierFrequencyDeviation+0x47>
movzwl 0xd(%rsp),%eax
shl    $0x10,%eax
bswap  %eax
cvtsi2sd %eax,%xmm0
mulsd  0xec3(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rbx)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.getCarrierFrequencyDeviation.data = [3 x i8] c"\05\00\00"
define i32 @getCarrierFrequencyDeviation(float* %0, i32 (i8*, i32, i8*)* %1, i8* %2) {
%4 = alloca i32
%5 = alloca float*
%6 = alloca i32 (i8*, i32, i8*)*
%7 = alloca i8*
%8 = alloca [3 x i8]
%9 = alloca i32
store float* %0, float** %5
store i32 (i8*, i32, i8*)* %1, i32 (i8*, i32, i8*)** %6
store i8* %2, i8** %7
%10 = bitcast [3 x i8]* %8 to i8*
%11 = load i32 (i8*, i32, i8*)*, i32 (i8*, i32, i8*)** %6
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %8, i64 0, i64 0
%13 = load i8*, i8** %7
%14 = call i32 %11(i8* %12, i32 3, i8* %13)
store i32 %14, i32* %9
%15 = load i32, i32* %9
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %3
%18 = load i32, i32* %9
store i32 %18, i32* %4
br label %32
19: ; preds = %3
%20 = getelementptr inbounds [3 x i8], [3 x i8]* %8, i64 0, i64 1
%21 = load i8, i8* %20
%22 = zext i8 %21 to i64
%23 = shl i64 %22, 8
%24 = getelementptr inbounds [3 x i8], [3 x i8]* %8, i64 0, i64 2
%25 = load i8, i8* %24
%26 = zext i8 %25 to i64
%27 = add i64 %23, %26
%28 = uitofp i64 %27 to double
%29 = fmul double 0x3F10000000000000, %28
%30 = fptrunc double %29 to float
%31 = load float*, float** %5
store float %30, float* %31
store i32 0, i32* %4
br label %32
32: ; preds = %19, %17
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
@__const.getCarrierFrequencyDeviation.data = [3 x i8] c"\05\00\00"
define i32 @getCarrierFrequencyDeviation(float* nocapture writeonly %0, i32 (i8*, i32, i8*)* nocapture %1, i8* %2) {
%4 = alloca [3 x i8]
%5 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%6 = call i32 %1(i8* %5, i32 3, i8* %2)
%7 = icmp slt i32 %6, 0
br i1 %7, label %20, label %8
8: ; preds = %3
%9 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 1
%10 = load i8, i8* %9
%11 = zext i8 %10 to i64
%12 = shl nuw nsw i64 %11, 8
%13 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 2
%14 = load i8, i8* %13
%15 = zext i8 %14 to i64
%16 = or i64 %12, %15
%17 = uitofp i64 %16 to double
%18 = fmul double %17, 0x3F10000000000000
%19 = fptrunc double %18 to float
store float %19, float* %0
br label %20
20: ; preds = %3, %8
%21 = phi i32 [ 0, %8 ], [ %6, %3 ]
ret i32 %21
}