int getBitRate(float *const bitRate,
               int (*spiTransfer)(unsigned char *const, unsigned int,
                                  void *const customData),
               void *const customData) {
  unsigned char data[] = {0x03, 0x00, 0x00};
  int res = (*spiTransfer)(data, 3, customData);
  if (res < 0) {
    return res;
  }
  *bitRate =
      32000000 / (((unsigned long)data[1] << 8) + (unsigned long)data[2]);
  return 0;
}


x86 assembly (clang, -O0):
<getBitRate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    0xee5(%rip),%ax
mov    %ax,-0x23(%rbp)
mov    0xedd(%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 <getBitRate+0x53>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    117f <getBitRate+0x7f>
movzwl -0x22(%rbp),%eax
mov    %eax,%ecx
shl    $0x30,%rcx
bswap  %rcx
xor    %eax,%eax
mov    %eax,%edx
mov    $0x1e84800,%eax
div    %rcx
cvtsi2ss %eax,%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):
<getBitRate>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rax
mov    %rdi,%rbx
movb   $0x0,0xe(%rsp)
movw   $0x3,0xc(%rsp)
lea    0xc(%rsp),%rdi
mov    $0x3,%esi
call   *%rax
test   %eax,%eax
js     1146 <getBitRate+0x46>
movzwl 0xd(%rsp),%esi
shl    $0x10,%esi
bswap  %esi
xor    %ecx,%ecx
mov    $0x1e84800,%eax
xor    %edx,%edx
div    %esi
cvtsi2ss %eax,%xmm0
movss  %xmm0,(%rbx)
jmp    1148 <getBitRate+0x48>
mov    %eax,%ecx
mov    %ecx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.getBitRate.data = [3 x i8] c"\03\00\00"
define i32 @getBitRate(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 %31
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 = udiv i64 32000000, %27
%29 = uitofp i64 %28 to float
%30 = load float*, float** %5
store float %29, float* %30
store i32 0, i32* %4
br label %31
31: ; preds = %19, %17
%32 = load i32, i32* %4
ret i32 %32
}

LLVM IR (-O2):
@__const.getBitRate.data = [3 x i8] c"\03\00\00"
define i32 @getBitRate(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 %19, 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 = udiv i64 32000000, %16
%18 = uitofp i64 %17 to float
store float %18, float* %0
br label %19
19: ; preds = %3, %8
%20 = phi i32 [ 0, %8 ], [ %6, %3 ]
ret i32 %20
}