int aa_pro_snk_b00(int chan, unsigned char *buf, int len) {
  if (len != 4 || buf[2] != 0x08)
    hu_log(6, "hu_aap", __func__, "Media Sink Setup Request");
  else
    hu_log(3, "hu_aap", __func__, "Media Sink Setup Request: %d", buf[3]);
  unsigned char rsp[] = {0x80, 0x03, 0x08, 2, 0x10, 1, 0x18, 0};
  int ret = hu_aap_enc_send(chan, rsp, sizeof(rsp));
  if (ret)
    return (ret);
  if (chan == 4 || chan == 5 || chan == 6) {
    return (ret);
  }
  if (chan == 2) {
    unsigned char rsp2[] = {0x80, 0x08, 0x08, 1, 0x10, 1};
    return (hu_aap_enc_send(chan, rsp2, sizeof(rsp2)));
  }
  return (ret);
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jne    114d <aa_pro_snk_b00+0x2d>
mov    -0x10(%rbp),%rax
movzbl 0x2(%rax),%eax
cmp    $0x8,%eax
je     1173 <aa_pro_snk_b00+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    119d <aa_pro_snk_b00+0x7d>
mov    -0x10(%rbp),%rax
movzbl 0x3(%rax),%r8d
mov    $0x3,%edi
lea    0xe78(%rip),%rsi
lea    0xe78(%rip),%rdx
lea    0xe99(%rip),%rcx
mov    $0x0,%al
call   1030 <hu_log@plt>
mov    0xea8(%rip),%rax
mov    %rax,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x1c(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1040 <hu_aap_enc_send@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     11d3 <aa_pro_snk_b00+0xb3>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    123b <aa_pro_snk_b00+0x11b>
cmpl   $0x4,-0x8(%rbp)
je     11f1 <aa_pro_snk_b00+0xd1>
cmpl   $0x5,-0x8(%rbp)
je     11f1 <aa_pro_snk_b00+0xd1>
cmpl   $0x6,-0x8(%rbp)
jne    11fc <aa_pro_snk_b00+0xdc>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    123b <aa_pro_snk_b00+0x11b>
cmpl   $0x2,-0x8(%rbp)
jne    1235 <aa_pro_snk_b00+0x115>
mov    0xe48(%rip),%eax
mov    %eax,-0x26(%rbp)
mov    0xe42(%rip),%ax
mov    %ax,-0x22(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x26(%rbp),%rsi
mov    $0x6,%edx
mov    $0x0,%al
call   1040 <hu_aap_enc_send@plt>
mov    %eax,-0x4(%rbp)
jmp    123b <aa_pro_snk_b00+0x11b>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
cmp    $0x4,%edx
jne    115a <aa_pro_snk_b00+0x3a>
cmpb   $0x8,0x2(%rsi)
jne    115a <aa_pro_snk_b00+0x3a>
movzbl 0x3(%rsi),%r8d
lea    0xec2(%rip),%rsi
lea    0xec2(%rip),%rdx
lea    0xee3(%rip),%rcx
mov    $0x3,%edi
xor    %eax,%eax
call   1030 <hu_log@plt>
jmp    117b <aa_pro_snk_b00+0x5b>
lea    0xe9f(%rip),%rsi
lea    0xe9f(%rip),%rdx
lea    0xea7(%rip),%rcx
mov    $0x6,%edi
xor    %eax,%eax
call   1030 <hu_log@plt>
movabs $0x18011002080380,%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    $0x8,%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1040 <hu_aap_enc_send@plt>
test   %eax,%eax
jne    11cd <aa_pro_snk_b00+0xad>
mov    $0x0,%eax
cmp    $0x2,%ebx
jne    11cd <aa_pro_snk_b00+0xad>
movw   $0x110,0x4(%rsp)
movl   $0x1080880,(%rsp)
mov    %rsp,%rsi
mov    $0x6,%edx
mov    $0x2,%edi
xor    %eax,%eax
call   1040 <hu_aap_enc_send@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"hu_aap\00"
@__func__.aa_pro_snk_b00 = [15 x i8] c"aa_pro_snk_b00\00"
@.str.1 = [25 x i8] c"Media Sink Setup Request\00"
@.str.2 = [29 x i8] c"Media Sink Setup Request: %d\00"
@__const.aa_pro_snk_b00.rsp = [8 x i8] c"\80\03\08\02\10\01\18\00"
@__const.aa_pro_snk_b00.rsp2 = [6 x i8] c"\80\08\08\01\10\01"
define i32 @aa_pro_snk_b00(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca [8 x i8]
%9 = alloca i32
%10 = alloca [6 x i8]
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%11 = load i32, i32* %7
%12 = icmp ne i32 %11, 4
br i1 %12, label %19, label %13
13: ; preds = %3
%14 = load i8*, i8** %6
%15 = getelementptr inbounds i8, i8* %14, i64 2
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = icmp ne i32 %17, 8
br i1 %18, label %19, label %21
19: ; preds = %13, %3
%20 = 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_snk_b00, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %27
21: ; preds = %13
%22 = load i8*, i8** %6
%23 = getelementptr inbounds i8, i8* %22, i64 3
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = call i32 (i32, i8*, i8*, i8*, i32, ...) bitcast (i32 (...)* @hu_log to i32 (i32, i8*, i8*, i8*, i32, ...)*)(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_snk_b00, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %21, %19
%28 = bitcast [8 x i8]* %8 to i8*
%29 = load i32, i32* %5
%30 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 0
%31 = call i32 (i32, i8*, i64, ...) bitcast (i32 (...)* @hu_aap_enc_send to i32 (i32, i8*, i64, ...)*)(i32 %29, i8* %30, i64 8)
store i32 %31, i32* %9
%32 = load i32, i32* %9
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %27
%35 = load i32, i32* %9
store i32 %35, i32* %4
br label %57
36: ; preds = %27
%37 = load i32, i32* %5
%38 = icmp eq i32 %37, 4
br i1 %38, label %45, label %39
39: ; preds = %36
%40 = load i32, i32* %5
%41 = icmp eq i32 %40, 5
br i1 %41, label %45, label %42
42: ; preds = %39
%43 = load i32, i32* %5
%44 = icmp eq i32 %43, 6
br i1 %44, label %45, label %47
45: ; preds = %42, %39, %36
%46 = load i32, i32* %9
store i32 %46, i32* %4
br label %57
47: ; preds = %42
%48 = load i32, i32* %5
%49 = icmp eq i32 %48, 2
br i1 %49, label %50, label %55
50: ; preds = %47
%51 = bitcast [6 x i8]* %10 to i8*
%52 = load i32, i32* %5
%53 = getelementptr inbounds [6 x i8], [6 x i8]* %10, i64 0, i64 0
%54 = call i32 (i32, i8*, i64, ...) bitcast (i32 (...)* @hu_aap_enc_send to i32 (i32, i8*, i64, ...)*)(i32 %52, i8* %53, i64 6)
store i32 %54, i32* %4
br label %57
55: ; preds = %47
%56 = load i32, i32* %9
store i32 %56, i32* %4
br label %57
57: ; preds = %55, %50, %45, %34
%58 = load i32, i32* %4
ret i32 %58
}

LLVM IR (-O2):
@.str = [7 x i8] c"hu_aap\00"
@__func__.aa_pro_snk_b00 = [15 x i8] c"aa_pro_snk_b00\00"
@.str.1 = [25 x i8] c"Media Sink Setup Request\00"
@.str.2 = [29 x i8] c"Media Sink Setup Request: %d\00"
@__const.aa_pro_snk_b00.rsp2 = [6 x i8] c"\80\08\08\01\10\01"
define i32 @aa_pro_snk_b00(i32 %0, i8* nocapture %1, i32 %2) {
%4 = alloca i64
%5 = alloca [6 x i8]
%6 = icmp eq i32 %2, 4
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = getelementptr inbounds i8, i8* %1, i64 2
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 8
br i1 %10, label %13, label %11
11: ; preds = %7, %3
%12 = 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_snk_b00, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %18
13: ; preds = %7
%14 = getelementptr inbounds i8, i8* %1, i64 3
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = tail call i32 (i32, i8*, i8*, i8*, i32, ...) bitcast (i32 (...)* @hu_log to i32 (i32, i8*, i8*, i8*, i32, ...)*)(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_snk_b00, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %13, %11
%19 = bitcast i64* %4 to i8*
store i64 6756567706239872, i64* %4
%20 = call i32 (i32, i8*, i64, ...) bitcast (i32 (...)* @hu_aap_enc_send to i32 (i32, i8*, i64, ...)*)(i32 %0, i8* %19, i64 8)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %18
%23 = icmp eq i32 %0, 2
br i1 %23, label %24, label %27
24: ; preds = %22
%25 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 0
%26 = call i32 (i32, i8*, i64, ...) bitcast (i32 (...)* @hu_aap_enc_send to i32 (i32, i8*, i64, ...)*)(i32 2, i8* %25, i64 6)
br label %27
27: ; preds = %22, %18, %24
%28 = phi i32 [ %26, %24 ], [ %20, %18 ], [ 0, %22 ]
ret i32 %28
}