#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 x79_Tag_DescriptorParser(unsigned int type, unsigned char *buff) {
  if (NULL == buff) {
    return -1;
  }
  Parser_DisplayTagInfo(type, buff[0]);
  Parser_TsPacketLog(type, "Descriptor_length = 0x%x\n", buff[1]);
  Parser_TsPacketLog(type, "scrambling_sequence_selector = 0x%x\n",
                     (buff[2] & 0x80) >> 7);
  Parser_TsPacketLog(type, "multiple_input_stream_flag = 0x%x\n",
                     (buff[2] & 0x40) >> 6);
  Parser_TsPacketLog(type, "backwards_compatibility_indicator = 0x%x\n",
                     (buff[2] & 0x20) >> 5);
  if (0x80 == (buff[2] & 0x80)) {
    Parser_TsPacketLog(type, "scrambling_sequence_index = 0x%x\n",
                       ((buff[3] & 0xFF) << 16) | ((buff[4] & 0xFF) << 8) |
                           (buff[5] & 0xFF));
  }
  if (0x40 == (buff[2] & 0x80)) {
    if (0x80 == (buff[2] & 0x80)) {
      Parser_TsPacketLog(type, "input_stream_identifier = 0x%x\n",
                         buff[6] & 0xFF);
    } else {
      Parser_TsPacketLog(type, "input_stream_identifier = 0x%x\n",
                         buff[3] & 0xFF);
    }
  }
  Parser_TsPacketLog(type, "******END******\n");
  return buff[1];
}


x86 assembly (clang, -O0):
<x79_Tag_DescriptorParser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    1147 <x79_Tag_DescriptorParser+0x27>
movl   $0xffffffff,-0x4(%rbp)
jmp    12c7 <x79_Tag_DescriptorParser+0x1a7>
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    0xe98(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
movzbl 0x2(%rax),%edx
and    $0x80,%edx
sar    $0x7,%edx
lea    0xe90(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
movzbl 0x2(%rax),%edx
and    $0x40,%edx
sar    $0x6,%edx
lea    0xe96(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
movzbl 0x2(%rax),%edx
and    $0x20,%edx
sar    $0x5,%edx
lea    0xe9a(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x10(%rbp),%rax
movzbl 0x2(%rax),%ecx
and    $0x80,%ecx
mov    $0x80,%eax
cmp    %ecx,%eax
jne    122d <x79_Tag_DescriptorParser+0x10d>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
movzbl 0x3(%rax),%edx
and    $0xff,%edx
shl    $0x10,%edx
mov    -0x10(%rbp),%rax
movzbl 0x4(%rax),%eax
and    $0xff,%eax
shl    $0x8,%eax
or     %eax,%edx
mov    -0x10(%rbp),%rax
movzbl 0x5(%rax),%eax
and    $0xff,%eax
or     %eax,%edx
lea    0xe66(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x10(%rbp),%rax
movzbl 0x2(%rax),%ecx
and    $0x80,%ecx
mov    $0x40,%eax
cmp    %ecx,%eax
jne    12ab <x79_Tag_DescriptorParser+0x18b>
mov    -0x10(%rbp),%rax
movzbl 0x2(%rax),%ecx
and    $0x80,%ecx
mov    $0x80,%eax
cmp    %ecx,%eax
jne    1287 <x79_Tag_DescriptorParser+0x167>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
movzbl 0x6(%rax),%edx
and    $0xff,%edx
lea    0xe33(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
jmp    12a6 <x79_Tag_DescriptorParser+0x186>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
movzbl 0x3(%rax),%edx
and    $0xff,%edx
lea    0xe0f(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
jmp    12ab <x79_Tag_DescriptorParser+0x18b>
mov    -0x8(%rbp),%edi
lea    0xe19(%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    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<x79_Tag_DescriptorParser>:
test   %rsi,%rsi
je     11df <x79_Tag_DescriptorParser+0xbf>
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
movzbl (%rsi),%esi
call   1040 <Parser_DisplayTagInfo@plt>
movzbl 0x1(%rbx),%edx
lea    0xebc(%rip),%rsi
mov    %ebp,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
movzbl 0x2(%rbx),%edx
shr    $0x7,%edx
lea    0xebf(%rip),%rsi
mov    %ebp,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
movzbl 0x2(%rbx),%edx
shr    $0x6,%edx
and    $0x1,%edx
lea    0xeca(%rip),%rsi
mov    %ebp,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
movzbl 0x2(%rbx),%edx
shr    $0x5,%edx
and    $0x1,%edx
lea    0xed3(%rip),%rsi
mov    %ebp,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
cmpb   $0x0,0x2(%rbx)
jns    11c4 <x79_Tag_DescriptorParser+0xa4>
movzbl 0x3(%rbx),%eax
shl    $0x10,%eax
movzbl 0x4(%rbx),%ecx
shl    $0x8,%ecx
or     %eax,%ecx
movzbl 0x5(%rbx),%edx
or     %ecx,%edx
lea    0xed1(%rip),%rsi
mov    %ebp,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
lea    0xee3(%rip),%rsi
mov    %ebp,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
movzbl 0x1(%rbx),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Descriptor_length = 0x%x\0A\00"
@.str.1 = [37 x i8] c"scrambling_sequence_selector = 0x%x\0A\00"
@.str.2 = [35 x i8] c"multiple_input_stream_flag = 0x%x\0A\00"
@.str.3 = [42 x i8] c"backwards_compatibility_indicator = 0x%x\0A\00"
@.str.4 = [34 x i8] c"scrambling_sequence_index = 0x%x\0A\00"
@.str.5 = [32 x i8] c"input_stream_identifier = 0x%x\0A\00"
@.str.6 = [17 x i8] c"******END******\0A\00"
define i32 @x79_Tag_DescriptorParser(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
%6 = load i8*, i8** %5
%7 = icmp eq i8* null, %6
br i1 %7, label %8, label %9
8: ; preds = %2
store i32 -1, i32* %3
br label %111
9: ; preds = %2
%10 = load i32, i32* %4
%11 = load i8*, i8** %5
%12 = getelementptr inbounds i8, i8* %11, i64 0
%13 = load i8, i8* %12
%14 = call i32 @Parser_DisplayTagInfo(i32 %10, i8 zeroext %13)
%15 = load i32, i32* %4
%16 = load i8*, i8** %5
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %15, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %4
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i64 2
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = and i32 %25, 128
%27 = ashr i32 %26, 7
%28 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %21, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %4
%30 = load i8*, i8** %5
%31 = getelementptr inbounds i8, i8* %30, i64 2
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = and i32 %33, 64
%35 = ashr i32 %34, 6
%36 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %29, i8* getelementptr inbounds ([35 x i8], [35 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 2
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
%42 = and i32 %41, 32
%43 = ashr i32 %42, 5
%44 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %37, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i32 %43)
%45 = load i8*, i8** %5
%46 = getelementptr inbounds i8, i8* %45, i64 2
%47 = load i8, i8* %46
%48 = zext i8 %47 to i32
%49 = and i32 %48, 128
%50 = icmp eq i32 128, %49
br i1 %50, label %51, label %73
51: ; preds = %9
%52 = load i32, i32* %4
%53 = load i8*, i8** %5
%54 = getelementptr inbounds i8, i8* %53, i64 3
%55 = load i8, i8* %54
%56 = zext i8 %55 to i32
%57 = and i32 %56, 255
%58 = shl i32 %57, 16
%59 = load i8*, i8** %5
%60 = getelementptr inbounds i8, i8* %59, i64 4
%61 = load i8, i8* %60
%62 = zext i8 %61 to i32
%63 = and i32 %62, 255
%64 = shl i32 %63, 8
%65 = or i32 %58, %64
%66 = load i8*, i8** %5
%67 = getelementptr inbounds i8, i8* %66, i64 5
%68 = load i8, i8* %67
%69 = zext i8 %68 to i32
%70 = and i32 %69, 255
%71 = or i32 %65, %70
%72 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %52, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %71)
br label %73
73: ; preds = %51, %9
%74 = load i8*, i8** %5
%75 = getelementptr inbounds i8, i8* %74, i64 2
%76 = load i8, i8* %75
%77 = zext i8 %76 to i32
%78 = and i32 %77, 128
%79 = icmp eq i32 64, %78
br i1 %79, label %80, label %104
80: ; preds = %73
%81 = load i8*, i8** %5
%82 = getelementptr inbounds i8, i8* %81, i64 2
%83 = load i8, i8* %82
%84 = zext i8 %83 to i32
%85 = and i32 %84, 128
%86 = icmp eq i32 128, %85
br i1 %86, label %87, label %95
87: ; preds = %80
%88 = load i32, i32* %4
%89 = load i8*, i8** %5
%90 = getelementptr inbounds i8, i8* %89, i64 6
%91 = load i8, i8* %90
%92 = zext i8 %91 to i32
%93 = and i32 %92, 255
%94 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %88, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %93)
br label %103
95: ; preds = %80
%96 = load i32, i32* %4
%97 = load i8*, i8** %5
%98 = getelementptr inbounds i8, i8* %97, i64 3
%99 = load i8, i8* %98
%100 = zext i8 %99 to i32
%101 = and i32 %100, 255
%102 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %96, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %101)
br label %103
103: ; preds = %95, %87
br label %104
104: ; preds = %103, %73
%105 = load i32, i32* %4
%106 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %105, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%107 = load i8*, i8** %5
%108 = getelementptr inbounds i8, i8* %107, i64 1
%109 = load i8, i8* %108
%110 = zext i8 %109 to i32
store i32 %110, i32* %3
br label %111
111: ; preds = %104, %8
%112 = load i32, i32* %3
ret i32 %112
}

LLVM IR (-O2):
@.str = [26 x i8] c"Descriptor_length = 0x%x\0A\00"
@.str.1 = [37 x i8] c"scrambling_sequence_selector = 0x%x\0A\00"
@.str.2 = [35 x i8] c"multiple_input_stream_flag = 0x%x\0A\00"
@.str.3 = [42 x i8] c"backwards_compatibility_indicator = 0x%x\0A\00"
@.str.4 = [34 x i8] c"scrambling_sequence_index = 0x%x\0A\00"
@.str.6 = [17 x i8] c"******END******\0A\00"
define i32 @x79_Tag_DescriptorParser(i32 %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %47, 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, 7
%14 = zext i8 %13 to i32
%15 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load i8, i8* %11
%17 = lshr i8 %16, 6
%18 = and i8 %17, 1
%19 = zext i8 %18 to i32
%20 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = load i8, i8* %11
%22 = lshr i8 %21, 5
%23 = and i8 %22, 1
%24 = zext i8 %23 to i32
%25 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = load i8, i8* %11
%27 = icmp slt i8 %26, 0
br i1 %27, label %28, label %43
28: ; preds = %4
%29 = getelementptr inbounds i8, i8* %1, i64 3
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
%32 = shl nuw nsw i32 %31, 16
%33 = getelementptr inbounds i8, i8* %1, i64 4
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = shl nuw nsw i32 %35, 8
%37 = or i32 %36, %32
%38 = getelementptr inbounds i8, i8* %1, i64 5
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = or i32 %37, %40
%42 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %4, %28
%44 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%45 = load i8, i8* %7
%46 = zext i8 %45 to i32
br label %47
47: ; preds = %2, %43
%48 = phi i32 [ %46, %43 ], [ -1, %2 ]
ret i32 %48
}