int setCarrierFrequencyDeviation(const float *const freq,
                                 int (*spiTransfer)(unsigned char *const,
                                                    unsigned int,
                                                    void *const customData),
                                 void *const customData) {
  unsigned char data[3];
  long steps = (long)(*freq / 32.0 * 524288.0);
  data[0] = 0x05 | 1 << 7;
  data[1] = (steps & 0xFF00) >> 8;
  data[2] = steps & 0xFF;
  return (*spiTransfer)(data, 3, customData);
}


x86 assembly (clang, -O0):
<setCarrierFrequencyDeviation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xee0(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xecc(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x28(%rbp)
movb   $0x85,-0x1b(%rbp)
mov    -0x28(%rbp),%rax
and    $0xff00,%rax
sar    $0x8,%rax
mov    %al,-0x1a(%rbp)
mov    -0x28(%rbp),%rax
and    $0xff,%rax
mov    %al,-0x19(%rbp)
mov    -0x10(%rbp),%rax
lea    -0x1b(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x3,%esi
call   *%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setCarrierFrequencyDeviation>:
push   %rax
movss  (%rdi),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xeef(%rip),%xmm0
mulsd  0xeef(%rip),%xmm0
cvttsd2si %xmm0,%rcx
mov    %rsi,%rax
movb   $0x85,0x5(%rsp)
mov    %ch,0x6(%rsp)
mov    %cl,0x7(%rsp)
lea    0x5(%rsp),%rdi
mov    $0x3,%esi
call   *%rax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @setCarrierFrequencyDeviation(float* %0, i32 (i8*, i32, i8*)* %1, i8* %2) {
%4 = alloca float*
%5 = alloca i32 (i8*, i32, i8*)*
%6 = alloca i8*
%7 = alloca [3 x i8]
%8 = alloca i64
store float* %0, float** %4
store i32 (i8*, i32, i8*)* %1, i32 (i8*, i32, i8*)** %5
store i8* %2, i8** %6
%9 = load float*, float** %4
%10 = load float, float* %9
%11 = fpext float %10 to double
%12 = fdiv double %11, 3.200000e+01
%13 = fmul double %12, 5.242880e+05
%14 = fptosi double %13 to i64
store i64 %14, i64* %8
%15 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
store i8 -123, i8* %15
%16 = load i64, i64* %8
%17 = and i64 %16, 65280
%18 = ashr i64 %17, 8
%19 = trunc i64 %18 to i8
%20 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 1
store i8 %19, i8* %20
%21 = load i64, i64* %8
%22 = and i64 %21, 255
%23 = trunc i64 %22 to i8
%24 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 2
store i8 %23, i8* %24
%25 = load i32 (i8*, i32, i8*)*, i32 (i8*, i32, i8*)** %5
%26 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%27 = load i8*, i8** %6
%28 = call i32 %25(i8* %26, i32 3, i8* %27)
ret i32 %28
}

LLVM IR (-O2):
define i32 @setCarrierFrequencyDeviation(float* nocapture %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 = load float, float* %0
%7 = fpext float %6 to double
%8 = fmul double %7, 3.125000e-02
%9 = fmul double %8, 5.242880e+05
%10 = fptosi double %9 to i64
store i8 -123, i8* %5
%11 = lshr i64 %10, 8
%12 = trunc i64 %11 to i8
%13 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 1
store i8 %12, i8* %13
%14 = trunc i64 %10 to i8
%15 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 2
store i8 %14, i8* %15
%16 = call i32 %1(i8* %5, i32 3, i8* %2)
ret i32 %16
}