#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 */

/* Variables and functions */
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ printf(char *, unsigned int, int);
int CmmbRtpToDRA(unsigned char *buffer, int recv_bytes,
                 unsigned char *save_buffer, int *pnLastPkt) {
  int save_len = 0;
  unsigned int nPkt = 0;
  nPkt = (unsigned int)(((buffer[2]) << 8) | (buffer[3]));
  if (nPkt - (*pnLastPkt) > 1) {
    printf("lose nPkt = %u, last = %u\n", nPkt, *pnLastPkt);
  }
  if (nPkt < *(pnLastPkt)) {
  }
  (*pnLastPkt) = nPkt;
  if (buffer[12] == 0xff) {
    memcpy(&(save_buffer[0]), &(buffer[13]), recv_bytes - 13);
    save_len += (recv_bytes - 13);
  } else {
    memcpy(&(save_buffer[0]), &(buffer[12]), recv_bytes - 12);
    save_len += (recv_bytes - 12);
  }
  return save_len;
}


x86 assembly (clang, -O0):
<CmmbRtpToDRA>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x2(%rax),%eax
shl    $0x8,%eax
mov    -0x8(%rbp),%rcx
movzbl 0x3(%rcx),%ecx
or     %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x20(%rbp),%rcx
sub    (%rcx),%eax
cmp    $0x1,%eax
jbe    1184 <CmmbRtpToDRA+0x64>
mov    -0x28(%rbp),%esi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
jae    1198 <CmmbRtpToDRA+0x78>
jmp    1198 <CmmbRtpToDRA+0x78>
mov    -0x28(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
movzbl 0xc(%rax),%eax
cmp    $0xff,%eax
jne    11dc <CmmbRtpToDRA+0xbc>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0xd,%rsi
mov    -0xc(%rbp),%edx
sub    $0xd,%edx
call   1040 <memcpy@plt>
mov    -0xc(%rbp),%eax
sub    $0xd,%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    11ff <CmmbRtpToDRA+0xdf>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0xc,%rsi
mov    -0xc(%rbp),%edx
sub    $0xc,%edx
call   1040 <memcpy@plt>
mov    -0xc(%rbp),%eax
sub    $0xc,%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CmmbRtpToDRA>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r15
mov    %rdx,%r14
mov    %esi,%r12d
mov    %rdi,%rbx
movzwl 0x2(%rdi),%ebp
shl    $0x10,%ebp
bswap  %ebp
mov    (%rcx),%edx
mov    %ebp,%eax
sub    %edx,%eax
cmp    $0x2,%eax
jb     1156 <CmmbRtpToDRA+0x36>
lea    0xeb1(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %ebp,(%r15)
cmpb   $0xff,0xc(%rbx)
je     1169 <CmmbRtpToDRA+0x49>
add    $0xc,%rbx
add    $0xfffffff4,%r12d
jmp    1171 <CmmbRtpToDRA+0x51>
add    $0xd,%rbx
add    $0xfffffff3,%r12d
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1040 <memcpy@plt>
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"lose nPkt = %u, last = %u\0A\00"
define i32 @CmmbRtpToDRA(i8* %0, i32 %1, i8* %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32* %3, i32** %8
store i32 0, i32* %9
store i32 0, i32* %10
%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 = shl i32 %14, 8
%16 = load i8*, i8** %5
%17 = getelementptr inbounds i8, i8* %16, i64 3
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = or i32 %15, %19
store i32 %20, i32* %10
%21 = load i32, i32* %10
%22 = load i32*, i32** %8
%23 = load i32, i32* %22
%24 = sub i32 %21, %23
%25 = icmp ugt i32 %24, 1
br i1 %25, label %26, label %31
26: ; preds = %4
%27 = load i32, i32* %10
%28 = load i32*, i32** %8
%29 = load i32, i32* %28
%30 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %27, i32 %29)
br label %31
31: ; preds = %26, %4
%32 = load i32, i32* %10
%33 = load i32*, i32** %8
%34 = load i32, i32* %33
%35 = icmp ult i32 %32, %34
br i1 %35, label %36, label %37
36: ; preds = %31
br label %37
37: ; preds = %36, %31
%38 = load i32, i32* %10
%39 = load i32*, i32** %8
store i32 %38, i32* %39
%40 = load i8*, i8** %5
%41 = getelementptr inbounds i8, i8* %40, i64 12
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = icmp eq i32 %43, 255
br i1 %44, label %45, label %57
45: ; preds = %37
%46 = load i8*, i8** %7
%47 = getelementptr inbounds i8, i8* %46, i64 0
%48 = load i8*, i8** %5
%49 = getelementptr inbounds i8, i8* %48, i64 13
%50 = load i32, i32* %6
%51 = sub nsw i32 %50, 13
%52 = call i32 @memcpy(i8* %47, i8* %49, i32 %51)
%53 = load i32, i32* %6
%54 = sub nsw i32 %53, 13
%55 = load i32, i32* %9
%56 = add nsw i32 %55, %54
store i32 %56, i32* %9
br label %69
57: ; preds = %37
%58 = load i8*, i8** %7
%59 = getelementptr inbounds i8, i8* %58, i64 0
%60 = load i8*, i8** %5
%61 = getelementptr inbounds i8, i8* %60, i64 12
%62 = load i32, i32* %6
%63 = sub nsw i32 %62, 12
%64 = call i32 @memcpy(i8* %59, i8* %61, i32 %63)
%65 = load i32, i32* %6
%66 = sub nsw i32 %65, 12
%67 = load i32, i32* %9
%68 = add nsw i32 %67, %66
store i32 %68, i32* %9
br label %69
69: ; preds = %57, %45
%70 = load i32, i32* %9
ret i32 %70
}

LLVM IR (-O2):
@.str = [27 x i8] c"lose nPkt = %u, last = %u\0A\00"
define i32 @CmmbRtpToDRA(i8* %0, i32 %1, i8* %2, i32* nocapture %3) {
%5 = getelementptr inbounds i8, i8* %0, i64 2
%6 = load i8, i8* %5
%7 = zext i8 %6 to i32
%8 = shl nuw nsw i32 %7, 8
%9 = getelementptr inbounds i8, i8* %0, i64 3
%10 = load i8, i8* %9
%11 = zext i8 %10 to i32
%12 = or i32 %8, %11
%13 = load i32, i32* %3
%14 = sub i32 %12, %13
%15 = icmp ugt i32 %14, 1
br i1 %15, label %16, label %18
16: ; preds = %4
%17 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %13)
br label %18
18: ; preds = %16, %4
store i32 %12, i32* %3
%19 = getelementptr inbounds i8, i8* %0, i64 12
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, -1
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = getelementptr inbounds i8, i8* %0, i64 13
%24 = add nsw i32 %1, -13
%25 = tail call i32 @memcpy(i8* %2, i8* %23, i32 %24)
br label %29
26: ; preds = %18
%27 = add nsw i32 %1, -12
%28 = tail call i32 @memcpy(i8* %2, i8* %19, i32 %27)
br label %29
29: ; preds = %26, %22
%30 = phi i32 [ %24, %22 ], [ %27, %26 ]
ret i32 %30
}