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


x86 assembly (clang, -O0):
<setCarrierFrequency>:
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   $0x87,-0x1c(%rbp)
mov    -0x28(%rbp),%rax
and    $0xff0000,%rax
sar    $0x10,%rax
mov    %al,-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    -0x1c(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x4,%esi
call   *%rax
add    $0x30,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @setCarrierFrequency(float* %0, i32 (i8*, i32, i8*)* %1, i8* %2) {
%4 = alloca float*
%5 = alloca i32 (i8*, i32, i8*)*
%6 = alloca i8*
%7 = alloca [4 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 [4 x i8], [4 x i8]* %7, i64 0, i64 0
store i8 -121, i8* %15
%16 = load i64, i64* %8
%17 = and i64 %16, 16711680
%18 = ashr i64 %17, 16
%19 = trunc i64 %18 to i8
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 1
store i8 %19, i8* %20
%21 = load i64, i64* %8
%22 = and i64 %21, 65280
%23 = ashr i64 %22, 8
%24 = trunc i64 %23 to i8
%25 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 2
store i8 %24, i8* %25
%26 = load i64, i64* %8
%27 = and i64 %26, 255
%28 = trunc i64 %27 to i8
%29 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 3
store i8 %28, i8* %29
%30 = load i32 (i8*, i32, i8*)*, i32 (i8*, i32, i8*)** %5
%31 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%32 = load i8*, i8** %6
%33 = call i32 %30(i8* %31, i32 4, i8* %32)
ret i32 %33
}

LLVM IR (-O2):
define i32 @setCarrierFrequency(float* nocapture %0, i32 (i8*, i32, i8*)* nocapture %1, i8* %2) {
%4 = alloca [4 x i8]
%5 = getelementptr inbounds [4 x i8], [4 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 -121, i8* %5
%11 = lshr i64 %10, 16
%12 = trunc i64 %11 to i8
%13 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 1
store i8 %12, i8* %13
%14 = lshr i64 %10, 8
%15 = trunc i64 %14 to i8
%16 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 2
store i8 %15, i8* %16
%17 = trunc i64 %10 to i8
%18 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 3
store i8 %17, i8* %18
%19 = call i32 %1(i8* %5, i32 4, i8* %2)
ret i32 %19
}