#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 x4F_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, "reference_service_id = 0x%x\n",
                     ((buff[2] & 0xFF) << 8) | (buff[3] & 0xFF));
  Parser_TsPacketLog(type, "reference_event_id = 0x%x\n",
                     ((buff[4] & 0xFF) << 8) | (buff[5] & 0xFF));
  Parser_TsPacketLog(type, "******END******\n");
  return buff[1];
}


x86 assembly (clang, -O0):
<x4F_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 <x4F_Tag_DescriptorParser+0x27>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ed <x4F_Tag_DescriptorParser+0xcd>
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    $0xff,%edx
shl    $0x8,%edx
mov    -0x10(%rbp),%rax
movzbl 0x3(%rax),%eax
and    $0xff,%eax
or     %eax,%edx
lea    0xe81(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
movzbl 0x4(%rax),%edx
and    $0xff,%edx
shl    $0x8,%edx
mov    -0x10(%rbp),%rax
movzbl 0x5(%rax),%eax
and    $0xff,%eax
or     %eax,%edx
lea    0xe6d(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x8(%rbp),%edi
lea    0xe77(%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):
<x4F_Tag_DescriptorParser>:
test   %rsi,%rsi
je     1196 <x4F_Tag_DescriptorParser+0x76>
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    0xec0(%rip),%rsi
mov    %ebp,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
movzwl 0x2(%rbx),%edx
shl    $0x10,%edx
bswap  %edx
lea    0xec1(%rip),%rsi
mov    %ebp,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
movzwl 0x4(%rbx),%edx
shl    $0x10,%edx
bswap  %edx
lea    0xec5(%rip),%rsi
mov    %ebp,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
lea    0xed0(%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 = [29 x i8] c"reference_service_id = 0x%x\0A\00"
@.str.2 = [27 x i8] c"reference_event_id = 0x%x\0A\00"
@.str.3 = [17 x i8] c"******END******\0A\00"
define i32 @x4F_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 %55
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, 255
%27 = shl i32 %26, 8
%28 = load i8*, i8** %5
%29 = getelementptr inbounds i8, i8* %28, i64 3
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
%32 = and i32 %31, 255
%33 = or i32 %27, %32
%34 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %21, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %4
%36 = load i8*, i8** %5
%37 = getelementptr inbounds i8, i8* %36, i64 4
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = and i32 %39, 255
%41 = shl i32 %40, 8
%42 = load i8*, i8** %5
%43 = getelementptr inbounds i8, i8* %42, i64 5
%44 = load i8, i8* %43
%45 = zext i8 %44 to i32
%46 = and i32 %45, 255
%47 = or i32 %41, %46
%48 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %35, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %47)
%49 = load i32, i32* %4
%50 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %49, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%51 = load i8*, i8** %5
%52 = getelementptr inbounds i8, i8* %51, i64 1
%53 = load i8, i8* %52
%54 = zext i8 %53 to i32
store i32 %54, i32* %3
br label %55
55: ; preds = %9, %8
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@.str = [26 x i8] c"Descriptor_length = 0x%x\0A\00"
@.str.1 = [29 x i8] c"reference_service_id = 0x%x\0A\00"
@.str.2 = [27 x i8] c"reference_event_id = 0x%x\0A\00"
@.str.3 = [17 x i8] c"******END******\0A\00"
define i32 @x4F_Tag_DescriptorParser(i32 %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %32, 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 ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds i8, i8* %1, i64 4
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = shl nuw nsw i32 %22, 8
%24 = getelementptr inbounds i8, i8* %1, i64 5
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = or i32 %23, %26
%28 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%30 = load i8, i8* %7
%31 = zext i8 %30 to i32
br label %32
32: ; preds = %2, %4
%33 = phi i32 [ %31, %4 ], [ -1, %2 ]
ret i32 %33
}