#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 x59_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]);
  for (i = 0; i < buff[1]; i += 8) {
    Parser_TsPacketLog(type, "ISO_639_language_code = 0x%x : %c%c%c\n",
                       ((buff[i + 2] & 0xFF) << 16) |
                           ((buff[i + 3] & 0xFF) << 8) | (buff[i + 4] & 0xFF),
                       buff[i + 2], buff[i + 3], buff[i + 4]);
    Parser_TsPacketLog(type, "subtitling_type = 0x%x\n", buff[i + 5]);
    Parser_TsPacketLog(type, "composition_page_id = 0x%x\n",
                       ((buff[i + 6] & 0xFF) << 8) | (buff[i + 7] & 0xFF));
    Parser_TsPacketLog(type, "ancillary_page_id = 0x%x\n",
                       ((buff[i + 8] & 0xFF) << 8) | (buff[i + 9] & 0xFF));
  }
  Parser_TsPacketLog(type, "******END******\n");
  return buff[1];
}


x86 assembly (clang, -O0):
<x59_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 <x59_Tag_DescriptorParser+0x2e>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ea <x59_Tag_DescriptorParser+0x1ca>
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>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
cmp    %ecx,%eax
jae    12ce <x59_Tag_DescriptorParser+0x1ae>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x2,%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%edx
and    $0xff,%edx
shl    $0x10,%edx
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x3,%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%eax
and    $0xff,%eax
shl    $0x8,%eax
or     %eax,%edx
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x4,%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%eax
and    $0xff,%eax
or     %eax,%edx
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x2,%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%ecx
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%esi
add    $0x3,%esi
mov    %esi,%esi
movzbl (%rax,%rsi,1),%r8d
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%esi
add    $0x4,%esi
mov    %esi,%esi
movzbl (%rax,%rsi,1),%r9d
lea    0xe04(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x5,%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%edx
lea    0xe0a(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x6,%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%edx
and    $0xff,%edx
shl    $0x8,%edx
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x7,%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%eax
and    $0xff,%eax
or     %eax,%edx
lea    0xde1(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x8,%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%edx
and    $0xff,%edx
shl    $0x8,%edx
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x9,%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%eax
and    $0xff,%eax
or     %eax,%edx
lea    0xdbc(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x14(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x14(%rbp)
jmp    117d <x59_Tag_DescriptorParser+0x5d>
mov    -0x8(%rbp),%edi
lea    0xdb7(%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):
<x59_Tag_DescriptorParser>:
test   %rsi,%rsi
je     1222 <x59_Tag_DescriptorParser+0x102>
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>
cmpb   $0x0,0x1(%rbx)
je     11ff <x59_Tag_DescriptorParser+0xdf>
lea    0xedb(%rip),%r15
lea    0xeec(%rip),%r12
lea    0xf01(%rip),%r13
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
movzbl 0x2(%rbx,%r14,1),%ecx
mov    %ecx,%eax
shl    $0x10,%eax
movzbl 0x3(%rbx,%r14,1),%r8d
mov    %r8d,%edx
shl    $0x8,%edx
or     %eax,%edx
movzbl 0x4(%rbx,%r14,1),%r9d
or     %r9d,%edx
mov    %ebp,%edi
lea    0xe6f(%rip),%rsi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
movzbl 0x5(%rbx,%r14,1),%edx
mov    %ebp,%edi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
movzwl 0x6(%rbx,%r14,1),%edx
shl    $0x10,%edx
bswap  %edx
mov    %ebp,%edi
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
movzwl 0x8(%rbx,%r14,1),%edx
add    $0x8,%r14
shl    $0x10,%edx
bswap  %edx
mov    %ebp,%edi
mov    %r13,%rsi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
movzbl 0x1(%rbx),%eax
cmp    %rax,%r14
jb     1180 <x59_Tag_DescriptorParser+0x60>
lea    0xe89(%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"ISO_639_language_code = 0x%x : %c%c%c\0A\00"
@.str.2 = [24 x i8] c"subtitling_type = 0x%x\0A\00"
@.str.3 = [28 x i8] c"composition_page_id = 0x%x\0A\00"
@.str.4 = [26 x i8] c"ancillary_page_id = 0x%x\0A\00"
@.str.5 = [17 x i8] c"******END******\0A\00"
define i32 @x59_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 %140
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)
store i32 0, i32* %6
br label %22
22: ; preds = %130, %10
%23 = load i32, i32* %6
%24 = load i8*, i8** %5
%25 = getelementptr inbounds i8, i8* %24, i64 1
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = icmp ult i32 %23, %27
br i1 %28, label %29, label %133
29: ; preds = %22
%30 = load i32, i32* %4
%31 = load i8*, i8** %5
%32 = load i32, i32* %6
%33 = add i32 %32, 2
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %31, i64 %34
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = and i32 %37, 255
%39 = shl i32 %38, 16
%40 = load i8*, i8** %5
%41 = load i32, i32* %6
%42 = add i32 %41, 3
%43 = zext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %40, i64 %43
%45 = load i8, i8* %44
%46 = zext i8 %45 to i32
%47 = and i32 %46, 255
%48 = shl i32 %47, 8
%49 = or i32 %39, %48
%50 = load i8*, i8** %5
%51 = load i32, i32* %6
%52 = add i32 %51, 4
%53 = zext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %50, i64 %53
%55 = load i8, i8* %54
%56 = zext i8 %55 to i32
%57 = and i32 %56, 255
%58 = or i32 %49, %57
%59 = load i8*, i8** %5
%60 = load i32, i32* %6
%61 = add i32 %60, 2
%62 = zext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %59, i64 %62
%64 = load i8, i8* %63
%65 = zext i8 %64 to i32
%66 = load i8*, i8** %5
%67 = load i32, i32* %6
%68 = add i32 %67, 3
%69 = zext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %66, i64 %69
%71 = load i8, i8* %70
%72 = zext i8 %71 to i32
%73 = load i8*, i8** %5
%74 = load i32, i32* %6
%75 = add i32 %74, 4
%76 = zext i32 %75 to i64
%77 = getelementptr inbounds i8, i8* %73, i64 %76
%78 = load i8, i8* %77
%79 = zext i8 %78 to i32
%80 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %30, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %58, i32 %65, i32 %72, i32 %79)
%81 = load i32, i32* %4
%82 = load i8*, i8** %5
%83 = load i32, i32* %6
%84 = add i32 %83, 5
%85 = zext i32 %84 to i64
%86 = getelementptr inbounds i8, i8* %82, i64 %85
%87 = load i8, i8* %86
%88 = zext i8 %87 to i32
%89 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %81, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %88)
%90 = load i32, i32* %4
%91 = load i8*, i8** %5
%92 = load i32, i32* %6
%93 = add i32 %92, 6
%94 = zext i32 %93 to i64
%95 = getelementptr inbounds i8, i8* %91, i64 %94
%96 = load i8, i8* %95
%97 = zext i8 %96 to i32
%98 = and i32 %97, 255
%99 = shl i32 %98, 8
%100 = load i8*, i8** %5
%101 = load i32, i32* %6
%102 = add i32 %101, 7
%103 = zext i32 %102 to i64
%104 = getelementptr inbounds i8, i8* %100, i64 %103
%105 = load i8, i8* %104
%106 = zext i8 %105 to i32
%107 = and i32 %106, 255
%108 = or i32 %99, %107
%109 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %90, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %108)
%110 = load i32, i32* %4
%111 = load i8*, i8** %5
%112 = load i32, i32* %6
%113 = add i32 %112, 8
%114 = zext i32 %113 to i64
%115 = getelementptr inbounds i8, i8* %111, i64 %114
%116 = load i8, i8* %115
%117 = zext i8 %116 to i32
%118 = and i32 %117, 255
%119 = shl i32 %118, 8
%120 = load i8*, i8** %5
%121 = load i32, i32* %6
%122 = add i32 %121, 9
%123 = zext i32 %122 to i64
%124 = getelementptr inbounds i8, i8* %120, i64 %123
%125 = load i8, i8* %124
%126 = zext i8 %125 to i32
%127 = and i32 %126, 255
%128 = or i32 %119, %127
%129 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %110, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %128)
br label %130
130: ; preds = %29
%131 = load i32, i32* %6
%132 = add i32 %131, 8
store i32 %132, i32* %6
br label %22
133: ; preds = %22
%134 = load i32, i32* %4
%135 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %134, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%136 = load i8*, i8** %5
%137 = getelementptr inbounds i8, i8* %136, i64 1
%138 = load i8, i8* %137
%139 = zext i8 %138 to i32
store i32 %139, i32* %3
br label %140
140: ; preds = %133, %9
%141 = load i32, i32* %3
ret i32 %141
}

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