#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 x48_Tag_DescriptorParser(unsigned int type, unsigned char *buff) {
  unsigned int i = 0;
  unsigned char *data = NULL;
  unsigned char tmplen = 0;
  if (NULL == buff) {
    return -1;
  }
  Parser_DisplayTagInfo(type, buff[0]);
  Parser_TsPacketLog(type, "Descriptor_length = 0x%x\n", buff[1]);
  Parser_TsPacketLog(type, "service_type = 0x%x\n", buff[2]);
  Parser_TsPacketLog(type, "service_provider_name_length = 0x%x\n", buff[3]);
  data = buff;
  data += 4;
  if (0 != buff[3]) {
    Parser_TsPacketLog(type, "service_provider_name:");
    for (i = 0; i < buff[3]; i++) {
      Parser_TsPacketLog(type, "%c", data[i]);
    }
    Parser_TsPacketLog(type, "\n");
  }
  data += i;
  tmplen = data[0];
  data += 1;
  Parser_TsPacketLog(type, "service_name_length = 0x%x\n", tmplen);
  if (0 != tmplen) {
    Parser_TsPacketLog(type, "service_name:");
    for (i = 0; i < tmplen; i++) {
      Parser_TsPacketLog(type, "%c", data[i]);
    }
    Parser_TsPacketLog(type, "\n");
  }
  Parser_TsPacketLog(type, "******END******\n");
  return buff[1];
}


x86 assembly (clang, -O0):
<x48_Tag_DescriptorParser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movb   $0x0,-0x21(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    115a <x48_Tag_DescriptorParser+0x3a>
movl   $0xffffffff,-0x4(%rbp)
jmp    1306 <x48_Tag_DescriptorParser+0x1e6>
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    0xe85(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
movzbl 0x2(%rax),%edx
lea    0xe86(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
movzbl 0x3(%rax),%edx
lea    0xe82(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movzbl 0x3(%rax),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
je     1240 <x48_Tag_DescriptorParser+0x120>
mov    -0x8(%rbp),%edi
lea    0xe70(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
movzbl 0x3(%rcx),%ecx
cmp    %ecx,%eax
jae    122f <x48_Tag_DescriptorParser+0x10f>
mov    -0x8(%rbp),%edi
mov    -0x20(%rbp),%rax
mov    -0x14(%rbp),%ecx
movzbl (%rax,%rcx,1),%edx
lea    0xe51(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f2 <x48_Tag_DescriptorParser+0xd2>
mov    -0x8(%rbp),%edi
lea    0xe6e(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x21(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
movzbl -0x21(%rbp),%edx
lea    0xdfb(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
movzbl -0x21(%rbp),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
je     12ea <x48_Tag_DescriptorParser+0x1ca>
mov    -0x8(%rbp),%edi
lea    0xdf8(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
movzbl -0x21(%rbp),%ecx
cmp    %ecx,%eax
jae    12d9 <x48_Tag_DescriptorParser+0x1b9>
mov    -0x8(%rbp),%edi
mov    -0x20(%rbp),%rax
mov    -0x14(%rbp),%ecx
movzbl (%rax,%rcx,1),%edx
lea    0xda7(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12a0 <x48_Tag_DescriptorParser+0x180>
mov    -0x8(%rbp),%edi
lea    0xdc4(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x8(%rbp),%edi
lea    0xda4(%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    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<x48_Tag_DescriptorParser>:
test   %rsi,%rsi
je     1282 <x48_Tag_DescriptorParser+0x162>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%r15d
movzbl (%rsi),%esi
call   1040 <Parser_DisplayTagInfo@plt>
movzbl 0x1(%r14),%edx
lea    0xeb2(%rip),%rsi
xor    %ebp,%ebp
mov    %r15d,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
movzbl 0x2(%r14),%edx
lea    0xeb4(%rip),%rsi
mov    %r15d,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
movzbl 0x3(%r14),%edx
lea    0xeb3(%rip),%rsi
mov    %r15d,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
lea    0x4(%r14),%r12
cmpb   $0x0,0x3(%r14)
je     11f2 <x48_Tag_DescriptorParser+0xd2>
lea    0xebc(%rip),%rsi
xor    %ebp,%ebp
mov    %r15d,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
cmpb   $0x0,0x3(%r14)
je     11e1 <x48_Tag_DescriptorParser+0xc1>
lea    0xeb9(%rip),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl 0x4(%r14,%rbp,1),%edx
mov    %r15d,%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
add    $0x1,%rbp
movzbl 0x3(%r14),%eax
cmp    %rax,%rbp
jb     11c0 <x48_Tag_DescriptorParser+0xa0>
lea    0xebf(%rip),%rsi
mov    %r15d,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
mov    %ebp,%ebp
movzbl (%r12,%rbp,1),%ebx
lea    0xe6e(%rip),%rsi
mov    %r15d,%edi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
test   %ebx,%ebx
je     125d <x48_Tag_DescriptorParser+0x13d>
add    %rbp,%r12
lea    0xe70(%rip),%rsi
mov    %r15d,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
lea    0xe40(%rip),%r13
xor    %ebp,%ebp
nopl   (%rax)
movzbl 0x1(%r12,%rbp,1),%edx
mov    %r15d,%edi
mov    %r13,%rsi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1230 <x48_Tag_DescriptorParser+0x110>
lea    0xe54(%rip),%rsi
mov    %r15d,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
lea    0xe34(%rip),%rsi
mov    %r15d,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
movzbl 0x1(%r14),%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 = [21 x i8] c"service_type = 0x%x\0A\00"
@.str.2 = [37 x i8] c"service_provider_name_length = 0x%x\0A\00"
@.str.3 = [23 x i8] c"service_provider_name:\00"
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [28 x i8] c"service_name_length = 0x%x\0A\00"
@.str.7 = [14 x i8] c"service_name:\00"
@.str.8 = [17 x i8] c"******END******\0A\00"
define i32 @x48_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* null, 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 %116
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 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %24, i8* getelementptr inbounds ([21 x i8], [21 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 3
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %30, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%36 = load i8*, i8** %5
store i8* %36, i8** %7
%37 = load i8*, i8** %7
%38 = getelementptr inbounds i8, i8* %37, i64 4
store i8* %38, i8** %7
%39 = load i8*, i8** %5
%40 = getelementptr inbounds i8, i8* %39, i64 3
%41 = load i8, i8* %40
%42 = zext i8 %41 to i32
%43 = icmp ne i32 0, %42
br i1 %43, label %44, label %69
44: ; preds = %12
%45 = load i32, i32* %4
%46 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %45, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %6
br label %47
47: ; preds = %63, %44
%48 = load i32, i32* %6
%49 = load i8*, i8** %5
%50 = getelementptr inbounds i8, i8* %49, i64 3
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = icmp ult i32 %48, %52
br i1 %53, label %54, label %66
54: ; preds = %47
%55 = load i32, i32* %4
%56 = load i8*, i8** %7
%57 = load i32, i32* %6
%58 = zext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
%60 = load i8, i8* %59
%61 = zext i8 %60 to i32
%62 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %55, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %61)
br label %63
63: ; preds = %54
%64 = load i32, i32* %6
%65 = add i32 %64, 1
store i32 %65, i32* %6
br label %47
66: ; preds = %47
%67 = load i32, i32* %4
%68 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %69
69: ; preds = %66, %12
%70 = load i32, i32* %6
%71 = load i8*, i8** %7
%72 = zext i32 %70 to i64
%73 = getelementptr inbounds i8, i8* %71, i64 %72
store i8* %73, i8** %7
%74 = load i8*, i8** %7
%75 = getelementptr inbounds i8, i8* %74, i64 0
%76 = load i8, i8* %75
store i8 %76, i8* %8
%77 = load i8*, i8** %7
%78 = getelementptr inbounds i8, i8* %77, i64 1
store i8* %78, i8** %7
%79 = load i32, i32* %4
%80 = load i8, i8* %8
%81 = zext i8 %80 to i32
%82 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %79, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i32 %81)
%83 = load i8, i8* %8
%84 = zext i8 %83 to i32
%85 = icmp ne i32 0, %84
br i1 %85, label %86, label %109
86: ; preds = %69
%87 = load i32, i32* %4
%88 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %87, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %6
br label %89
89: ; preds = %103, %86
%90 = load i32, i32* %6
%91 = load i8, i8* %8
%92 = zext i8 %91 to i32
%93 = icmp ult i32 %90, %92
br i1 %93, label %94, label %106
94: ; preds = %89
%95 = load i32, i32* %4
%96 = load i8*, i8** %7
%97 = load i32, i32* %6
%98 = zext i32 %97 to i64
%99 = getelementptr inbounds i8, i8* %96, i64 %98
%100 = load i8, i8* %99
%101 = zext i8 %100 to i32
%102 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %95, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %101)
br label %103
103: ; preds = %94
%104 = load i32, i32* %6
%105 = add i32 %104, 1
store i32 %105, i32* %6
br label %89
106: ; preds = %89
%107 = load i32, i32* %4
%108 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %107, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %109
109: ; preds = %106, %69
%110 = load i32, i32* %4
%111 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %110, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%112 = load i8*, i8** %5
%113 = getelementptr inbounds i8, i8* %112, i64 1
%114 = load i8, i8* %113
%115 = zext i8 %114 to i32
store i32 %115, i32* %3
br label %116
116: ; preds = %109, %11
%117 = load i32, i32* %3
ret i32 %117
}

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