#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 x50_Tag_DescriptorParser(unsigned int type, unsigned char *buff) {
  unsigned int i = 0;
  if (NULL == buff) {
    return -1;
  }
  Parser_DisplayTagInfo(type, buff[0]);
  Parser_TsPacketLog(type, "Descriptor_length = 0x%x\n", buff[1]);
  Parser_TsPacketLog(type, "stream_content_ext = 0x%x\n",
                     (buff[2] & 0xF0) >> 4);
  Parser_TsPacketLog(type, "stream_content = 0x%x\n", buff[2] & 0x0F);
  Parser_TsPacketLog(type, "component_type = 0x%x\n", buff[3]);
  Parser_TsPacketLog(type, "component_tag = 0x%x\n", buff[4]);
  Parser_TsPacketLog(type, "ISO_639_language_code = 0x%x : %c%c%c\n",
                     (buff[5] << 16) | (buff[6] << 8) | (buff[7] & 0xFF),
                     buff[5], buff[6], buff[7]);
  if (buff[1] > 6) {
    Parser_TsPacketLog(type, "Component descriptor text : ");
    for (i = 6; i < buff[1]; i += 1) {
      Parser_TsPacketLog(type, "%c", buff[i + 2]);
    }
    Parser_TsPacketLog(type, "\n");
  }
  Parser_TsPacketLog(type, "******END******\n");
  return buff[1];
}


x86 assembly (clang, -O0):
<x50_Tag_DescriptorParser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    114e <x50_Tag_DescriptorParser+0x2e>
movl   $0xffffffff,-0x4(%rbp)
jmp    12d0 <x50_Tag_DescriptorParser+0x1b0>
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    0xe91(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
movzbl 0x2(%rax),%edx
and    $0xf0,%edx
sar    $0x4,%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    $0xf,%edx
lea    0xe88(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
movzbl 0x3(%rax),%edx
lea    0xe86(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
movzbl 0x4(%rax),%edx
lea    0xe84(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
movzbl 0x5(%rax),%edx
shl    $0x10,%edx
mov    -0x10(%rbp),%rax
movzbl 0x6(%rax),%eax
shl    $0x8,%eax
or     %eax,%edx
mov    -0x10(%rbp),%rax
movzbl 0x7(%rax),%eax
and    $0xff,%eax
or     %eax,%edx
mov    -0x10(%rbp),%rax
movzbl 0x5(%rax),%ecx
mov    -0x10(%rbp),%rax
movzbl 0x6(%rax),%r8d
mov    -0x10(%rbp),%rax
movzbl 0x7(%rax),%r9d
lea    0xe48(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x10(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0x6,%eax
jle    12b4 <x50_Tag_DescriptorParser+0x194>
mov    -0x8(%rbp),%edi
lea    0xe4d(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
movl   $0x6,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
cmp    %ecx,%eax
jae    12a3 <x50_Tag_DescriptorParser+0x183>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x2,%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%edx
lea    0xe2f(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1261 <x50_Tag_DescriptorParser+0x141>
mov    -0x8(%rbp),%edi
lea    0xe22(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x8(%rbp),%edi
lea    0xe02(%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):
<x50_Tag_DescriptorParser>:
test   %rsi,%rsi
je     1260 <x50_Tag_DescriptorParser+0x140>
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%r15d
movzbl (%rsi),%esi
call   1040 <Parser_DisplayTagInfo@plt>
movzbl 0x1(%rbx),%edx
lea    0xeb7(%rip),%rsi
mov    %r15d,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
movzbl 0x2(%rbx),%edx
shr    $0x4,%edx
lea    0xeb9(%rip),%rsi
mov    %r15d,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
movzbl 0x2(%rbx),%edx
and    $0xf,%edx
lea    0xebc(%rip),%rsi
mov    %r15d,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
movzbl 0x3(%rbx),%edx
lea    0xebe(%rip),%rsi
mov    %r15d,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
movzbl 0x4(%rbx),%edx
lea    0xec0(%rip),%rsi
mov    %r15d,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
movzbl 0x5(%rbx),%ecx
mov    %ecx,%eax
shl    $0x10,%eax
movzbl 0x6(%rbx),%r8d
mov    %r8d,%edx
shl    $0x8,%edx
or     %eax,%edx
movzbl 0x7(%rbx),%r9d
or     %r9d,%edx
lea    0xea7(%rip),%rsi
mov    %r15d,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
cmpb   $0x7,0x1(%rbx)
jb     1240 <x50_Tag_DescriptorParser+0x120>
lea    0xeb7(%rip),%rsi
mov    %r15d,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
cmpb   $0x7,0x1(%rbx)
jb     122f <x50_Tag_DescriptorParser+0x10f>
mov    $0x6,%ebp
lea    0xeb8(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
movzbl 0x2(%rbx,%rbp,1),%edx
mov    %r15d,%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
add    $0x1,%rbp
movzbl 0x1(%rbx),%eax
cmp    %rax,%rbp
jb     1210 <x50_Tag_DescriptorParser+0xf0>
lea    0xe99(%rip),%rsi
mov    %r15d,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
lea    0xe79(%rip),%rsi
mov    %r15d,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
movzbl 0x1(%rbx),%eax
add    $0x8,%rsp
pop    %rbx
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 = [27 x i8] c"stream_content_ext = 0x%x\0A\00"
@.str.2 = [23 x i8] c"stream_content = 0x%x\0A\00"
@.str.3 = [23 x i8] c"component_type = 0x%x\0A\00"
@.str.4 = [22 x i8] c"component_tag = 0x%x\0A\00"
@.str.5 = [39 x i8] c"ISO_639_language_code = 0x%x : %c%c%c\0A\00"
@.str.6 = [29 x i8] c"Component descriptor text : \00"
@.str.7 = [3 x i8] c"%c\00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [17 x i8] c"******END******\0A\00"
define i32 @x50_Tag_DescriptorParser(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 0, i32* %6
%7 = load i8*, i8** %5
%8 = icmp eq i8* null, %7
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 -1, i32* %3
br label %118
10: ; preds = %2
%11 = load i32, i32* %4
%12 = load i8*, i8** %5
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = call i32 @Parser_DisplayTagInfo(i32 %11, i8 zeroext %14)
%16 = load i32, i32* %4
%17 = load i8*, i8** %5
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %16, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %4
%23 = load i8*, i8** %5
%24 = getelementptr inbounds i8, i8* %23, i64 2
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = and i32 %26, 240
%28 = ashr i32 %27, 4
%29 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %22, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %4
%31 = load i8*, i8** %5
%32 = getelementptr inbounds i8, i8* %31, i64 2
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = and i32 %34, 15
%36 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %30, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %4
%38 = load i8*, i8** %5
%39 = getelementptr inbounds i8, i8* %38, i64 3
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
%42 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %37, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %41)
%43 = load i32, i32* %4
%44 = load i8*, i8** %5
%45 = getelementptr inbounds i8, i8* %44, i64 4
%46 = load i8, i8* %45
%47 = zext i8 %46 to i32
%48 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %43, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %47)
%49 = load i32, i32* %4
%50 = load i8*, i8** %5
%51 = getelementptr inbounds i8, i8* %50, i64 5
%52 = load i8, i8* %51
%53 = zext i8 %52 to i32
%54 = shl i32 %53, 16
%55 = load i8*, i8** %5
%56 = getelementptr inbounds i8, i8* %55, i64 6
%57 = load i8, i8* %56
%58 = zext i8 %57 to i32
%59 = shl i32 %58, 8
%60 = or i32 %54, %59
%61 = load i8*, i8** %5
%62 = getelementptr inbounds i8, i8* %61, i64 7
%63 = load i8, i8* %62
%64 = zext i8 %63 to i32
%65 = and i32 %64, 255
%66 = or i32 %60, %65
%67 = load i8*, i8** %5
%68 = getelementptr inbounds i8, i8* %67, i64 5
%69 = load i8, i8* %68
%70 = zext i8 %69 to i32
%71 = load i8*, i8** %5
%72 = getelementptr inbounds i8, i8* %71, i64 6
%73 = load i8, i8* %72
%74 = zext i8 %73 to i32
%75 = load i8*, i8** %5
%76 = getelementptr inbounds i8, i8* %75, i64 7
%77 = load i8, i8* %76
%78 = zext i8 %77 to i32
%79 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %49, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i32 %66, i32 %70, i32 %74, i32 %78)
%80 = load i8*, i8** %5
%81 = getelementptr inbounds i8, i8* %80, i64 1
%82 = load i8, i8* %81
%83 = zext i8 %82 to i32
%84 = icmp sgt i32 %83, 6
br i1 %84, label %85, label %111
85: ; preds = %10
%86 = load i32, i32* %4
%87 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %86, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
store i32 6, i32* %6
br label %88
88: ; preds = %105, %85
%89 = load i32, i32* %6
%90 = load i8*, i8** %5
%91 = getelementptr inbounds i8, i8* %90, i64 1
%92 = load i8, i8* %91
%93 = zext i8 %92 to i32
%94 = icmp ult i32 %89, %93
br i1 %94, label %95, label %108
95: ; preds = %88
%96 = load i32, i32* %4
%97 = load i8*, i8** %5
%98 = load i32, i32* %6
%99 = add i32 %98, 2
%100 = zext i32 %99 to i64
%101 = getelementptr inbounds i8, i8* %97, i64 %100
%102 = load i8, i8* %101
%103 = zext i8 %102 to i32
%104 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %96, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 %103)
br label %105
105: ; preds = %95
%106 = load i32, i32* %6
%107 = add i32 %106, 1
store i32 %107, i32* %6
br label %88
108: ; preds = %88
%109 = load i32, i32* %4
%110 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %109, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %111
111: ; preds = %108, %10
%112 = load i32, i32* %4
%113 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %112, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
%114 = load i8*, i8** %5
%115 = getelementptr inbounds i8, i8* %114, i64 1
%116 = load i8, i8* %115
%117 = zext i8 %116 to i32
store i32 %117, i32* %3
br label %118
118: ; preds = %111, %9
%119 = load i32, i32* %3
ret i32 %119
}

LLVM IR (-O2):
@.str = [26 x i8] c"Descriptor_length = 0x%x\0A\00"
@.str.1 = [27 x i8] c"stream_content_ext = 0x%x\0A\00"
@.str.2 = [23 x i8] c"stream_content = 0x%x\0A\00"
@.str.3 = [23 x i8] c"component_type = 0x%x\0A\00"
@.str.4 = [22 x i8] c"component_tag = 0x%x\0A\00"
@.str.5 = [39 x i8] c"ISO_639_language_code = 0x%x : %c%c%c\0A\00"
@.str.6 = [29 x i8] c"Component descriptor text : \00"
@.str.7 = [3 x i8] c"%c\00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [17 x i8] c"******END******\0A\00"
define i32 @x50_Tag_DescriptorParser(i32 %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %65, 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 = lshr i8 %12, 4
%14 = zext i8 %13 to i32
%15 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load i8, i8* %11
%17 = and i8 %16, 15
%18 = zext i8 %17 to i32
%19 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds i8, i8* %1, i64 3
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = 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 %22)
%24 = getelementptr inbounds i8, i8* %1, i64 4
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds i8, i8* %1, i64 5
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = shl nuw nsw i32 %30, 16
%32 = getelementptr inbounds i8, i8* %1, i64 6
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = shl nuw nsw i32 %34, 8
%36 = or i32 %35, %31
%37 = getelementptr inbounds i8, i8* %1, i64 7
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = or i32 %36, %39
%41 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i32 %40, i32 %30, i32 %34, i32 %39)
%42 = load i8, i8* %7
%43 = icmp ugt i8 %42, 6
br i1 %43, label %44, label %61
44: ; preds = %4
%45 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
%46 = load i8, i8* %7
%47 = icmp ugt i8 %46, 6
br i1 %47, label %48, label %59
48: ; preds = %44, %48
%49 = phi i64 [ %55, %48 ], [ 6, %44 ]
%50 = add nuw nsw i64 %49, 2
%51 = getelementptr inbounds i8, i8* %1, i64 %50
%52 = load i8, i8* %51
%53 = zext i8 %52 to i32
%54 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 %53)
%55 = add nuw nsw i64 %49, 1
%56 = load i8, i8* %7
%57 = zext i8 %56 to i64
%58 = icmp ult i64 %55, %57
br i1 %58, label %48, label %59
59: ; preds = %48, %44
%60 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %61
61: ; preds = %59, %4
%62 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
%63 = load i8, i8* %7
%64 = zext i8 %63 to i32
br label %65
65: ; preds = %2, %61
%66 = phi i32 [ %64, %61 ], [ -1, %2 ]
ret i32 %66
}