int aa_pro_all_a07(int chan, unsigned char *buf, int len) {
  if (len != 6 || buf[2] != 0x08 || buf[4] != 0x10)
    hu_log(6, "hu_aap", __func__, "Channel Open Request");
  else
    hu_log(3, "hu_aap", __func__, "Channel Open Request: %d  chan: %d", buf[3],
           buf[5]);
  unsigned char rsp[] = {0, 8, 8, 0};
  int ret = hu_aap_enc_send(chan, rsp, sizeof(rsp));
  if (ret == 0 && chan == 7) {
  }
  if (ret)
    return (ret);
  if (chan == 2) {
    ms_sleep(100);
    unsigned char rspds2[] = {0x80, 0x03, 0x6a, 2, 8, 0};
    return (hu_aap_enc_send(chan, rspds2, sizeof(rspds2)));
  }
  return (ret);
}


x86 assembly (clang, -O0):
<aa_pro_all_a07>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x6,-0x14(%rbp)
jne    116e <aa_pro_all_a07+0x3e>
mov    -0x10(%rbp),%rax
movzbl 0x2(%rax),%eax
cmp    $0x8,%eax
jne    116e <aa_pro_all_a07+0x3e>
mov    -0x10(%rbp),%rax
movzbl 0x4(%rax),%eax
cmp    $0x10,%eax
je     1194 <aa_pro_all_a07+0x64>
mov    $0x6,%edi
lea    0xe86(%rip),%rsi
lea    0xe86(%rip),%rdx
lea    0xe8e(%rip),%rcx
mov    $0x0,%al
call   1030 <hu_log@plt>
jmp    11c7 <aa_pro_all_a07+0x97>
mov    -0x10(%rbp),%rax
movzbl 0x3(%rax),%r8d
mov    -0x10(%rbp),%rax
movzbl 0x5(%rax),%r9d
mov    $0x3,%edi
lea    0xe4e(%rip),%rsi
lea    0xe4e(%rip),%rdx
lea    0xe6b(%rip),%rcx
mov    $0x0,%al
call   1030 <hu_log@plt>
mov    0xe87(%rip),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1050 <hu_aap_enc_send@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    11ff <aa_pro_all_a07+0xcf>
cmpl   $0x7,-0x8(%rbp)
jne    11ff <aa_pro_all_a07+0xcf>
jmp    11ff <aa_pro_all_a07+0xcf>
cmpl   $0x0,-0x1c(%rbp)
je     1214 <aa_pro_all_a07+0xe4>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    125f <aa_pro_all_a07+0x12f>
cmpl   $0x2,-0x8(%rbp)
jne    1259 <aa_pro_all_a07+0x129>
mov    $0x64,%edi
mov    $0x0,%al
call   1040 <ms_sleep@plt>
mov    0xe1e(%rip),%eax
mov    %eax,-0x22(%rbp)
mov    0xe18(%rip),%ax
mov    %ax,-0x1e(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x22(%rbp),%rsi
mov    $0x6,%edx
mov    $0x0,%al
call   1050 <hu_aap_enc_send@plt>
mov    %eax,-0x4(%rbp)
jmp    125f <aa_pro_all_a07+0x12f>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aa_pro_all_a07>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
cmp    $0x6,%edx
jne    1175 <aa_pro_all_a07+0x45>
cmpb   $0x8,0x2(%rsi)
jne    1175 <aa_pro_all_a07+0x45>
cmpb   $0x10,0x4(%rsi)
jne    1175 <aa_pro_all_a07+0x45>
movzbl 0x3(%rsi),%r8d
movzbl 0x5(%rsi),%r9d
lea    0xea7(%rip),%rsi
lea    0xea7(%rip),%rdx
lea    0xec4(%rip),%rcx
mov    $0x3,%edi
xor    %eax,%eax
call   1030 <hu_log@plt>
jmp    1196 <aa_pro_all_a07+0x66>
lea    0xe84(%rip),%rsi
lea    0xe84(%rip),%rdx
lea    0xe8c(%rip),%rcx
mov    $0x6,%edi
xor    %eax,%eax
call   1030 <hu_log@plt>
movl   $0x80800,0xc(%rsp)
lea    0xc(%rsp),%rsi
mov    $0x4,%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1050 <hu_aap_enc_send@plt>
test   %eax,%eax
jne    11f0 <aa_pro_all_a07+0xc0>
mov    $0x0,%eax
cmp    $0x2,%ebx
jne    11f0 <aa_pro_all_a07+0xc0>
mov    $0x64,%edi
xor    %eax,%eax
call   1040 <ms_sleep@plt>
movw   $0x8,0x8(%rsp)
movl   $0x26a0380,0x4(%rsp)
02
lea    0x4(%rsp),%rsi
mov    $0x6,%edx
mov    $0x2,%edi
xor    %eax,%eax
call   1050 <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_all_a07 = [15 x i8] c"aa_pro_all_a07\00"
@.str.1 = [21 x i8] c"Channel Open Request\00"
@.str.2 = [35 x i8] c"Channel Open Request: %d chan: %d\00"
@__const.aa_pro_all_a07.rsp = [4 x i8] c"\00\08\08\00"
@__const.aa_pro_all_a07.rspds2 = [6 x i8] c"\80\03j\02\08\00"
define i32 @aa_pro_all_a07(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca [4 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, 6
br i1 %12, label %25, 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 %25, label %19
19: ; preds = %13
%20 = load i8*, i8** %6
%21 = getelementptr inbounds i8, i8* %20, i64 4
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = icmp ne i32 %23, 16
br i1 %24, label %25, label %27
25: ; preds = %19, %13, %3
%26 = 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_all_a07, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %37
27: ; preds = %19
%28 = load i8*, i8** %6
%29 = getelementptr inbounds i8, i8* %28, i64 3
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
%32 = load i8*, i8** %6
%33 = getelementptr inbounds i8, i8* %32, i64 5
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = call i32 (i32, i8*, i8*, i8*, i32, i32, ...) bitcast (i32 (...)* @hu_log to i32 (i32, i8*, i8*, i8*, i32, 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_all_a07, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %31, i32 %35)
br label %37
37: ; preds = %27, %25
%38 = bitcast [4 x i8]* %8 to i8*
%39 = load i32, i32* %5
%40 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%41 = call i32 (i32, i8*, i64, ...) bitcast (i32 (...)* @hu_aap_enc_send to i32 (i32, i8*, i64, ...)*)(i32 %39, i8* %40, i64 4)
store i32 %41, i32* %9
%42 = load i32, i32* %9
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %37
%45 = load i32, i32* %5
%46 = icmp eq i32 %45, 7
br i1 %46, label %47, label %48
47: ; preds = %44
br label %48
48: ; preds = %47, %44, %37
%49 = load i32, i32* %9
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %48
%52 = load i32, i32* %9
store i32 %52, i32* %4
br label %64
53: ; preds = %48
%54 = load i32, i32* %5
%55 = icmp eq i32 %54, 2
br i1 %55, label %56, label %62
56: ; preds = %53
%57 = call i32 (i32, ...) bitcast (i32 (...)* @ms_sleep to i32 (i32, ...)*)(i32 100)
%58 = bitcast [6 x i8]* %10 to i8*
%59 = load i32, i32* %5
%60 = getelementptr inbounds [6 x i8], [6 x i8]* %10, i64 0, i64 0
%61 = call i32 (i32, i8*, i64, ...) bitcast (i32 (...)* @hu_aap_enc_send to i32 (i32, i8*, i64, ...)*)(i32 %59, i8* %60, i64 6)
store i32 %61, i32* %4
br label %64
62: ; preds = %53
%63 = load i32, i32* %9
store i32 %63, i32* %4
br label %64
64: ; preds = %62, %56, %51
%65 = load i32, i32* %4
ret i32 %65
}

LLVM IR (-O2):
@.str = [7 x i8] c"hu_aap\00"
@__func__.aa_pro_all_a07 = [15 x i8] c"aa_pro_all_a07\00"
@.str.1 = [21 x i8] c"Channel Open Request\00"
@.str.2 = [35 x i8] c"Channel Open Request: %d chan: %d\00"
@__const.aa_pro_all_a07.rspds2 = [6 x i8] c"\80\03j\02\08\00"
define i32 @aa_pro_all_a07(i32 %0, i8* nocapture %1, i32 %2) {
%4 = alloca i32
%5 = alloca [6 x i8]
%6 = icmp eq i32 %2, 6
br i1 %6, label %7, label %15
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 %11, label %15
11: ; preds = %7
%12 = getelementptr inbounds i8, i8* %1, i64 4
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 16
br i1 %14, label %17, label %15
15: ; preds = %11, %7, %3
%16 = 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_all_a07, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %25
17: ; preds = %11
%18 = getelementptr inbounds i8, i8* %1, i64 3
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = getelementptr inbounds i8, i8* %1, i64 5
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = tail call i32 (i32, i8*, i8*, i8*, i32, i32, ...) bitcast (i32 (...)* @hu_log to i32 (i32, i8*, i8*, i8*, i32, 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_all_a07, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %20, i32 %23)
br label %25
25: ; preds = %17, %15
%26 = bitcast i32* %4 to i8*
store i32 526336, i32* %4
%27 = call i32 (i32, i8*, i64, ...) bitcast (i32 (...)* @hu_aap_enc_send to i32 (i32, i8*, i64, ...)*)(i32 %0, i8* %26, i64 4)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %25
%30 = icmp eq i32 %0, 2
br i1 %30, label %31, label %35
31: ; preds = %29
%32 = call i32 (i32, ...) bitcast (i32 (...)* @ms_sleep to i32 (i32, ...)*)(i32 100)
%33 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 0
%34 = call i32 (i32, i8*, i64, ...) bitcast (i32 (...)* @hu_aap_enc_send to i32 (i32, i8*, i64, ...)*)(i32 2, i8* %33, i64 6)
br label %35
35: ; preds = %29, %25, %31
%36 = phi i32 [ %34, %31 ], [ %27, %25 ], [ 0, %29 ]
ret i32 %36
}