#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 x00_Tag_DescriptorParser(unsigned int type, unsigned char *buff) {
  unsigned int i = 0;
  if (NULL == buff) {
    return -1;
  }
  Parser_DisplayTagInfo(type, buff[0]);
  if (0 != buff[1]) {
    Parser_TsPacketLog(type, "user_private_define_byte:");
    for (i = 0; i < buff[1]; i++) {
      Parser_TsPacketLog(type, " 0x%02x", buff[i + 2]);
    }
    Parser_TsPacketLog(type, "\n");
  }
  Parser_TsPacketLog(type, "******END******\n");
  return buff[1];
}


x86 assembly (clang, -O0):
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 <x00_Tag_DescriptorParser+0x2e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f6 <x00_Tag_DescriptorParser+0xd6>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
movzbl (%rax),%esi
call   1040 <Parser_DisplayTagInfo@plt>
mov    -0x10(%rbp),%rax
movzbl 0x1(%rax),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
je     11da <x00_Tag_DescriptorParser+0xba>
mov    -0x8(%rbp),%edi
lea    0xe87(%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    11c9 <x00_Tag_DescriptorParser+0xa9>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x2,%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%edx
lea    0xe66(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1187 <x00_Tag_DescriptorParser+0x67>
mov    -0x8(%rbp),%edi
lea    0xe5e(%rip),%rsi
mov    $0x0,%al
call   1030 <Parser_TsPacketLog@plt>
mov    -0x8(%rbp),%edi
lea    0xe3e(%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):
test   %rsi,%rsi
je     11c0 <x00_Tag_DescriptorParser+0xa0>
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%r15d
movzbl (%rsi),%esi
call   1040 <Parser_DisplayTagInfo@plt>
cmpb   $0x0,0x1(%rbx)
je     11a0 <x00_Tag_DescriptorParser+0x80>
lea    0xeb5(%rip),%rsi
mov    %r15d,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
cmpb   $0x0,0x1(%rbx)
je     118f <x00_Tag_DescriptorParser+0x6f>
lea    0xeb8(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
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     1170 <x00_Tag_DescriptorParser+0x50>
lea    0xe9b(%rip),%rsi
mov    %r15d,%edi
xor    %eax,%eax
call   1030 <Parser_TsPacketLog@plt>
lea    0xe7b(%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"user_private_define_byte:\00"
@.str.1 = [8 x i8] c" 0x%02x\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [17 x i8] c"******END******\0A\00"
define i32 @x00_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 %54
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 i8*, i8** %5
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = icmp ne i32 0, %19
br i1 %20, label %21, label %47
21: ; preds = %10
%22 = load i32, i32* %4
%23 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %22, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
br label %24
24: ; preds = %41, %21
%25 = load i32, i32* %6
%26 = load i8*, i8** %5
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = icmp ult i32 %25, %29
br i1 %30, label %31, label %44
31: ; preds = %24
%32 = load i32, i32* %4
%33 = load i8*, i8** %5
%34 = load i32, i32* %6
%35 = add i32 %34, 2
%36 = zext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %33, i64 %36
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %32, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %31
%42 = load i32, i32* %6
%43 = add i32 %42, 1
store i32 %43, i32* %6
br label %24
44: ; preds = %24
%45 = load i32, i32* %4
%46 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %47
47: ; preds = %44, %10
%48 = load i32, i32* %4
%49 = call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %48, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%50 = load i8*, i8** %5
%51 = getelementptr inbounds i8, i8* %50, i64 1
%52 = load i8, i8* %51
%53 = zext i8 %52 to i32
store i32 %53, i32* %3
br label %54
54: ; preds = %47, %9
%55 = load i32, i32* %3
ret i32 %55
}

LLVM IR (-O2):
@.str = [26 x i8] c"user_private_define_byte:\00"
@.str.1 = [8 x i8] c" 0x%02x\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [17 x i8] c"******END******\0A\00"
define i32 @x00_Tag_DescriptorParser(i32 %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %31, 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 = icmp eq i8 %8, 0
br i1 %9, label %27, label %10
10: ; preds = %4
%11 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%12 = load i8, i8* %7
%13 = icmp eq i8 %12, 0
br i1 %13, label %25, label %14
14: ; preds = %10, %14
%15 = phi i64 [ %21, %14 ], [ 0, %10 ]
%16 = add nuw nsw i64 %15, 2
%17 = getelementptr inbounds i8, i8* %1, i64 %16
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = add nuw nsw i64 %15, 1
%22 = load i8, i8* %7
%23 = zext i8 %22 to i64
%24 = icmp ult i64 %21, %23
br i1 %24, label %14, label %25
25: ; preds = %14, %10
%26 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %27
27: ; preds = %25, %4
%28 = tail call i32 (i32, i8*, ...) @Parser_TsPacketLog(i32 %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%29 = load i8, i8* %7
%30 = zext i8 %29 to i32
br label %31
31: ; preds = %2, %27
%32 = phi i32 [ %30, %27 ], [ -1, %2 ]
ret i32 %32
}