#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ msg;
typedef int /*<<< orphan*/ hlp;

/* Variables and functions */
unsigned char eb_calc_crc(unsigned char *, int);
int eb_cmd_get_s_type(int);
int eb_cmd_search_com_cyc(unsigned char const *, int);
int /*<<< orphan*/ eb_cmd_set_cyc_buf(int, unsigned char *, int);
int /*<<< orphan*/ eb_esc(unsigned char *, int *);
int /*<<< orphan*/ eb_unesc(unsigned char *, int *);
int /*<<< orphan*/ log_print(int, char *, char *);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char const *, int);
int /*<<< orphan*/ memset(unsigned char *, char, int);
int eb_cyc_data_process(const unsigned char *buf, int buflen) {
  unsigned char msg[50], hlp[50];
  unsigned char crcm_recv, crcm_calc, acks, crcs_recv, crcs_calc, ackm;
  int id, msgtype, msglen, hlplen, mlen, slen, len;
  memset(msg, '\0', sizeof(msg));
  id = eb_cmd_search_com_cyc(&buf[1], buflen - 1);
  if (id >= 0) {
    msgtype = eb_cmd_get_s_type(id);
    memcpy(msg, buf, buflen);
    msglen = buflen;
    eb_unesc(msg, &msglen);
    mlen = 5 + (int)msg[4];
    memset(hlp, '\0', sizeof(hlp));
    memcpy(hlp, msg, mlen);
    hlplen = mlen;
    eb_esc(hlp, &hlplen);
    crcm_calc = eb_calc_crc(hlp, hlplen);
    crcm_recv = msg[mlen];
    if (crcm_calc != crcm_recv) {
      log_print(0x04, "%s", "Master CRC Error");
      return -2;
    }
    len = mlen + 1;
    if (msgtype != 1) {
      acks = msg[mlen + 1];
      if (acks == 0xFF) {
        log_print(0x04, "%s", "Slave ACK Error");
      }
      len = mlen + 2;
    }
    if (msgtype == 3) {
      slen = 1 + (int)msg[mlen + 2];
      memset(hlp, '\0', sizeof(hlp));
      memcpy(hlp, &msg[mlen + 2], slen);
      hlplen = slen;
      eb_esc(hlp, &hlplen);
      crcs_calc = eb_calc_crc(hlp, hlplen);
      crcs_recv = msg[mlen + 2 + slen];
      if (crcs_calc != crcs_recv) {
        log_print(0x04, "%s", "Slave CRC Error");
        return -2;
      }
      ackm = msg[mlen + 2 + slen + 1];
      if (ackm == 0xFF) {
        log_print(0x04, "%s", "Master ACK Error");
      }
      len = mlen + 2 + slen + 2;
    }
    if (msglen > len) {
      log_print(0x04, "%s", "LEN Error");
      return -2;
    }
    eb_cmd_set_cyc_buf(id, msg, msglen);
  }
  return id;
}


x86 assembly (clang, -O0):
<eb_cyc_data_process>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1050 <memset@plt>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    -0x14(%rbp),%esi
sub    $0x1,%esi
call   10b0 <eb_cmd_search_com_cyc@plt>
mov    %eax,-0x9c(%rbp)
cmpl   $0x0,-0x9c(%rbp)
jl     14c8 <eb_cyc_data_process+0x338>
mov    -0x9c(%rbp),%edi
call   10a0 <eb_cmd_get_s_type@plt>
mov    %eax,-0xa0(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1070 <memcpy@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0xa4(%rbp)
lea    -0x50(%rbp),%rdi
lea    -0xa4(%rbp),%rsi
call   1030 <eb_unesc@plt>
movzbl -0x4c(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0xac(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1050 <memset@plt>
lea    -0x90(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    -0xac(%rbp),%edx
call   1070 <memcpy@plt>
mov    -0xac(%rbp),%eax
mov    %eax,-0xa8(%rbp)
lea    -0x90(%rbp),%rdi
lea    -0xa8(%rbp),%rsi
call   1080 <eb_esc@plt>
lea    -0x90(%rbp),%rdi
mov    -0xa8(%rbp),%esi
call   1060 <eb_calc_crc@plt>
mov    %al,-0x92(%rbp)
movslq -0xac(%rbp),%rax
mov    -0x50(%rbp,%rax,1),%al
mov    %al,-0x91(%rbp)
movzbl -0x92(%rbp),%eax
movzbl -0x91(%rbp),%ecx
cmp    %ecx,%eax
je     12ca <eb_cyc_data_process+0x13a>
mov    $0x4,%edi
lea    0xd4e(%rip),%rsi
lea    0xd4a(%rip),%rdx
call   1040 <log_print@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    14d1 <eb_cyc_data_process+0x341>
mov    -0xac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
cmpl   $0x1,-0xa0(%rbp)
je     1334 <eb_cyc_data_process+0x1a4>
mov    -0xac(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0x50(%rbp,%rax,1),%al
mov    %al,-0x93(%rbp)
movzbl -0x93(%rbp),%eax
cmp    $0xff,%eax
jne    1325 <eb_cyc_data_process+0x195>
mov    $0x4,%edi
lea    0xce7(%rip),%rsi
lea    0xcf4(%rip),%rdx
call   1040 <log_print@plt>
mov    -0xac(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xb4(%rbp)
cmpl   $0x3,-0xa0(%rbp)
jne    147d <eb_cyc_data_process+0x2ed>
mov    -0xac(%rbp),%eax
add    $0x2,%eax
cltq
movzbl -0x50(%rbp,%rax,1),%eax
add    $0x1,%eax
mov    %eax,-0xb0(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1050 <memset@plt>
lea    -0x90(%rbp),%rdi
mov    -0xac(%rbp),%eax
add    $0x2,%eax
cltq
lea    -0x50(%rbp),%rsi
add    %rax,%rsi
mov    -0xb0(%rbp),%edx
call   1070 <memcpy@plt>
mov    -0xb0(%rbp),%eax
mov    %eax,-0xa8(%rbp)
lea    -0x90(%rbp),%rdi
lea    -0xa8(%rbp),%rsi
call   1080 <eb_esc@plt>
lea    -0x90(%rbp),%rdi
mov    -0xa8(%rbp),%esi
call   1060 <eb_calc_crc@plt>
mov    %al,-0x95(%rbp)
mov    -0xac(%rbp),%eax
add    $0x2,%eax
add    -0xb0(%rbp),%eax
cltq
mov    -0x50(%rbp,%rax,1),%al
mov    %al,-0x94(%rbp)
movzbl -0x95(%rbp),%eax
movzbl -0x94(%rbp),%ecx
cmp    %ecx,%eax
je     141d <eb_cyc_data_process+0x28d>
mov    $0x4,%edi
lea    0xbfb(%rip),%rsi
lea    0xc18(%rip),%rdx
call   1040 <log_print@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    14d1 <eb_cyc_data_process+0x341>
mov    -0xac(%rbp),%eax
add    $0x2,%eax
add    -0xb0(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0x50(%rbp,%rax,1),%al
mov    %al,-0x96(%rbp)
movzbl -0x96(%rbp),%eax
cmp    $0xff,%eax
jne    1465 <eb_cyc_data_process+0x2d5>
mov    $0x4,%edi
lea    0xba7(%rip),%rsi
lea    0xbd4(%rip),%rdx
call   1040 <log_print@plt>
mov    -0xac(%rbp),%eax
add    $0x2,%eax
add    -0xb0(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xb4(%rbp)
mov    -0xa4(%rbp),%eax
cmp    -0xb4(%rbp),%eax
jle    14b3 <eb_cyc_data_process+0x323>
mov    $0x4,%edi
lea    0xb65(%rip),%rsi
lea    0xba3(%rip),%rdx
call   1040 <log_print@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    14d1 <eb_cyc_data_process+0x341>
mov    -0x9c(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    -0xa4(%rbp),%edx
call   1090 <eb_cmd_set_cyc_buf@plt>
mov    -0x9c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eb_cyc_data_process>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1050 <memset@plt>
lea    0x1(%rbx),%rdi
lea    -0x1(%rbp),%esi
call   10b0 <eb_cmd_search_com_cyc@plt>
mov    %eax,%r12d
test   %eax,%eax
js     1367 <eb_cyc_data_process+0x1d7>
mov    %r12d,%edi
call   10a0 <eb_cmd_get_s_type@plt>
mov    %eax,%r15d
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1070 <memcpy@plt>
mov    %ebp,0x4(%rsp)
lea    0x4(%rsp),%rsi
mov    %r14,%rdi
call   1030 <eb_unesc@plt>
movzbl 0x14(%rsp),%r13d
lea    0x5(%r13),%rbx
lea    0x50(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1050 <memset@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1070 <memcpy@plt>
mov    %ebx,(%rsp)
mov    %rsp,%rsi
mov    %rbp,%rdi
call   1080 <eb_esc@plt>
mov    (%rsp),%esi
mov    %rbp,%rdi
call   1060 <eb_calc_crc@plt>
cmp    0x15(%rsp,%r13,1),%al
jne    130f <eb_cyc_data_process+0x17f>
lea    0x6(%r13),%rax
cmp    $0x1,%r15d
je     1322 <eb_cyc_data_process+0x192>
cmpb   $0xff,0x10(%rsp,%rax,1)
jne    1278 <eb_cyc_data_process+0xe8>
lea    0xd99(%rip),%rsi
lea    0xda6(%rip),%rdx
mov    $0x4,%edi
call   1040 <log_print@plt>
add    $0x7,%r13
cmp    $0x3,%r15d
jne    131f <eb_cyc_data_process+0x18f>
lea    (%rsp,%r13,1),%rax
add    $0x10,%rax
mov    %rax,0x8(%rsp)
movzbl 0x10(%rsp,%r13,1),%r15d
lea    0x1(%r15),%rbp
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
mov    0x8(%rsp),%rsi
mov    %ebp,%edx
call   1070 <memcpy@plt>
mov    %ebp,(%rsp)
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1080 <eb_esc@plt>
mov    (%rsp),%esi
mov    %rbx,%rdi
call   1060 <eb_calc_crc@plt>
mov    %r13d,%ecx
lea    (%r15,%rcx,1),%rbx
add    $0x1,%rbx
cmp    0x10(%rsp,%rbx,1),%al
jne    1349 <eb_cyc_data_process+0x1b9>
cmpb   $0xff,0x1(%rbx,%r14,1)
jne    130a <eb_cyc_data_process+0x17a>
lea    0xd07(%rip),%rsi
lea    0xd34(%rip),%rdx
mov    $0x4,%edi
call   1040 <log_print@plt>
lea    0x2(%rbx),%eax
jmp    1322 <eb_cyc_data_process+0x192>
lea    0xcea(%rip),%rsi
lea    0xce6(%rip),%rdx
jmp    1357 <eb_cyc_data_process+0x1c7>
mov    %r13d,%eax
mov    0x4(%rsp),%edx
cmp    %eax,%edx
jle    133a <eb_cyc_data_process+0x1aa>
lea    0xccf(%rip),%rsi
lea    0xd0d(%rip),%rdx
jmp    1357 <eb_cyc_data_process+0x1c7>
lea    0x10(%rsp),%rsi
mov    %r12d,%edi
call   1090 <eb_cmd_set_cyc_buf@plt>
jmp    1367 <eb_cyc_data_process+0x1d7>
lea    0xcb0(%rip),%rsi
lea    0xccd(%rip),%rdx
mov    $0x4,%edi
call   1040 <log_print@plt>
mov    $0xfffffffe,%r12d
mov    %r12d,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [17 x i8] c"Master CRC Error\00"
@.str.2 = [16 x i8] c"Slave ACK Error\00"
@.str.3 = [16 x i8] c"Slave CRC Error\00"
@.str.4 = [17 x i8] c"Master ACK Error\00"
@.str.5 = [10 x i8] c"LEN Error\00"
define i32 @eb_cyc_data_process(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [50 x i8]
%7 = alloca [50 x i8]
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8
%11 = alloca i8
%12 = alloca i8
%13 = alloca i8
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%21 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%22 = call i32 @memset(i8* %21, i8 signext 0, i32 50)
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = load i32, i32* %5
%26 = sub nsw i32 %25, 1
%27 = call i32 @eb_cmd_search_com_cyc(i8* %24, i32 %26)
store i32 %27, i32* %14
%28 = load i32, i32* %14
%29 = icmp sge i32 %28, 0
br i1 %29, label %30, label %157
30: ; preds = %2
%31 = load i32, i32* %14
%32 = call i32 @eb_cmd_get_s_type(i32 %31)
store i32 %32, i32* %15
%33 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%34 = load i8*, i8** %4
%35 = load i32, i32* %5
%36 = call i32 @memcpy(i8* %33, i8* %34, i32 %35)
%37 = load i32, i32* %5
store i32 %37, i32* %16
%38 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%39 = call i32 @eb_unesc(i8* %38, i32* %16)
%40 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 4
%41 = load i8, i8* %40
%42 = zext i8 %41 to i32
%43 = add nsw i32 5, %42
store i32 %43, i32* %18
%44 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%45 = call i32 @memset(i8* %44, i8 signext 0, i32 50)
%46 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%47 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%48 = load i32, i32* %18
%49 = call i32 @memcpy(i8* %46, i8* %47, i32 %48)
%50 = load i32, i32* %18
store i32 %50, i32* %17
%51 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%52 = call i32 @eb_esc(i8* %51, i32* %17)
%53 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%54 = load i32, i32* %17
%55 = call zeroext i8 @eb_calc_crc(i8* %53, i32 %54)
store i8 %55, i8* %9
%56 = load i32, i32* %18
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 %57
%59 = load i8, i8* %58
store i8 %59, i8* %8
%60 = load i8, i8* %9
%61 = zext i8 %60 to i32
%62 = load i8, i8* %8
%63 = zext i8 %62 to i32
%64 = icmp ne i32 %61, %63
br i1 %64, label %65, label %67
65: ; preds = %30
%66 = call i32 @log_print(i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
store i32 -2, i32* %3
br label %159
67: ; preds = %30
%68 = load i32, i32* %18
%69 = add nsw i32 %68, 1
store i32 %69, i32* %20
%70 = load i32, i32* %15
%71 = icmp ne i32 %70, 1
br i1 %71, label %72, label %86
72: ; preds = %67
%73 = load i32, i32* %18
%74 = add nsw i32 %73, 1
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 %75
%77 = load i8, i8* %76
store i8 %77, i8* %10
%78 = load i8, i8* %10
%79 = zext i8 %78 to i32
%80 = icmp eq i32 %79, 255
br i1 %80, label %81, label %83
81: ; preds = %72
%82 = call i32 @log_print(i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %83
83: ; preds = %81, %72
%84 = load i32, i32* %18
%85 = add nsw i32 %84, 2
store i32 %85, i32* %20
br label %86
86: ; preds = %83, %67
%87 = load i32, i32* %15
%88 = icmp eq i32 %87, 3
br i1 %88, label %89, label %146
89: ; preds = %86
%90 = load i32, i32* %18
%91 = add nsw i32 %90, 2
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 %92
%94 = load i8, i8* %93
%95 = zext i8 %94 to i32
%96 = add nsw i32 1, %95
store i32 %96, i32* %19
%97 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%98 = call i32 @memset(i8* %97, i8 signext 0, i32 50)
%99 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%100 = load i32, i32* %18
%101 = add nsw i32 %100, 2
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 %102
%104 = load i32, i32* %19
%105 = call i32 @memcpy(i8* %99, i8* %103, i32 %104)
%106 = load i32, i32* %19
store i32 %106, i32* %17
%107 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%108 = call i32 @eb_esc(i8* %107, i32* %17)
%109 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%110 = load i32, i32* %17
%111 = call zeroext i8 @eb_calc_crc(i8* %109, i32 %110)
store i8 %111, i8* %12
%112 = load i32, i32* %18
%113 = add nsw i32 %112, 2
%114 = load i32, i32* %19
%115 = add nsw i32 %113, %114
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 %116
%118 = load i8, i8* %117
store i8 %118, i8* %11
%119 = load i8, i8* %12
%120 = zext i8 %119 to i32
%121 = load i8, i8* %11
%122 = zext i8 %121 to i32
%123 = icmp ne i32 %120, %122
br i1 %123, label %124, label %126
124: ; preds = %89
%125 = call i32 @log_print(i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
store i32 -2, i32* %3
br label %159
126: ; preds = %89
%127 = load i32, i32* %18
%128 = add nsw i32 %127, 2
%129 = load i32, i32* %19
%130 = add nsw i32 %128, %129
%131 = add nsw i32 %130, 1
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 %132
%134 = load i8, i8* %133
store i8 %134, i8* %13
%135 = load i8, i8* %13
%136 = zext i8 %135 to i32
%137 = icmp eq i32 %136, 255
br i1 %137, label %138, label %140
138: ; preds = %126
%139 = call i32 @log_print(i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %140
140: ; preds = %138, %126
%141 = load i32, i32* %18
%142 = add nsw i32 %141, 2
%143 = load i32, i32* %19
%144 = add nsw i32 %142, %143
%145 = add nsw i32 %144, 2
store i32 %145, i32* %20
br label %146
146: ; preds = %140, %86
%147 = load i32, i32* %16
%148 = load i32, i32* %20
%149 = icmp sgt i32 %147, %148
br i1 %149, label %150, label %152
150: ; preds = %146
%151 = call i32 @log_print(i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
store i32 -2, i32* %3
br label %159
152: ; preds = %146
%153 = load i32, i32* %14
%154 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%155 = load i32, i32* %16
%156 = call i32 @eb_cmd_set_cyc_buf(i32 %153, i8* %154, i32 %155)
br label %157
157: ; preds = %152, %2
%158 = load i32, i32* %14
store i32 %158, i32* %3
br label %159
159: ; preds = %157, %150, %124, %65
%160 = load i32, i32* %3
ret i32 %160
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [17 x i8] c"Master CRC Error\00"
@.str.2 = [16 x i8] c"Slave ACK Error\00"
@.str.3 = [16 x i8] c"Slave CRC Error\00"
@.str.4 = [17 x i8] c"Master ACK Error\00"
@.str.5 = [10 x i8] c"LEN Error\00"
define i32 @eb_cyc_data_process(i8* %0, i32 %1) {
%3 = alloca [50 x i8]
%4 = alloca [50 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = call i32 @memset(i8* %7, i8 signext 0, i32 50)
%12 = getelementptr inbounds i8, i8* %0, i64 1
%13 = add nsw i32 %1, -1
%14 = call i32 @eb_cmd_search_com_cyc(i8* %12, i32 %13)
%15 = icmp sgt i32 %14, -1
br i1 %15, label %16, label %84
16: ; preds = %2
%17 = call i32 @eb_cmd_get_s_type(i32 %14)
%18 = call i32 @memcpy(i8* %7, i8* %0, i32 %1)
store i32 %1, i32* %5
%19 = call i32 @eb_unesc(i8* %7, i32* %5)
%20 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 4
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = add nuw nsw i32 %22, 5
%24 = call i32 @memset(i8* %8, i8 signext 0, i32 50)
%25 = call i32 @memcpy(i8* %8, i8* %7, i32 %23)
store i32 %23, i32* %6
%26 = call i32 @eb_esc(i8* %8, i32* %6)
%27 = load i32, i32* %6
%28 = call zeroext i8 @eb_calc_crc(i8* %8, i32 %27)
%29 = zext i32 %23 to i64
%30 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = icmp eq i8 %28, %31
br i1 %32, label %35, label %33
33: ; preds = %16
%34 = call i32 @log_print(i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %84
35: ; preds = %16
%36 = add nuw nsw i32 %22, 6
%37 = icmp eq i32 %17, 1
br i1 %37, label %76, label %38
38: ; preds = %35
%39 = zext i32 %36 to i64
%40 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = icmp eq i8 %41, -1
br i1 %42, label %43, label %45
43: ; preds = %38
%44 = call i32 @log_print(i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %45
45: ; preds = %38, %43
%46 = add nuw nsw i32 %22, 7
%47 = icmp eq i32 %17, 3
br i1 %47, label %48, label %76
48: ; preds = %45
%49 = zext i32 %46 to i64
%50 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %49
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = add nuw nsw i32 %52, 1
%54 = call i32 @memset(i8* %8, i8 signext 0, i32 50)
%55 = call i32 @memcpy(i8* %8, i8* %50, i32 %53)
store i32 %53, i32* %6
%56 = call i32 @eb_esc(i8* %8, i32* %6)
%57 = load i32, i32* %6
%58 = call zeroext i8 @eb_calc_crc(i8* %8, i32 %57)
%59 = add nuw nsw i32 %53, %46
%60 = zext i32 %59 to i64
%61 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %60
%62 = load i8, i8* %61
%63 = icmp eq i8 %58, %62
br i1 %63, label %66, label %64
64: ; preds = %48
%65 = call i32 @log_print(i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %84
66: ; preds = %48
%67 = add nuw nsw i32 %59, 1
%68 = zext i32 %67 to i64
%69 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %68
%70 = load i8, i8* %69
%71 = icmp eq i8 %70, -1
br i1 %71, label %72, label %74
72: ; preds = %66
%73 = call i32 @log_print(i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %74
74: ; preds = %72, %66
%75 = add nuw nsw i32 %59, 2
br label %76
76: ; preds = %35, %74, %45
%77 = phi i32 [ %75, %74 ], [ %46, %45 ], [ %36, %35 ]
%78 = load i32, i32* %5
%79 = icmp sgt i32 %78, %77
br i1 %79, label %80, label %82
80: ; preds = %76
%81 = call i32 @log_print(i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
br label %84
82: ; preds = %76
%83 = call i32 @eb_cmd_set_cyc_buf(i32 %14, i8* %7, i32 %78)
br label %84
84: ; preds = %2, %82, %80, %64, %33
%85 = phi i32 [ -2, %33 ], [ -2, %64 ], [ -2, %80 ], [ %14, %82 ], [ %14, %2 ]
ret i32 %85
}