int aa_pro_ctr_a12(int chan, unsigned char *buf, int len) {
  if (len != 4 || buf[2] != 0x08)
    hu_log(6, "hu_aap", __func__, "Audio Focus Request");
  else if (buf[3] == 1)
    hu_log(3, "hu_aap", __func__, "Audio Focus Request: 1 AUDIO_FOCUS_GAIN ?");
  else if (buf[3] == 2)
    hu_log(3, "hu_aap", __func__,
           "Audio Focus Request: 2 AUDIO_FOCUS_GAIN_TRANSIENT");
  else if (buf[3] == 3)
    hu_log(3, "hu_aap", __func__, "Audio Focus Request: 3 gain/release ?");
  else if (buf[3] == 4)
    hu_log(3, "hu_aap", __func__, "Audio Focus Request: 4 AUDIO_FOCUS_RELEASE");
  else
    hu_log(6, "hu_aap", __func__, "Audio Focus Request: %d", buf[3]);
  buf[0] = 0;
  buf[1] = 19;
  buf[2] = 0x08;
  if (buf[3] == 4)
    buf[3] = 3;
  else if (buf[3] == 2)
    buf[3] = 1;
  else
    buf[3] = 1;
  buf[4] = 0x10;
  buf[5] = 0;
  int ret = hu_aap_enc_send(chan, buf, 4);
  return (0);
}


x86 assembly (clang, -O0):
<aa_pro_ctr_a12>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jne    114d <aa_pro_ctr_a12+0x2d>
mov    -0x10(%rbp),%rax
movzbl 0x2(%rax),%eax
cmp    $0x8,%eax
je     1173 <aa_pro_ctr_a12+0x53>
mov    $0x6,%edi
lea    0xea7(%rip),%rsi
lea    0xea7(%rip),%rdx
lea    0xeaf(%rip),%rcx
mov    $0x0,%al
call   1030 <hu_log@plt>
jmp    128d <aa_pro_ctr_a12+0x16d>
mov    -0x10(%rbp),%rax
movzbl 0x3(%rax),%eax
cmp    $0x1,%eax
jne    11aa <aa_pro_ctr_a12+0x8a>
mov    $0x3,%edi
lea    0xe70(%rip),%rsi
lea    0xe70(%rip),%rdx
lea    0xe8c(%rip),%rcx
mov    $0x0,%al
call   1030 <hu_log@plt>
jmp    1288 <aa_pro_ctr_a12+0x168>
mov    -0x10(%rbp),%rax
movzbl 0x3(%rax),%eax
cmp    $0x2,%eax
jne    11e1 <aa_pro_ctr_a12+0xc1>
mov    $0x3,%edi
lea    0xe39(%rip),%rsi
lea    0xe39(%rip),%rdx
lea    0xe7f(%rip),%rcx
mov    $0x0,%al
call   1030 <hu_log@plt>
jmp    1283 <aa_pro_ctr_a12+0x163>
mov    -0x10(%rbp),%rax
movzbl 0x3(%rax),%eax
cmp    $0x3,%eax
jne    1218 <aa_pro_ctr_a12+0xf8>
mov    $0x3,%edi
lea    0xe02(%rip),%rsi
lea    0xe02(%rip),%rdx
lea    0xe7a(%rip),%rcx
mov    $0x0,%al
call   1030 <hu_log@plt>
jmp    127e <aa_pro_ctr_a12+0x15e>
mov    -0x10(%rbp),%rax
movzbl 0x3(%rax),%eax
cmp    $0x4,%eax
jne    124f <aa_pro_ctr_a12+0x12f>
mov    $0x3,%edi
lea    0xdcb(%rip),%rsi
lea    0xdcb(%rip),%rdx
lea    0xe69(%rip),%rcx
mov    $0x0,%al
call   1030 <hu_log@plt>
jmp    1279 <aa_pro_ctr_a12+0x159>
mov    -0x10(%rbp),%rax
movzbl 0x3(%rax),%r8d
mov    $0x6,%edi
lea    0xd9c(%rip),%rsi
lea    0xd9c(%rip),%rdx
lea    0xe65(%rip),%rcx
mov    $0x0,%al
call   1030 <hu_log@plt>
jmp    127e <aa_pro_ctr_a12+0x15e>
jmp    1283 <aa_pro_ctr_a12+0x163>
jmp    1288 <aa_pro_ctr_a12+0x168>
jmp    128d <aa_pro_ctr_a12+0x16d>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x13,0x1(%rax)
mov    -0x10(%rbp),%rax
movb   $0x8,0x2(%rax)
mov    -0x10(%rbp),%rax
movzbl 0x3(%rax),%eax
cmp    $0x4,%eax
jne    12c2 <aa_pro_ctr_a12+0x1a2>
mov    -0x10(%rbp),%rax
movb   $0x3,0x3(%rax)
jmp    12ed <aa_pro_ctr_a12+0x1cd>
mov    -0x10(%rbp),%rax
movzbl 0x3(%rax),%eax
cmp    $0x2,%eax
jne    12e0 <aa_pro_ctr_a12+0x1c0>
mov    -0x10(%rbp),%rax
movb   $0x1,0x3(%rax)
jmp    12e8 <aa_pro_ctr_a12+0x1c8>
mov    -0x10(%rbp),%rax
movb   $0x1,0x3(%rax)
jmp    12ed <aa_pro_ctr_a12+0x1cd>
mov    -0x10(%rbp),%rax
movb   $0x10,0x4(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,0x5(%rax)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1040 <hu_aap_enc_send@plt>
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aa_pro_ctr_a12>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
cmp    $0x4,%edx
jne    116d <aa_pro_ctr_a12+0x4d>
cmpb   $0x8,0x2(%rbx)
jne    116d <aa_pro_ctr_a12+0x4d>
movzbl 0x3(%rbx),%r8d
lea    -0x1(%r8),%eax
cmp    $0x3,%al
ja     1189 <aa_pro_ctr_a12+0x69>
movzbl %al,%eax
lea    0xeb6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeb6(%rip),%rsi
lea    0xeb6(%rip),%rdx
lea    0xed2(%rip),%rcx
jmp    11ef <aa_pro_ctr_a12+0xcf>
lea    0xe9c(%rip),%rsi
lea    0xe9c(%rip),%rdx
lea    0xea4(%rip),%rcx
mov    $0x6,%edi
jmp    11f4 <aa_pro_ctr_a12+0xd4>
lea    0xe80(%rip),%rsi
lea    0xe80(%rip),%rdx
lea    0xf49(%rip),%rcx
mov    $0x6,%edi
xor    %eax,%eax
call   1030 <hu_log@plt>
jmp    11fb <aa_pro_ctr_a12+0xdb>
lea    0xe5d(%rip),%rsi
lea    0xe5d(%rip),%rdx
lea    0xea3(%rip),%rcx
jmp    11ef <aa_pro_ctr_a12+0xcf>
lea    0xe46(%rip),%rsi
lea    0xe46(%rip),%rdx
lea    0xebe(%rip),%rcx
jmp    11ef <aa_pro_ctr_a12+0xcf>
lea    0xe2f(%rip),%rsi
lea    0xe2f(%rip),%rdx
lea    0xecd(%rip),%rcx
mov    $0x3,%edi
xor    %eax,%eax
call   1030 <hu_log@plt>
movw   $0x1300,(%rbx)
movb   $0x8,0x2(%rbx)
cmpb   $0x4,0x3(%rbx)
sete   %al
add    %al,%al
or     $0x1,%al
mov    %al,0x3(%rbx)
movw   $0x10,0x4(%rbx)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x4,%edx
xor    %eax,%eax
call   1040 <hu_aap_enc_send@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"hu_aap\00"
@__func__.aa_pro_ctr_a12 = [15 x i8] c"aa_pro_ctr_a12\00"
@.str.1 = [20 x i8] c"Audio Focus Request\00"
@.str.2 = [42 x i8] c"Audio Focus Request: 1 AUDIO_FOCUS_GAIN ?\00"
@.str.3 = [50 x i8] c"Audio Focus Request: 2 AUDIO_FOCUS_GAIN_TRANSIENT\00"
@.str.4 = [38 x i8] c"Audio Focus Request: 3 gain/release ?\00"
@.str.5 = [43 x i8] c"Audio Focus Request: 4 AUDIO_FOCUS_RELEASE\00"
@.str.6 = [24 x i8] c"Audio Focus Request: %d\00"
define i32 @aa_pro_ctr_a12(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = icmp ne i32 %8, 4
br i1 %9, label %16, label %10
10: ; preds = %3
%11 = load i8*, i8** %5
%12 = getelementptr inbounds i8, i8* %11, i64 2
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = icmp ne i32 %14, 8
br i1 %15, label %16, label %18
16: ; preds = %10, %3
%17 = call i32 (i32, i8*, i8*, i8*, ...) bitcast (i32 (...)* @hu_log to i32 (i32, i8*, i8*, i8*, ...)*)(i32 6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__func__.aa_pro_ctr_a12, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %60
18: ; preds = %10
%19 = load i8*, i8** %5
%20 = getelementptr inbounds i8, i8* %19, i64 3
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %26
24: ; preds = %18
%25 = call i32 (i32, i8*, i8*, i8*, ...) bitcast (i32 (...)* @hu_log to i32 (i32, i8*, i8*, i8*, ...)*)(i32 3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__func__.aa_pro_ctr_a12, i64 0, i64 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
br label %59
26: ; preds = %18
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i64 3
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = icmp eq i32 %30, 2
br i1 %31, label %32, label %34
32: ; preds = %26
%33 = call i32 (i32, i8*, i8*, i8*, ...) bitcast (i32 (...)* @hu_log to i32 (i32, i8*, i8*, i8*, ...)*)(i32 3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__func__.aa_pro_ctr_a12, i64 0, i64 0), i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
br label %58
34: ; preds = %26
%35 = load i8*, i8** %5
%36 = getelementptr inbounds i8, i8* %35, i64 3
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = icmp eq i32 %38, 3
br i1 %39, label %40, label %42
40: ; preds = %34
%41 = call i32 (i32, i8*, i8*, i8*, ...) bitcast (i32 (...)* @hu_log to i32 (i32, i8*, i8*, i8*, ...)*)(i32 3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__func__.aa_pro_ctr_a12, i64 0, i64 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
br label %57
42: ; preds = %34
%43 = load i8*, i8** %5
%44 = getelementptr inbounds i8, i8* %43, i64 3
%45 = load i8, i8* %44
%46 = zext i8 %45 to i32
%47 = icmp eq i32 %46, 4
br i1 %47, label %48, label %50
48: ; preds = %42
%49 = call i32 (i32, i8*, i8*, i8*, ...) bitcast (i32 (...)* @hu_log to i32 (i32, i8*, i8*, i8*, ...)*)(i32 3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__func__.aa_pro_ctr_a12, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
br label %56
50: ; preds = %42
%51 = load i8*, i8** %5
%52 = getelementptr inbounds i8, i8* %51, i64 3
%53 = load i8, i8* %52
%54 = zext i8 %53 to i32
%55 = call i32 (i32, i8*, i8*, i8*, i32, ...) bitcast (i32 (...)* @hu_log to i32 (i32, i8*, i8*, i8*, i32, ...)*)(i32 6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__func__.aa_pro_ctr_a12, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i32 %54)
br label %56
56: ; preds = %50, %48
br label %57
57: ; preds = %56, %40
br label %58
58: ; preds = %57, %32
br label %59
59: ; preds = %58, %24
br label %60
60: ; preds = %59, %16
%61 = load i8*, i8** %5
%62 = getelementptr inbounds i8, i8* %61, i64 0
store i8 0, i8* %62
%63 = load i8*, i8** %5
%64 = getelementptr inbounds i8, i8* %63, i64 1
store i8 19, i8* %64
%65 = load i8*, i8** %5
%66 = getelementptr inbounds i8, i8* %65, i64 2
store i8 8, i8* %66
%67 = load i8*, i8** %5
%68 = getelementptr inbounds i8, i8* %67, i64 3
%69 = load i8, i8* %68
%70 = zext i8 %69 to i32
%71 = icmp eq i32 %70, 4
br i1 %71, label %72, label %75
72: ; preds = %60
%73 = load i8*, i8** %5
%74 = getelementptr inbounds i8, i8* %73, i64 3
store i8 3, i8* %74
br label %88
75: ; preds = %60
%76 = load i8*, i8** %5
%77 = getelementptr inbounds i8, i8* %76, i64 3
%78 = load i8, i8* %77
%79 = zext i8 %78 to i32
%80 = icmp eq i32 %79, 2
br i1 %80, label %81, label %84
81: ; preds = %75
%82 = load i8*, i8** %5
%83 = getelementptr inbounds i8, i8* %82, i64 3
store i8 1, i8* %83
br label %87
84: ; preds = %75
%85 = load i8*, i8** %5
%86 = getelementptr inbounds i8, i8* %85, i64 3
store i8 1, i8* %86
br label %87
87: ; preds = %84, %81
br label %88
88: ; preds = %87, %72
%89 = load i8*, i8** %5
%90 = getelementptr inbounds i8, i8* %89, i64 4
store i8 16, i8* %90
%91 = load i8*, i8** %5
%92 = getelementptr inbounds i8, i8* %91, i64 5
store i8 0, i8* %92
%93 = load i32, i32* %4
%94 = load i8*, i8** %5
%95 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @hu_aap_enc_send to i32 (i32, i8*, i32, ...)*)(i32 %93, i8* %94, i32 4)
store i32 %95, i32* %7
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"hu_aap\00"
@__func__.aa_pro_ctr_a12 = [15 x i8] c"aa_pro_ctr_a12\00"
@.str.1 = [20 x i8] c"Audio Focus Request\00"
@.str.2 = [42 x i8] c"Audio Focus Request: 1 AUDIO_FOCUS_GAIN ?\00"
@.str.3 = [50 x i8] c"Audio Focus Request: 2 AUDIO_FOCUS_GAIN_TRANSIENT\00"
@.str.4 = [38 x i8] c"Audio Focus Request: 3 gain/release ?\00"
@.str.5 = [43 x i8] c"Audio Focus Request: 4 AUDIO_FOCUS_RELEASE\00"
@.str.6 = [24 x i8] c"Audio Focus Request: %d\00"
define i32 @aa_pro_ctr_a12(i32 %0, i8* %1, i32 %2) {
%4 = icmp eq i32 %2, 4
br i1 %4, label %5, label %9
5: ; preds = %3
%6 = getelementptr inbounds i8, i8* %1, i64 2
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 8
br i1 %8, label %11, label %9
9: ; preds = %5, %3
%10 = tail call i32 (i32, i8*, i8*, i8*, ...) bitcast (i32 (...)* @hu_log to i32 (i32, i8*, i8*, i8*, ...)*)(i32 6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__func__.aa_pro_ctr_a12, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %25
11: ; preds = %5
%12 = getelementptr inbounds i8, i8* %1, i64 3
%13 = load i8, i8* %12
switch i8 %13, label %22 [
i8 1, label %14
i8 2, label %16
i8 3, label %18
i8 4, label %20
]
14: ; preds = %11
%15 = tail call i32 (i32, i8*, i8*, i8*, ...) bitcast (i32 (...)* @hu_log to i32 (i32, i8*, i8*, i8*, ...)*)(i32 3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__func__.aa_pro_ctr_a12, i64 0, i64 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
br label %25
16: ; preds = %11
%17 = tail call i32 (i32, i8*, i8*, i8*, ...) bitcast (i32 (...)* @hu_log to i32 (i32, i8*, i8*, i8*, ...)*)(i32 3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__func__.aa_pro_ctr_a12, i64 0, i64 0), i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
br label %25
18: ; preds = %11
%19 = tail call i32 (i32, i8*, i8*, i8*, ...) bitcast (i32 (...)* @hu_log to i32 (i32, i8*, i8*, i8*, ...)*)(i32 3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__func__.aa_pro_ctr_a12, i64 0, i64 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
br label %25
20: ; preds = %11
%21 = tail call i32 (i32, i8*, i8*, i8*, ...) bitcast (i32 (...)* @hu_log to i32 (i32, i8*, i8*, i8*, ...)*)(i32 3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__func__.aa_pro_ctr_a12, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
br label %25
22: ; preds = %11
%23 = zext i8 %13 to i32
%24 = tail call i32 (i32, i8*, i8*, i8*, i32, ...) bitcast (i32 (...)* @hu_log to i32 (i32, i8*, i8*, i8*, i32, ...)*)(i32 6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__func__.aa_pro_ctr_a12, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %14, %18, %22, %20, %16, %9
store i8 0, i8* %1
%26 = getelementptr inbounds i8, i8* %1, i64 1
store i8 19, i8* %26
%27 = getelementptr inbounds i8, i8* %1, i64 2
store i8 8, i8* %27
%28 = getelementptr inbounds i8, i8* %1, i64 3
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 4
%31 = select i1 %30, i8 3, i8 1
store i8 %31, i8* %28
%32 = getelementptr inbounds i8, i8* %1, i64 4
store i8 16, i8* %32
%33 = getelementptr inbounds i8, i8* %1, i64 5
store i8 0, i8* %33
%34 = tail call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @hu_aap_enc_send to i32 (i32, i8*, i32, ...)*)(i32 %0, i8* %1, i32 4)
ret i32 0
}