int aa_pro_sen_b01(int chan, unsigned char *buf, int len) {
  if (len != 6 || buf[2] != 0x08 || buf[4] != 0x10)
    hu_log(6, "hu_aap", __func__, "Sensor Start Request");
  else
    hu_log(3, "hu_aap", __func__,
           "Sensor Start Request sensor: %d   period: %d", buf[3], buf[5]);
  unsigned char rsp[] = {0x80, 0x02, 0x08, 0};
  int ret = hu_aap_enc_send(chan, rsp, sizeof(rsp));
  return (ret);
}


x86 assembly (clang, -O0):
<aa_pro_sen_b01>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x6,-0x14(%rbp)
jne    115e <aa_pro_sen_b01+0x3e>
mov    -0x10(%rbp),%rax
movzbl 0x2(%rax),%eax
cmp    $0x8,%eax
jne    115e <aa_pro_sen_b01+0x3e>
mov    -0x10(%rbp),%rax
movzbl 0x4(%rax),%eax
cmp    $0x10,%eax
je     1184 <aa_pro_sen_b01+0x64>
mov    $0x6,%edi
lea    0xe96(%rip),%rsi
lea    0xe96(%rip),%rdx
lea    0xe9e(%rip),%rcx
mov    $0x0,%al
call   1030 <hu_log@plt>
jmp    11b7 <aa_pro_sen_b01+0x97>
mov    -0x10(%rbp),%rax
movzbl 0x3(%rax),%r8d
mov    -0x10(%rbp),%rax
movzbl 0x5(%rax),%r9d
mov    $0x3,%edi
lea    0xe5e(%rip),%rsi
lea    0xe5e(%rip),%rdx
lea    0xe7b(%rip),%rcx
mov    $0x0,%al
call   1030 <hu_log@plt>
mov    0xe9b(%rip),%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1040 <hu_aap_enc_send@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aa_pro_sen_b01>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
cmp    $0x6,%edx
jne    1165 <aa_pro_sen_b01+0x45>
cmpb   $0x8,0x2(%rsi)
jne    1165 <aa_pro_sen_b01+0x45>
cmpb   $0x10,0x4(%rsi)
jne    1165 <aa_pro_sen_b01+0x45>
movzbl 0x3(%rsi),%r8d
movzbl 0x5(%rsi),%r9d
lea    0xeb7(%rip),%rsi
lea    0xeb7(%rip),%rdx
lea    0xed4(%rip),%rcx
mov    $0x3,%edi
xor    %eax,%eax
call   1030 <hu_log@plt>
jmp    1186 <aa_pro_sen_b01+0x66>
lea    0xe94(%rip),%rsi
lea    0xe94(%rip),%rdx
lea    0xe9c(%rip),%rcx
mov    $0x6,%edi
xor    %eax,%eax
call   1030 <hu_log@plt>
movl   $0x80280,0xc(%rsp)
lea    0xc(%rsp),%rsi
mov    $0x4,%edx
mov    %ebx,%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_sen_b01 = [15 x i8] c"aa_pro_sen_b01\00"
@.str.1 = [21 x i8] c"Sensor Start Request\00"
@.str.2 = [45 x i8] c"Sensor Start Request sensor: %d period: %d\00"
@__const.aa_pro_sen_b01.rsp = [4 x i8] c"\80\02\08\00"
define i32 @aa_pro_sen_b01(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [4 x i8]
%8 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load i32, i32* %6
%10 = icmp ne i32 %9, 6
br i1 %10, label %23, label %11
11: ; preds = %3
%12 = load i8*, i8** %5
%13 = getelementptr inbounds i8, i8* %12, i64 2
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = icmp ne i32 %15, 8
br i1 %16, label %23, label %17
17: ; preds = %11
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i64 4
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = icmp ne i32 %21, 16
br i1 %22, label %23, label %25
23: ; preds = %17, %11, %3
%24 = 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_sen_b01, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %35
25: ; preds = %17
%26 = load i8*, i8** %5
%27 = getelementptr inbounds i8, i8* %26, i64 3
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = load i8*, i8** %5
%31 = getelementptr inbounds i8, i8* %30, i64 5
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = 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_sen_b01, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %29, i32 %33)
br label %35
35: ; preds = %25, %23
%36 = bitcast [4 x i8]* %7 to i8*
%37 = load i32, i32* %4
%38 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%39 = call i32 (i32, i8*, i64, ...) bitcast (i32 (...)* @hu_aap_enc_send to i32 (i32, i8*, i64, ...)*)(i32 %37, i8* %38, i64 4)
store i32 %39, i32* %8
%40 = load i32, i32* %8
ret i32 %40
}

LLVM IR (-O2):
@.str = [7 x i8] c"hu_aap\00"
@__func__.aa_pro_sen_b01 = [15 x i8] c"aa_pro_sen_b01\00"
@.str.1 = [21 x i8] c"Sensor Start Request\00"
@.str.2 = [45 x i8] c"Sensor Start Request sensor: %d period: %d\00"
define i32 @aa_pro_sen_b01(i32 %0, i8* nocapture %1, i32 %2) {
%4 = alloca i32
%5 = icmp eq i32 %2, 6
br i1 %5, label %6, label %14
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %1, i64 2
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 8
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = getelementptr inbounds i8, i8* %1, i64 4
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 16
br i1 %13, label %16, label %14
14: ; preds = %10, %6, %3
%15 = 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_sen_b01, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %24
16: ; preds = %10
%17 = getelementptr inbounds i8, i8* %1, i64 3
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = getelementptr inbounds i8, i8* %1, i64 5
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = 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_sen_b01, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %22)
br label %24
24: ; preds = %16, %14
%25 = bitcast i32* %4 to i8*
store i32 524928, i32* %4
%26 = call i32 (i32, i8*, i64, ...) bitcast (i32 (...)* @hu_aap_enc_send to i32 (i32, i8*, i64, ...)*)(i32 %0, i8* %25, i64 4)
ret i32 %26
}