int eb_cyc_data_recv() {
  static unsigned char msg[100];
  static int msglen = 0;
  unsigned char buf[100];
  int ret, i, buflen;
  char tmp[1024];
  int tmplen;
  memset(buf, '\0', sizeof(buf));
  buflen = sizeof(buf);
  if (msglen == 0)
    memset(msg, '\0', sizeof(msg));
  ret = eb_serial_recv(buf, &buflen);
  if (ret < 0)
    return -1;
  i = 0;
  while (i < buflen) {
    if (buf[i] != 0xAA) {
      msg[msglen] = buf[i];
      msglen++;
    }
    if (buf[i] == 0xAA && msglen > 0) {
      eb_print_hex(msg, msglen);
      ret = eb_cyc_data_process(msg, msglen);
      if (ret > 0) {
        memset(tmp, '\0', sizeof(tmp));
        eb_execute(ret, "-", tmp, &tmplen);
        tmp[strcspn(tmp, "\n")] = '\0';
        log_print(0x40, "%s", tmp);
      }
      memset(msg, '\0', sizeof(msg));
      msglen = 0;
    }
    i++;
  }
  return msglen;
}


x86 assembly (clang, -O0):
<eb_cyc_data_recv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x490,%rsp
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
movl   $0x64,-0x7c(%rbp)
cmpl   $0x0,0x2f3b(%rip)
jne    11b2 <eb_cyc_data_recv+0x42>
lea    0x2eca(%rip),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
lea    -0x70(%rbp),%rdi
lea    -0x7c(%rbp),%rsi
mov    $0x0,%al
call   1030 <eb_serial_recv@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0x0,-0x74(%rbp)
jge    11da <eb_cyc_data_recv+0x6a>
movl   $0xffffffff,-0x4(%rbp)
jmp    131a <eb_cyc_data_recv+0x1aa>
movl   $0x0,-0x78(%rbp)
mov    -0x78(%rbp),%eax
cmp    -0x7c(%rbp),%eax
jge    1311 <eb_cyc_data_recv+0x1a1>
movslq -0x78(%rbp),%rax
movzbl -0x70(%rbp,%rax,1),%eax
cmp    $0xaa,%eax
je     1229 <eb_cyc_data_recv+0xb9>
movslq -0x78(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%dl
movslq 0x2ec4(%rip),%rcx
lea    0x2e59(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    0x2eb4(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2eab(%rip)
movslq -0x78(%rbp),%rax
movzbl -0x70(%rbp,%rax,1),%eax
cmp    $0xaa,%eax
jne    1303 <eb_cyc_data_recv+0x193>
cmpl   $0x0,0x2e90(%rip)
jle    1303 <eb_cyc_data_recv+0x193>
mov    0x2e84(%rip),%esi
lea    0x2e19(%rip),%rdi
mov    $0x0,%al
call   1080 <eb_print_hex@plt>
mov    0x2e70(%rip),%esi
lea    0x2e05(%rip),%rdi
mov    $0x0,%al
call   1090 <eb_cyc_data_process@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0x0,-0x74(%rbp)
jle    12e6 <eb_cyc_data_recv+0x176>
lea    -0x480(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
mov    -0x74(%rbp),%edi
lea    -0x480(%rbp),%rdx
lea    0xd5d(%rip),%rsi
lea    -0x484(%rbp),%rcx
mov    $0x0,%al
call   1060 <eb_execute@plt>
lea    -0x480(%rbp),%rdi
lea    0xd43(%rip),%rsi
call   1070 <strcspn@plt>
movb   $0x0,-0x480(%rbp,%rax,1)
lea    -0x480(%rbp),%rdx
mov    $0x40,%edi
lea    0xd25(%rip),%rsi
mov    $0x0,%al
call   1040 <log_print@plt>
lea    0x2d83(%rip),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
movl   $0x0,0x2dd1(%rip)
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    11e1 <eb_cyc_data_recv+0x71>
mov    0x2dbd(%rip),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x490,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eb_cyc_data_recv>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x488,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x60(%rsp)
movl   $0x0,0x70(%rsp)
movl   $0x64,0x8(%rsp)
cmpl   $0x0,0x2f1b(%rip)
jne    11ef <eb_cyc_data_recv+0x7f>
movaps %xmm0,0x2efe(%rip)
movaps %xmm0,0x2ee7(%rip)
movaps %xmm0,0x2ed0(%rip)
movaps %xmm0,0x2eb9(%rip)
movaps %xmm0,0x2ea2(%rip)
movaps %xmm0,0x2e8b(%rip)
movl   $0x0,0x2ee1(%rip)
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1030 <eb_serial_recv@plt>
test   %eax,%eax
js     132e <eb_cyc_data_recv+0x1be>
mov    0x8(%rsp),%eax
test   %eax,%eax
jle    1335 <eb_cyc_data_recv+0x1c5>
lea    0x2e55(%rip),%rbx
lea    0x80(%rsp),%r14
lea    0xdd8(%rip),%r13
lea    0xdd3(%rip),%rbp
xor    %r12d,%r12d
jmp    125f <eb_cyc_data_recv+0xef>
cs nopw 0x0(%rax,%rax,1)
movslq %esi,%rsi
mov    %cl,(%rsi,%rbx,1)
add    $0x1,%esi
mov    %esi,0x2e85(%rip)
add    $0x1,%r12
movslq %eax,%rcx
cmp    %rcx,%r12
jge    133b <eb_cyc_data_recv+0x1cb>
movzbl 0x10(%rsp,%r12,1),%ecx
mov    0x2e69(%rip),%esi
cmp    $0xaa,%cl
jne    1240 <eb_cyc_data_recv+0xd0>
test   %esi,%esi
jle    124f <eb_cyc_data_recv+0xdf>
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <eb_print_hex@plt>
mov    0x2e50(%rip),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1090 <eb_cyc_data_process@plt>
test   %eax,%eax
jle    12e2 <eb_cyc_data_recv+0x172>
mov    %eax,%r15d
mov    $0x400,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %r15d,%edi
lea    0xd52(%rip),%rsi
mov    %r14,%rdx
lea    0xc(%rsp),%rcx
xor    %eax,%eax
call   1060 <eb_execute@plt>
mov    %r14,%rdi
mov    %r13,%rsi
call   1070 <strcspn@plt>
movb   $0x0,0x80(%rsp,%rax,1)
mov    $0x40,%edi
mov    %rbp,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <log_print@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x2dd4(%rip)
movaps %xmm0,0x2dbd(%rip)
movaps %xmm0,0x2da6(%rip)
movaps %xmm0,0x2d8f(%rip)
movaps %xmm0,0x2d78(%rip)
movaps %xmm0,0x2d61(%rip)
movl   $0x0,0x2db7(%rip)
movl   $0x0,0x2db1(%rip)
xor    %esi,%esi
mov    0x8(%rsp),%eax
jmp    124f <eb_cyc_data_recv+0xdf>
mov    $0xffffffff,%esi
jmp    133b <eb_cyc_data_recv+0x1cb>
mov    0x2d99(%rip),%esi
mov    %esi,%eax
add    $0x488,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@eb_cyc_data_recv.msg = internal global [100 x i8] zeroinitializer
@eb_cyc_data_recv.msglen = internal global i32 0
@.str = [2 x i8] c"-\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @eb_cyc_data_recv() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [1024 x i8]
%7 = alloca i32
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
store i32 100, i32* %5
%9 = load i32, i32* @eb_cyc_data_recv.msglen
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %0
br label %12
12: ; preds = %11, %0
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%14 = call i32 (i8*, i32*, ...) bitcast (i32 (...)* @eb_serial_recv to i32 (i8*, i32*, ...)*)(i8* %13, i32* %5)
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %12
store i32 -1, i32* %1
br label %73
18: ; preds = %12
store i32 0, i32* %4
br label %19
19: ; preds = %68, %18
%20 = load i32, i32* %4
%21 = load i32, i32* %5
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %71
23: ; preds = %19
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = icmp ne i32 %28, 170
br i1 %29, label %30, label %40
30: ; preds = %23
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = load i32, i32* @eb_cyc_data_recv.msglen
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [100 x i8], [100 x i8]* @eb_cyc_data_recv.msg, i64 0, i64 %36
store i8 %34, i8* %37
%38 = load i32, i32* @eb_cyc_data_recv.msglen
%39 = add nsw i32 %38, 1
store i32 %39, i32* @eb_cyc_data_recv.msglen
br label %40
40: ; preds = %30, %23
%41 = load i32, i32* %4
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = zext i8 %44 to i32
%46 = icmp eq i32 %45, 170
br i1 %46, label %47, label %68
47: ; preds = %40
%48 = load i32, i32* @eb_cyc_data_recv.msglen
%49 = icmp sgt i32 %48, 0
br i1 %49, label %50, label %68
50: ; preds = %47
%51 = load i32, i32* @eb_cyc_data_recv.msglen
%52 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @eb_print_hex to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @eb_cyc_data_recv.msg, i64 0, i64 0), i32 %51)
%53 = load i32, i32* @eb_cyc_data_recv.msglen
%54 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @eb_cyc_data_process to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @eb_cyc_data_recv.msg, i64 0, i64 0), i32 %53)
store i32 %54, i32* %3
%55 = load i32, i32* %3
%56 = icmp sgt i32 %55, 0
br i1 %56, label %57, label %67
57: ; preds = %50
%58 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%59 = load i32, i32* %3
%60 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%61 = call i32 (i32, i8*, i8*, i32*, ...) bitcast (i32 (...)* @eb_execute to i32 (i32, i8*, i8*, i32*, ...)*)(i32 %59, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %60, i32* %7)
%62 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%63 = call i64 @strcspn(i8* %62, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%64 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 %63
store i8 0, i8* %64
%65 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%66 = call i32 (i32, i8*, i8*, ...) bitcast (i32 (...)* @log_print to i32 (i32, i8*, i8*, ...)*)(i32 64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %65)
br label %67
67: ; preds = %57, %50
store i32 0, i32* @eb_cyc_data_recv.msglen
br label %68
68: ; preds = %67, %47, %40
%69 = load i32, i32* %4
%70 = add nsw i32 %69, 1
store i32 %70, i32* %4
br label %19
71: ; preds = %19
%72 = load i32, i32* @eb_cyc_data_recv.msglen
store i32 %72, i32* %1
br label %73
73: ; preds = %71, %17
%74 = load i32, i32* %1
ret i32 %74
}

LLVM IR (-O2):
@eb_cyc_data_recv.msg = internal global [100 x i8] zeroinitializer
@eb_cyc_data_recv.msglen = internal unnamed_addr global i32 0
@.str = [2 x i8] c"-\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @eb_cyc_data_recv() {
%1 = alloca [100 x i8]
%2 = alloca i32
%3 = alloca [1024 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%6 = bitcast i32* %2 to i8*
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%8 = bitcast i32* %4 to i8*
store i32 100, i32* %2
%9 = load i32, i32* @eb_cyc_data_recv.msglen
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %0
tail call void @llvm.memset.p0i8.i64(i8* align 16 dereferenceable(100) getelementptr inbounds ([100 x i8], [100 x i8]* @eb_cyc_data_recv.msg, i64 0, i64 0), i8 0, i64 100, i1 false)
br label %12
12: ; preds = %11, %0
%13 = call i32 (i8*, i32*, ...) bitcast (i32 (...)* @eb_serial_recv to i32 (i8*, i32*, ...)*)(i8* %5, i32* %2)
%14 = icmp slt i32 %13, 0
br i1 %14, label %51, label %15
15: ; preds = %12
%16 = load i32, i32* %2
%17 = icmp sgt i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = load i32, i32* @eb_cyc_data_recv.msglen
br label %51
20: ; preds = %15, %45
%21 = phi i32 [ %47, %45 ], [ %16, %15 ]
%22 = phi i64 [ %48, %45 ], [ 0, %15 ]
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, -86
%26 = load i32, i32* @eb_cyc_data_recv.msglen
br i1 %25, label %31, label %27
27: ; preds = %20
%28 = sext i32 %26 to i64
%29 = getelementptr inbounds [100 x i8], [100 x i8]* @eb_cyc_data_recv.msg, i64 0, i64 %28
store i8 %24, i8* %29
%30 = add nsw i32 %26, 1
store i32 %30, i32* @eb_cyc_data_recv.msglen
br label %45
31: ; preds = %20
%32 = icmp sgt i32 %26, 0
br i1 %32, label %33, label %45
33: ; preds = %31
%34 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @eb_print_hex to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @eb_cyc_data_recv.msg, i64 0, i64 0), i32 %26)
%35 = load i32, i32* @eb_cyc_data_recv.msglen
%36 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @eb_cyc_data_process to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @eb_cyc_data_recv.msg, i64 0, i64 0), i32 %35)
%37 = icmp sgt i32 %36, 0
br i1 %37, label %38, label %43
38: ; preds = %33
%39 = call i32 (i32, i8*, i8*, i32*, ...) bitcast (i32 (...)* @eb_execute to i32 (i32, i8*, i8*, i32*, ...)*)(i32 %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %7, i32* %4)
%40 = call i64 @strcspn(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%41 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %40
store i8 0, i8* %41
%42 = call i32 (i32, i8*, i8*, ...) bitcast (i32 (...)* @log_print to i32 (i32, i8*, i8*, ...)*)(i32 64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %7)
br label %43
43: ; preds = %38, %33
store i32 0, i32* @eb_cyc_data_recv.msglen
%44 = load i32, i32* %2
br label %45
45: ; preds = %27, %43, %31
%46 = phi i32 [ %30, %27 ], [ 0, %43 ], [ %26, %31 ]
%47 = phi i32 [ %21, %27 ], [ %44, %43 ], [ %21, %31 ]
%48 = add nuw nsw i64 %22, 1
%49 = sext i32 %47 to i64
%50 = icmp slt i64 %48, %49
br i1 %50, label %20, label %51
51: ; preds = %45, %18, %12
%52 = phi i32 [ -1, %12 ], [ %19, %18 ], [ %46, %45 ]
ret i32 %52
}