#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*/ Parser_DisplayTagInfo(unsigned int, unsigned char);
int /*<<< orphan*/ Parser_TsPacketLog(unsigned int, char *, ...);
int x6E_Tag_DescriptorParser(unsigned int type, unsigned char *buff) {
  unsigned int i = 0;
  unsigned char reference_type = 0;
  unsigned char offset = 0;
  if (NULL == buff) {
    return -1;
  }
  Parser_DisplayTagInfo(type, buff[0]);
  Parser_TsPacketLog(type, "Descriptor_length = 0x%x\n", buff[1]);
  Parser_TsPacketLog(type, "announcement_support_indicator = 0x%x\n",
                     ((buff[2] & 0xFF) << 8) | (buff[3] & 0xFF));
  for (i = 2; i < buff[1]; i += offset) {
    Parser_TsPacketLog(type, "announcement_type = 0x%x\n", buff[4] & 0xF0);
    reference_type = buff[4] & 0x07;
    Parser_TsPacketLog(type, "reference_type = 0x%x\n", reference_type);
    if ((0x01 == reference_type) || (0x02 == reference_type) ||
        (0x03 == reference_type)) {
      Parser_TsPacketLog(type, "original_network_id = 0x%x\n",
                         ((buff[5] & 0xFF) << 8) | (buff[6] & 0xFF));
      Parser_TsPacketLog(type, "transport_stream_id = 0x%x\n",
                         ((buff[7] & 0xFF) << 8) | (buff[8] & 0xFF));
      Parser_TsPacketLog(type, "service_id = 0x%x\n",
                         ((buff[9] & 0xFF) << 8) | (buff[10] & 0xFF));
      Parser_TsPacketLog(type, "component_tag = 0x%x\n", buff[11]);
    } else {
    }
  }
  Parser_TsPacketLog(type, "******END******\n");
  return buff[1];
}


x86 assembly (clang, -O0):
<x6E_Tag_DescriptorParser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movb   $0x0,-0x15(%rbp)
movb   $0x0,-0x16(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    1156 <x6E_Tag_DescriptorParser+0x36>
movl   $0xffffffff,-0x4(%rbp)
jmp    1324 <x6E_Tag_DescriptorParser+0x204>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
movzbl (%rax),%esi
call   1040 <Parser_DisplayTagInfo@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
movzbl 0x1(%rax),%edx
lea    0xe89(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
movzbl 0x2(%rax),%edx
and    $0xff,%edx
shl    $0x8,%edx
mov    -0x10(%rbp),%rax
movzbl 0x3(%rax),%eax
and    $0xff,%eax
or     %eax,%edx
lea    0xe72(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
movl   $0x2,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
cmp    %ecx,%eax
jae    1308 <x6E_Tag_DescriptorParser+0x1e8>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
movzbl 0x4(%rax),%edx
and    $0xf0,%edx
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x10(%rbp),%rax
movzbl 0x4(%rax),%eax
and    $0x7,%eax
mov    %al,-0x15(%rbp)
mov    -0x8(%rbp),%edi
movzbl -0x15(%rbp),%edx
lea    0xe57(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
movzbl -0x15(%rbp),%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
je     123e <x6E_Tag_DescriptorParser+0x11e>
movzbl -0x15(%rbp),%ecx
mov    $0x2,%eax
cmp    %ecx,%eax
je     123e <x6E_Tag_DescriptorParser+0x11e>
movzbl -0x15(%rbp),%ecx
mov    $0x3,%eax
cmp    %ecx,%eax
jne    12ef <x6E_Tag_DescriptorParser+0x1cf>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
movzbl 0x5(%rax),%edx
and    $0xff,%edx
shl    $0x8,%edx
mov    -0x10(%rbp),%rax
movzbl 0x6(%rax),%eax
and    $0xff,%eax
or     %eax,%edx
lea    0xe0a(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
movzbl 0x7(%rax),%edx
and    $0xff,%edx
shl    $0x8,%edx
mov    -0x10(%rbp),%rax
movzbl 0x8(%rax),%eax
and    $0xff,%eax
or     %eax,%edx
lea    0xdf5(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
movzbl 0x9(%rax),%edx
and    $0xff,%edx
shl    $0x8,%edx
mov    -0x10(%rbp),%rax
movzbl 0xa(%rax),%eax
and    $0xff,%eax
or     %eax,%edx
lea    0xde0(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
movzbl 0xb(%rax),%edx
lea    0xdda(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
jmp    12f4 <x6E_Tag_DescriptorParser+0x1d4>
jmp    12f4 <x6E_Tag_DescriptorParser+0x1d4>
jmp    12f9 <x6E_Tag_DescriptorParser+0x1d9>
movzbl -0x16(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11b6 <x6E_Tag_DescriptorParser+0x96>
mov    -0x8(%rbp),%edi
lea    0xdc1(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x10(%rbp),%rax
movzbl 0x1(%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<x6E_Tag_DescriptorParser>:
test   %rsi,%rsi
je     1251 <x6E_Tag_DescriptorParser+0x131>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
movzbl (%rsi),%esi
call   1040 <Parser_DisplayTagInfo@plt>
movzbl 0x1(%rbx),%edx
lea    0xeb4(%rip),%rsi
mov    %ebp,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
movzwl 0x2(%rbx),%edx
shl    $0x10,%edx
bswap  %edx
lea    0xeb5(%rip),%rsi
mov    %ebp,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
cmpb   $0x3,0x1(%rbx)
jb     122e <x6E_Tag_DescriptorParser+0x10e>
lea    0xec2(%rip),%r14
lea    0xed5(%rip),%r15
lea    0xf30(%rip),%r13
jmp    119a <x6E_Tag_DescriptorParser+0x7a>
nop
cmpb   $0x2,0x1(%rbx)
jbe    122e <x6E_Tag_DescriptorParser+0x10e>
movzbl 0x4(%rbx),%edx
and    $0xfffffff0,%edx
mov    %ebp,%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
movzbl 0x4(%rbx),%r12d
and    $0x7,%r12d
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
lea    -0x1(%r12),%eax
cmp    $0x2,%al
ja     1190 <x6E_Tag_DescriptorParser+0x70>
movzwl 0x5(%rbx),%edx
shl    $0x10,%edx
bswap  %edx
mov    %ebp,%edi
lea    0xe92(%rip),%rsi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
movzwl 0x7(%rbx),%edx
shl    $0x10,%edx
bswap  %edx
mov    %ebp,%edi
lea    0xe95(%rip),%rsi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
movzwl 0x9(%rbx),%edx
shl    $0x10,%edx
bswap  %edx
mov    %ebp,%edi
lea    0xe98(%rip),%rsi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
movzbl 0xb(%rbx),%edx
mov    %ebp,%edi
mov    %r13,%rsi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
jmp    1190 <x6E_Tag_DescriptorParser+0x70>
lea    0xe9e(%rip),%rsi
mov    %ebp,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
movzbl 0x1(%rbx),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Descriptor_length = 0x%x\0A\00"
@.str.1 = [39 x i8] c"announcement_support_indicator = 0x%x\0A\00"
@.str.2 = [26 x i8] c"announcement_type = 0x%x\0A\00"
@.str.3 = [23 x i8] c"reference_type = 0x%x\0A\00"
@.str.4 = [28 x i8] c"original_network_id = 0x%x\0A\00"
@.str.5 = [28 x i8] c"transport_stream_id = 0x%x\0A\00"
@.str.6 = [19 x i8] c"service_id = 0x%x\0A\00"
@.str.7 = [22 x i8] c"component_tag = 0x%x\0A\00"
@.str.8 = [17 x i8] c"******END******\0A\00"
define i32 @x6E_Tag_DescriptorParser(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8
%8 = alloca i8
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 0, i32* %6
store i8 0, i8* %7
store i8 0, i8* %8
%9 = load i8*, i8** %5
%10 = icmp eq i8* null, %9
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 -1, i32* %3
br label %137
12: ; preds = %2
%13 = load i32, i32* %4
%14 = load i8*, i8** %5
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = call i32 @Parser_DisplayTagInfo(i32 %13, i8 zeroext %16)
%18 = load i32, i32* %4
%19 = load i8*, i8** %5
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %18, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %4
%25 = load i8*, i8** %5
%26 = getelementptr inbounds i8, i8* %25, i64 2
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = and i32 %28, 255
%30 = shl i32 %29, 8
%31 = load i8*, i8** %5
%32 = getelementptr inbounds i8, i8* %31, i64 3
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = and i32 %34, 255
%36 = or i32 %30, %35
%37 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %24, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %36)
store i32 2, i32* %6
br label %38
38: ; preds = %125, %12
%39 = load i32, i32* %6
%40 = load i8*, i8** %5
%41 = getelementptr inbounds i8, i8* %40, i64 1
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = icmp ult i32 %39, %43
br i1 %44, label %45, label %130
45: ; preds = %38
%46 = load i32, i32* %4
%47 = load i8*, i8** %5
%48 = getelementptr inbounds i8, i8* %47, i64 4
%49 = load i8, i8* %48
%50 = zext i8 %49 to i32
%51 = and i32 %50, 240
%52 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %46, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %51)
%53 = load i8*, i8** %5
%54 = getelementptr inbounds i8, i8* %53, i64 4
%55 = load i8, i8* %54
%56 = zext i8 %55 to i32
%57 = and i32 %56, 7
%58 = trunc i32 %57 to i8
store i8 %58, i8* %7
%59 = load i32, i32* %4
%60 = load i8, i8* %7
%61 = zext i8 %60 to i32
%62 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %59, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %61)
%63 = load i8, i8* %7
%64 = zext i8 %63 to i32
%65 = icmp eq i32 1, %64
br i1 %65, label %74, label %66
66: ; preds = %45
%67 = load i8, i8* %7
%68 = zext i8 %67 to i32
%69 = icmp eq i32 2, %68
br i1 %69, label %74, label %70
70: ; preds = %66
%71 = load i8, i8* %7
%72 = zext i8 %71 to i32
%73 = icmp eq i32 3, %72
br i1 %73, label %74, label %123
74: ; preds = %70, %66, %45
%75 = load i32, i32* %4
%76 = load i8*, i8** %5
%77 = getelementptr inbounds i8, i8* %76, i64 5
%78 = load i8, i8* %77
%79 = zext i8 %78 to i32
%80 = and i32 %79, 255
%81 = shl i32 %80, 8
%82 = load i8*, i8** %5
%83 = getelementptr inbounds i8, i8* %82, i64 6
%84 = load i8, i8* %83
%85 = zext i8 %84 to i32
%86 = and i32 %85, 255
%87 = or i32 %81, %86
%88 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %75, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %87)
%89 = load i32, i32* %4
%90 = load i8*, i8** %5
%91 = getelementptr inbounds i8, i8* %90, i64 7
%92 = load i8, i8* %91
%93 = zext i8 %92 to i32
%94 = and i32 %93, 255
%95 = shl i32 %94, 8
%96 = load i8*, i8** %5
%97 = getelementptr inbounds i8, i8* %96, i64 8
%98 = load i8, i8* %97
%99 = zext i8 %98 to i32
%100 = and i32 %99, 255
%101 = or i32 %95, %100
%102 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %89, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %101)
%103 = load i32, i32* %4
%104 = load i8*, i8** %5
%105 = getelementptr inbounds i8, i8* %104, i64 9
%106 = load i8, i8* %105
%107 = zext i8 %106 to i32
%108 = and i32 %107, 255
%109 = shl i32 %108, 8
%110 = load i8*, i8** %5
%111 = getelementptr inbounds i8, i8* %110, i64 10
%112 = load i8, i8* %111
%113 = zext i8 %112 to i32
%114 = and i32 %113, 255
%115 = or i32 %109, %114
%116 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %103, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %115)
%117 = load i32, i32* %4
%118 = load i8*, i8** %5
%119 = getelementptr inbounds i8, i8* %118, i64 11
%120 = load i8, i8* %119
%121 = zext i8 %120 to i32
%122 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %117, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %121)
br label %124
123: ; preds = %70
br label %124
124: ; preds = %123, %74
br label %125
125: ; preds = %124
%126 = load i8, i8* %8
%127 = zext i8 %126 to i32
%128 = load i32, i32* %6
%129 = add i32 %128, %127
store i32 %129, i32* %6
br label %38
130: ; preds = %38
%131 = load i32, i32* %4
%132 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %131, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%133 = load i8*, i8** %5
%134 = getelementptr inbounds i8, i8* %133, i64 1
%135 = load i8, i8* %134
%136 = zext i8 %135 to i32
store i32 %136, i32* %3
br label %137
137: ; preds = %130, %11
%138 = load i32, i32* %3
ret i32 %138
}

LLVM IR (-O2):
@.str = [26 x i8] c"Descriptor_length = 0x%x\0A\00"
@.str.1 = [39 x i8] c"announcement_support_indicator = 0x%x\0A\00"
@.str.2 = [26 x i8] c"announcement_type = 0x%x\0A\00"
@.str.3 = [23 x i8] c"reference_type = 0x%x\0A\00"
@.str.4 = [28 x i8] c"original_network_id = 0x%x\0A\00"
@.str.5 = [28 x i8] c"transport_stream_id = 0x%x\0A\00"
@.str.6 = [19 x i8] c"service_id = 0x%x\0A\00"
@.str.7 = [22 x i8] c"component_tag = 0x%x\0A\00"
@.str.8 = [17 x i8] c"******END******\0A\00"
define i32 @x6E_Tag_DescriptorParser(i32 %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %74, label %4
4: ; preds = %2
%5 = load i8, i8* %1
%6 = tail call i32 @Parser_DisplayTagInfo(i32 %0, i8 zeroext %5)
%7 = getelementptr inbounds i8, i8* %1, i64 1
%8 = load i8, i8* %7
%9 = zext i8 %8 to i32
%10 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds i8, i8* %1, i64 2
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = shl nuw nsw i32 %13, 8
%15 = getelementptr inbounds i8, i8* %1, i64 3
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = or i32 %14, %17
%19 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = load i8, i8* %7
%21 = icmp ugt i8 %20, 2
br i1 %21, label %22, label %70
22: ; preds = %4
%23 = getelementptr inbounds i8, i8* %1, i64 4
%24 = getelementptr inbounds i8, i8* %1, i64 5
%25 = getelementptr inbounds i8, i8* %1, i64 6
%26 = getelementptr inbounds i8, i8* %1, i64 7
%27 = getelementptr inbounds i8, i8* %1, i64 8
%28 = getelementptr inbounds i8, i8* %1, i64 9
%29 = getelementptr inbounds i8, i8* %1, i64 10
%30 = getelementptr inbounds i8, i8* %1, i64 11
br label %31
31: ; preds = %22, %67
%32 = load i8, i8* %23
%33 = and i8 %32, -16
%34 = zext i8 %33 to i32
%35 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%36 = load i8, i8* %23
%37 = and i8 %36, 7
%38 = zext i8 %37 to i32
%39 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %38)
%40 = add nsw i8 %37, -1
%41 = icmp ult i8 %40, 3
br i1 %41, label %42, label %67
42: ; preds = %31
%43 = load i8, i8* %24
%44 = zext i8 %43 to i32
%45 = shl nuw nsw i32 %44, 8
%46 = load i8, i8* %25
%47 = zext i8 %46 to i32
%48 = or i32 %45, %47
%49 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %48)
%50 = load i8, i8* %26
%51 = zext i8 %50 to i32
%52 = shl nuw nsw i32 %51, 8
%53 = load i8, i8* %27
%54 = zext i8 %53 to i32
%55 = or i32 %52, %54
%56 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %55)
%57 = load i8, i8* %28
%58 = zext i8 %57 to i32
%59 = shl nuw nsw i32 %58, 8
%60 = load i8, i8* %29
%61 = zext i8 %60 to i32
%62 = or i32 %59, %61
%63 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %62)
%64 = load i8, i8* %30
%65 = zext i8 %64 to i32
%66 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %65)
br label %67
67: ; preds = %42, %31
%68 = load i8, i8* %7
%69 = icmp ugt i8 %68, 2
br i1 %69, label %31, label %70
70: ; preds = %67, %4
%71 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%72 = load i8, i8* %7
%73 = zext i8 %72 to i32
br label %74
74: ; preds = %2, %70
%75 = phi i32 [ %73, %70 ], [ -1, %2 ]
ret i32 %75
}