int aa_pro_ctr_a0f(int chan, unsigned char *buf, int len) {
  if (len != 4 || buf[2] != 0x08)
    hu_log(6, "hu_aap", __func__, "Byebye Request");
  else if (buf[3] == 1)
    hu_log(3, "hu_aap", __func__, "Byebye Request reason: 1 AA Exit Car Mode");
  else if (buf[3] == 2)
    hu_log(6, "hu_aap", __func__, "Byebye Request reason: 2 ?");
  else
    hu_log(6, "hu_aap", __func__, "Byebye Request reason: %d", buf[3]);
  buf[0] = 0;
  buf[1] = 16;
  buf[2] = 0x08;
  buf[3] = 0;
  int ret = hu_aap_enc_send(chan, buf, 4);
  ms_sleep(100);
  hu_aap_stop();
  return (-1);
}


x86 assembly (clang, -O0):
<aa_pro_ctr_a0f>:
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    116d <aa_pro_ctr_a0f+0x2d>
mov    -0x10(%rbp),%rax
movzbl 0x2(%rax),%eax
cmp    $0x8,%eax
je     1193 <aa_pro_ctr_a0f+0x53>
mov    $0x6,%edi
lea    0xe87(%rip),%rsi
lea    0xe87(%rip),%rdx
lea    0xe8f(%rip),%rcx
mov    $0x0,%al
call   1040 <hu_log@plt>
jmp    1235 <aa_pro_ctr_a0f+0xf5>
mov    -0x10(%rbp),%rax
movzbl 0x3(%rax),%eax
cmp    $0x1,%eax
jne    11ca <aa_pro_ctr_a0f+0x8a>
mov    $0x3,%edi
lea    0xe50(%rip),%rsi
lea    0xe50(%rip),%rdx
lea    0xe67(%rip),%rcx
mov    $0x0,%al
call   1040 <hu_log@plt>
jmp    1230 <aa_pro_ctr_a0f+0xf0>
mov    -0x10(%rbp),%rax
movzbl 0x3(%rax),%eax
cmp    $0x2,%eax
jne    1201 <aa_pro_ctr_a0f+0xc1>
mov    $0x6,%edi
lea    0xe19(%rip),%rsi
lea    0xe19(%rip),%rdx
lea    0xe5a(%rip),%rcx
mov    $0x0,%al
call   1040 <hu_log@plt>
jmp    122b <aa_pro_ctr_a0f+0xeb>
mov    -0x10(%rbp),%rax
movzbl 0x3(%rax),%r8d
mov    $0x6,%edi
lea    0xdea(%rip),%rsi
lea    0xdea(%rip),%rdx
lea    0xe46(%rip),%rcx
mov    $0x0,%al
call   1040 <hu_log@plt>
jmp    1230 <aa_pro_ctr_a0f+0xf0>
jmp    1235 <aa_pro_ctr_a0f+0xf5>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x10,0x1(%rax)
mov    -0x10(%rbp),%rax
movb   $0x8,0x2(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,0x3(%rax)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1060 <hu_aap_enc_send@plt>
mov    %eax,-0x18(%rbp)
mov    $0x64,%edi
mov    $0x0,%al
call   1050 <ms_sleep@plt>
mov    $0x0,%al
call   1030 <hu_aap_stop@plt>
mov    $0xffffffff,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aa_pro_ctr_a0f>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
cmp    $0x4,%edx
jne    1180 <aa_pro_ctr_a0f+0x40>
cmpb   $0x8,0x2(%rbx)
jne    1180 <aa_pro_ctr_a0f+0x40>
movzbl 0x3(%rbx),%r8d
lea    0xea1(%rip),%rsi
lea    0xea1(%rip),%rdx
cmp    $0x2,%r8d
je     11d7 <aa_pro_ctr_a0f+0x97>
cmp    $0x1,%r8b
jne    11e0 <aa_pro_ctr_a0f+0xa0>
lea    0xeac(%rip),%rcx
mov    $0x3,%edi
jmp    119a <aa_pro_ctr_a0f+0x5a>
lea    0xe79(%rip),%rsi
lea    0xe79(%rip),%rdx
lea    0xe81(%rip),%rcx
mov    $0x6,%edi
xor    %eax,%eax
call   1040 <hu_log@plt>
movl   $0x81000,(%rbx)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x4,%edx
xor    %eax,%eax
call   1060 <hu_aap_enc_send@plt>
mov    $0x64,%edi
xor    %eax,%eax
call   1050 <ms_sleep@plt>
xor    %eax,%eax
call   1030 <hu_aap_stop@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe71(%rip),%rcx
jmp    1195 <aa_pro_ctr_a0f+0x55>
lea    0xe83(%rip),%rcx
mov    $0x6,%edi
xor    %eax,%eax
call   1040 <hu_log@plt>
jmp    11a1 <aa_pro_ctr_a0f+0x61>

LLVM IR (-O0):
@.str = [7 x i8] c"hu_aap\00"
@__func__.aa_pro_ctr_a0f = [15 x i8] c"aa_pro_ctr_a0f\00"
@.str.1 = [15 x i8] c"Byebye Request\00"
@.str.2 = [42 x i8] c"Byebye Request reason: 1 AA Exit Car Mode\00"
@.str.3 = [27 x i8] c"Byebye Request reason: 2 ?\00"
@.str.4 = [26 x i8] c"Byebye Request reason: %d\00"
define i32 @aa_pro_ctr_a0f(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_a0f, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %42
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_a0f, i64 0, i64 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
br label %41
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 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_a0f, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %40
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 = 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_a0f, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %34, %32
br label %41
41: ; preds = %40, %24
br label %42
42: ; preds = %41, %16
%43 = load i8*, i8** %5
%44 = getelementptr inbounds i8, i8* %43, i64 0
store i8 0, i8* %44
%45 = load i8*, i8** %5
%46 = getelementptr inbounds i8, i8* %45, i64 1
store i8 16, i8* %46
%47 = load i8*, i8** %5
%48 = getelementptr inbounds i8, i8* %47, i64 2
store i8 8, i8* %48
%49 = load i8*, i8** %5
%50 = getelementptr inbounds i8, i8* %49, i64 3
store i8 0, i8* %50
%51 = load i32, i32* %4
%52 = load i8*, i8** %5
%53 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @hu_aap_enc_send to i32 (i32, i8*, i32, ...)*)(i32 %51, i8* %52, i32 4)
store i32 %53, i32* %7
%54 = call i32 (i32, ...) bitcast (i32 (...)* @ms_sleep to i32 (i32, ...)*)(i32 100)
%55 = call i32 (...) @hu_aap_stop()
ret i32 -1
}

LLVM IR (-O2):
@.str = [7 x i8] c"hu_aap\00"
@__func__.aa_pro_ctr_a0f = [15 x i8] c"aa_pro_ctr_a0f\00"
@.str.1 = [15 x i8] c"Byebye Request\00"
@.str.2 = [42 x i8] c"Byebye Request reason: 1 AA Exit Car Mode\00"
@.str.3 = [27 x i8] c"Byebye Request reason: 2 ?\00"
@.str.4 = [26 x i8] c"Byebye Request reason: %d\00"
define i32 @aa_pro_ctr_a0f(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_a0f, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %21
11: ; preds = %5
%12 = getelementptr inbounds i8, i8* %1, i64 3
%13 = load i8, i8* %12
switch i8 %13, label %18 [
i8 1, label %14
i8 2, label %16
]
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_a0f, i64 0, i64 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
br label %21
16: ; preds = %11
%17 = 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_a0f, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %21
18: ; preds = %11
%19 = zext i8 %13 to i32
%20 = 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_a0f, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %14, %18, %16, %9
store i8 0, i8* %1
%22 = getelementptr inbounds i8, i8* %1, i64 1
store i8 16, i8* %22
%23 = getelementptr inbounds i8, i8* %1, i64 2
store i8 8, i8* %23
%24 = getelementptr inbounds i8, i8* %1, i64 3
store i8 0, i8* %24
%25 = tail call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @hu_aap_enc_send to i32 (i32, i8*, i32, ...)*)(i32 %0, i8* %1, i32 4)
%26 = tail call i32 (i32, ...) bitcast (i32 (...)* @ms_sleep to i32 (i32, ...)*)(i32 100)
%27 = tail call i32 (...) @hu_aap_stop()
ret i32 -1
}