void tune_report(int channel, int audio) {
  if (channel == 3) {
    pll_report(audio);
    return;
  }
  union {
    unsigned char c[4];
    unsigned u;
  } response;
  read_registers(((channel)*4 + 16), 4, response.c);
  unsigned rawf = response.u << 8;
  unsigned hertz = (250000000ull * rawf + (1ull << 31)) >> 32;
  if (channel != 2) {
    printf("%d%c %9d Hz, gain = %d * 6dB\n", channel,
           audio == channel ? '*' : ':', hertz, response.c[3] & 15);
    return;
  }
  read_registers(9, 1, response.c);
  printf("%d%c %9d Hz, gain = %d,%d * 6dB, decay = %d\n", channel,
         audio == channel ? '*' : ':', hertz, response.c[3] & 15,
         (response.c[3] >> 4) & 15, response.c[0] & 15);
}


x86 assembly (clang, -O0):
<tune_report>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x3,-0x4(%rbp)
jne    1157 <tune_report+0x27>
mov    -0x8(%rbp),%edi
mov    $0x0,%al
call   1050 <pll_report@plt>
jmp    1236 <tune_report+0x106>
mov    -0x4(%rbp),%edi
shl    $0x2,%edi
add    $0x10,%edi
lea    -0x10(%rbp),%rdx
mov    $0x4,%esi
mov    $0x0,%al
call   1030 <read_registers@plt>
mov    -0x10(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
imul   $0xee6b280,%rax,%rax
movabs $0x80000000,%rcx
add    %rcx,%rax
shr    $0x20,%rax
mov    %eax,-0x18(%rbp)
cmpl   $0x2,-0x4(%rbp)
je     11d8 <tune_report+0xa8>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%edi
mov    $0x3a,%edx
mov    $0x2a,%eax
cmp    %edi,%ecx
cmove  %eax,%edx
mov    -0x18(%rbp),%ecx
movzbl -0xd(%rbp),%r8d
and    $0xf,%r8d
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1236 <tune_report+0x106>
lea    -0x10(%rbp),%rdx
mov    $0x9,%edi
mov    $0x1,%esi
mov    $0x0,%al
call   1030 <read_registers@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%edi
mov    $0x3a,%edx
mov    $0x2a,%eax
cmp    %edi,%ecx
cmove  %eax,%edx
mov    -0x18(%rbp),%ecx
movzbl -0xd(%rbp),%r8d
and    $0xf,%r8d
movzbl -0xd(%rbp),%r9d
sar    $0x4,%r9d
and    $0xf,%r9d
movzbl -0x10(%rbp),%eax
and    $0xf,%eax
lea    0xdf2(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tune_report>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r14d
cmp    $0x3,%edi
jne    1152 <tune_report+0x22>
mov    %r14d,%edi
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <pll_report@plt>
mov    %edi,%ebp
lea    0x10(,%rbp,4),%edi
lea    0x8(%rsp),%rdx
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <read_registers@plt>
mov    0x8(%rsp),%r8d
mov    %r8d,%eax
shl    $0x8,%eax
imul   $0xee6b280,%rax,%rbx
sub    $0xffffffff80000000,%rbx
shr    $0x20,%rbx
cmp    $0x2,%ebp
jne    11e6 <tune_report+0xb6>
lea    0x8(%rsp),%rdx
mov    $0x9,%edi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <read_registers@plt>
xor    %edx,%edx
cmp    $0x2,%r14d
setne  %dl
shl    $0x4,%edx
or     $0x2a,%edx
movzbl 0xb(%rsp),%r9d
mov    %r9d,%r8d
and    $0xf,%r8d
shr    $0x4,%r9d
movzbl 0x8(%rsp),%eax
and    $0xf,%eax
mov    %eax,(%rsp)
lea    0xe48(%rip),%rdi
mov    $0x2,%esi
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    120e <tune_report+0xde>
shr    $0x18,%r8d
xor    %edx,%edx
cmp    %ebp,%r14d
setne  %dl
shl    $0x4,%edx
or     $0x2a,%edx
and    $0xf,%r8d
lea    0xdfd(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%union.anon = type { i32 }
@.str = [30 x i8] c"%d%c %9d Hz, gain = %d * 6dB\0A\00"
@.str.1 = [45 x i8] c"%d%c %9d Hz, gain = %d,%d * 6dB, decay = %d\0A\00"
define void @tune_report(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %union.anon
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, 3
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* %4
%12 = call i32 (i32, ...) bitcast (i32 (...)* @pll_report to i32 (i32, ...)*)(i32 %11)
br label %73
13: ; preds = %2
%14 = load i32, i32* %3
%15 = mul nsw i32 %14, 4
%16 = add nsw i32 %15, 16
%17 = bitcast %union.anon* %5 to [4 x i8]*
%18 = getelementptr inbounds [4 x i8], [4 x i8]* %17, i64 0, i64 0
%19 = call i32 (i32, i32, i8*, ...) bitcast (i32 (...)* @read_registers to i32 (i32, i32, i8*, ...)*)(i32 %16, i32 4, i8* %18)
%20 = bitcast %union.anon* %5 to i32*
%21 = load i32, i32* %20
%22 = shl i32 %21, 8
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = zext i32 %23 to i64
%25 = mul i64 250000000, %24
%26 = add i64 %25, 2147483648
%27 = lshr i64 %26, 32
%28 = trunc i64 %27 to i32
store i32 %28, i32* %7
%29 = load i32, i32* %3
%30 = icmp ne i32 %29, 2
br i1 %30, label %31, label %45
31: ; preds = %13
%32 = load i32, i32* %3
%33 = load i32, i32* %4
%34 = load i32, i32* %3
%35 = icmp eq i32 %33, %34
%36 = zext i1 %35 to i64
%37 = select i1 %35, i32 42, i32 58
%38 = load i32, i32* %7
%39 = bitcast %union.anon* %5 to [4 x i8]*
%40 = getelementptr inbounds [4 x i8], [4 x i8]* %39, i64 0, i64 3
%41 = load i8, i8* %40
%42 = zext i8 %41 to i32
%43 = and i32 %42, 15
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %32, i32 %37, i32 %38, i32 %43)
br label %73
45: ; preds = %13
%46 = bitcast %union.anon* %5 to [4 x i8]*
%47 = getelementptr inbounds [4 x i8], [4 x i8]* %46, i64 0, i64 0
%48 = call i32 (i32, i32, i8*, ...) bitcast (i32 (...)* @read_registers to i32 (i32, i32, i8*, ...)*)(i32 9, i32 1, i8* %47)
%49 = load i32, i32* %3
%50 = load i32, i32* %4
%51 = load i32, i32* %3
%52 = icmp eq i32 %50, %51
%53 = zext i1 %52 to i64
%54 = select i1 %52, i32 42, i32 58
%55 = load i32, i32* %7
%56 = bitcast %union.anon* %5 to [4 x i8]*
%57 = getelementptr inbounds [4 x i8], [4 x i8]* %56, i64 0, i64 3
%58 = load i8, i8* %57
%59 = zext i8 %58 to i32
%60 = and i32 %59, 15
%61 = bitcast %union.anon* %5 to [4 x i8]*
%62 = getelementptr inbounds [4 x i8], [4 x i8]* %61, i64 0, i64 3
%63 = load i8, i8* %62
%64 = zext i8 %63 to i32
%65 = ashr i32 %64, 4
%66 = and i32 %65, 15
%67 = bitcast %union.anon* %5 to [4 x i8]*
%68 = getelementptr inbounds [4 x i8], [4 x i8]* %67, i64 0, i64 0
%69 = load i8, i8* %68
%70 = zext i8 %69 to i32
%71 = and i32 %70, 15
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 %49, i32 %54, i32 %55, i32 %60, i32 %66, i32 %71)
br label %73
73: ; preds = %45, %31, %10
ret void
}

LLVM IR (-O2):
%union.anon = type { i32 }
@.str = [30 x i8] c"%d%c %9d Hz, gain = %d * 6dB\0A\00"
@.str.1 = [45 x i8] c"%d%c %9d Hz, gain = %d,%d * 6dB, decay = %d\0A\00"
define void @tune_report(i32 %0, i32 %1) {
%3 = alloca %union.anon
%4 = icmp eq i32 %0, 3
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 (i32, ...) bitcast (i32 (...)* @pll_report to i32 (i32, ...)*)(i32 %1)
br label %42
7: ; preds = %2
%8 = bitcast %union.anon* %3 to i8*
%9 = shl nsw i32 %0, 2
%10 = add nsw i32 %9, 16
%11 = call i32 (i32, i32, i8*, ...) bitcast (i32 (...)* @read_registers to i32 (i32, i32, i8*, ...)*)(i32 %10, i32 4, i8* %8)
%12 = getelementptr inbounds %union.anon, %union.anon* %3, i64 0, i32 0
%13 = load i32, i32* %12
%14 = shl i32 %13, 8
%15 = zext i32 %14 to i64
%16 = mul nuw nsw i64 %15, 250000000
%17 = add nuw nsw i64 %16, 2147483648
%18 = lshr i64 %17, 32
%19 = trunc i64 %18 to i32
%20 = icmp eq i32 %0, 2
br i1 %20, label %27, label %21
21: ; preds = %7
%22 = lshr i32 %13, 24
%23 = icmp eq i32 %1, %0
%24 = select i1 %23, i32 42, i32 58
%25 = and i32 %22, 15
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %24, i32 %19, i32 %25)
br label %41
27: ; preds = %7
%28 = bitcast %union.anon* %3 to [4 x i8]*
%29 = call i32 (i32, i32, i8*, ...) bitcast (i32 (...)* @read_registers to i32 (i32, i32, i8*, ...)*)(i32 9, i32 1, i8* %8)
%30 = icmp eq i32 %1, 2
%31 = select i1 %30, i32 42, i32 58
%32 = getelementptr inbounds [4 x i8], [4 x i8]* %28, i64 0, i64 3
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = and i32 %34, 15
%36 = lshr i32 %34, 4
%37 = load i8, i8* %8
%38 = and i8 %37, 15
%39 = zext i8 %38 to i32
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 %31, i32 %19, i32 %35, i32 %36, i32 %39)
br label %41
41: ; preds = %27, %21
br label %42
42: ; preds = %41, %5
ret void
}