#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 */
scalar_t__ SearchMPEG2StartCode(unsigned char const *, int, int,
                                unsigned char const **);
unsigned int SearFrameType(char *pData, int Size) {
  const unsigned char *ptr;
  if (SearchMPEG2StartCode((const unsigned char *)pData, Size, 0x00000100,
                           &ptr)) {
    unsigned char picture_coding_type = ((*(ptr + 5) & 0x38) >> 3);
    if (picture_coding_type == 1 || picture_coding_type == 2 ||
        picture_coding_type == 3)
      return picture_coding_type;
  }
  return 0;
}


x86 assembly (clang, -O0):
<SearFrameType>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    $0x100,%edx
lea    -0x20(%rbp),%rcx
call   1030 <SearchMPEG2StartCode@plt>
cmp    $0x0,%rax
je     1187 <SearFrameType+0x77>
mov    -0x20(%rbp),%rax
movzbl 0x5(%rax),%eax
and    $0x38,%eax
sar    $0x3,%eax
mov    %al,-0x21(%rbp)
movzbl -0x21(%rbp),%eax
cmp    $0x1,%eax
je     1176 <SearFrameType+0x66>
movzbl -0x21(%rbp),%eax
cmp    $0x2,%eax
je     1176 <SearFrameType+0x66>
movzbl -0x21(%rbp),%eax
cmp    $0x3,%eax
jne    1182 <SearFrameType+0x72>
movzbl -0x21(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    118e <SearFrameType+0x7e>
jmp    1187 <SearFrameType+0x77>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SearFrameType>:
push   %rax
mov    %rsp,%rcx
mov    $0x100,%edx
call   1030 <SearchMPEG2StartCode@plt>
test   %rax,%rax
je     1139 <SearFrameType+0x29>
mov    (%rsp),%rax
movzbl 0x5(%rax),%eax
shr    $0x3,%eax
and    $0x7,%eax
lea    -0x1(%rax),%ecx
cmp    $0x3,%cl
jb     113b <SearFrameType+0x2b>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @SearFrameType(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8
store i8* %0, i8** %4
store i32 %1, i32* %5
%8 = load i8*, i8** %4
%9 = load i32, i32* %5
%10 = call i64 @SearchMPEG2StartCode(i8* %8, i32 %9, i32 256, i8** %6)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %35
12: ; preds = %2
%13 = load i8*, i8** %6
%14 = getelementptr inbounds i8, i8* %13, i64 5
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = and i32 %16, 56
%18 = ashr i32 %17, 3
%19 = trunc i32 %18 to i8
store i8 %19, i8* %7
%20 = load i8, i8* %7
%21 = zext i8 %20 to i32
%22 = icmp eq i32 %21, 1
br i1 %22, label %31, label %23
23: ; preds = %12
%24 = load i8, i8* %7
%25 = zext i8 %24 to i32
%26 = icmp eq i32 %25, 2
br i1 %26, label %31, label %27
27: ; preds = %23
%28 = load i8, i8* %7
%29 = zext i8 %28 to i32
%30 = icmp eq i32 %29, 3
br i1 %30, label %31, label %34
31: ; preds = %27, %23, %12
%32 = load i8, i8* %7
%33 = zext i8 %32 to i32
store i32 %33, i32* %3
br label %36
34: ; preds = %27
br label %35
35: ; preds = %34, %2
store i32 0, i32* %3
br label %36
36: ; preds = %35, %31
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
define i32 @SearFrameType(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = call i64 @SearchMPEG2StartCode(i8* %0, i32 %1, i32 256, i8** %3)
%6 = icmp eq i64 %5, 0
br i1 %6, label %16, label %7
7: ; preds = %2
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i64 5
%10 = load i8, i8* %9
%11 = lshr i8 %10, 3
%12 = and i8 %11, 7
%13 = zext i8 %12 to i32
%14 = add nsw i8 %12, -1
%15 = icmp ult i8 %14, 3
br i1 %15, label %17, label %16
16: ; preds = %7, %2
br label %17
17: ; preds = %7, %16
%18 = phi i32 [ 0, %16 ], [ %13, %7 ]
ret i32 %18
}