#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*/ EMSGSIZE;
#define NS_CMPRSFLGS 128
int /*<<< orphan*/ errno;
int local_ns_labellen(unsigned char const *);
int local_ns_name_skip(const unsigned char **ptrptr, const unsigned char *eom) {
  const unsigned char *cp;
  unsigned int n;
  int l;
  cp = *ptrptr;
  while (cp < eom && (n = *cp++) != 0) {
    switch (n & NS_CMPRSFLGS) {
    case 0:
      cp += n;
      continue;
    case 0x40:
      if ((l = local_ns_labellen(cp - 1)) < 0) {
        errno = EMSGSIZE;
        return -1;
      }
      cp += l;
      continue;
    case NS_CMPRSFLGS:
      cp++;
      break;
    default:
      errno = EMSGSIZE;
      return -1;
    }
    break;
  }
  if (cp > eom) {
    errno = EMSGSIZE;
    return -1;
  }
  *ptrptr = cp;
  return 0;
}


x86 assembly (clang, -O0):
<local_ns_name_skip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
xor    %eax,%eax
cmp    -0x18(%rbp),%rcx
mov    %al,-0x29(%rbp)
jae    115c <local_ns_name_skip+0x4c>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movzbl (%rax),%eax
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    116c <local_ns_name_skip+0x5c>
jmp    123c <local_ns_name_skip+0x12c>
mov    -0x24(%rbp),%eax
and    $0x80,%eax
mov    %eax,-0x30(%rbp)
je     11a6 <local_ns_name_skip+0x96>
jmp    1182 <local_ns_name_skip+0x72>
mov    -0x30(%rbp),%eax
sub    $0x40,%eax
je     11bb <local_ns_name_skip+0xab>
jmp    1193 <local_ns_name_skip+0x83>
mov    -0x30(%rbp),%eax
sub    $0x80,%eax
je     1208 <local_ns_name_skip+0xf8>
jmp    1219 <local_ns_name_skip+0x109>
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
jmp    112b <local_ns_name_skip+0x1b>
mov    -0x20(%rbp),%rdi
add    $0xffffffffffffffff,%rdi
call   1030 <local_ns_labellen@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jge    11f2 <local_ns_name_skip+0xe2>
mov    0x2e0d(%rip),%rax
mov    (%rax),%ecx
mov    0x2df4(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    127a <local_ns_name_skip+0x16a>
mov    -0x28(%rbp),%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
jmp    112b <local_ns_name_skip+0x1b>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1237 <local_ns_name_skip+0x127>
mov    0x2dc8(%rip),%rax
mov    (%rax),%ecx
mov    0x2daf(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    127a <local_ns_name_skip+0x16a>
jmp    123c <local_ns_name_skip+0x12c>
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    1268 <local_ns_name_skip+0x158>
mov    0x2d97(%rip),%rax
mov    (%rax),%ecx
mov    0x2d7e(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    127a <local_ns_name_skip+0x16a>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<local_ns_name_skip>:
mov    (%rdi),%rcx
cmp    %rsi,%rcx
jae    114c <local_ns_name_skip+0x4c>
nopl   0x0(%rax,%rax,1)
lea    0x1(%rcx),%rax
movzbl (%rcx),%edx
test   %rdx,%rdx
je     112b <local_ns_name_skip+0x2b>
test   %dl,%dl
js     1148 <local_ns_name_skip+0x48>
add    %rdx,%rax
mov    %rax,%rcx
cmp    %rsi,%rax
jb     1110 <local_ns_name_skip+0x10>
cmp    %rsi,%rax
jbe    1154 <local_ns_name_skip+0x54>
mov    0x2eb1(%rip),%rax
mov    (%rax),%eax
mov    0x2e98(%rip),%rcx
mov    %eax,(%rcx)
mov    $0xffffffff,%eax
ret
add    $0x2,%rcx
mov    %rcx,%rax
cmp    %rsi,%rax
ja     1130 <local_ns_name_skip+0x30>
mov    %rax,(%rdi)
xor    %eax,%eax
ret

LLVM IR (-O0):
@EMSGSIZE = global i32 0
@errno = global i32 0
define i32 @local_ns_name_skip(i8** %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8** %0, i8*** %4
store i8* %1, i8** %5
%9 = load i8**, i8*** %4
%10 = load i8*, i8** %9
store i8* %10, i8** %6
br label %11
11: ; preds = %38, %26, %2
%12 = load i8*, i8** %6
%13 = load i8*, i8** %5
%14 = icmp ult i8* %12, %13
br i1 %14, label %15, label %21
15: ; preds = %11
%16 = load i8*, i8** %6
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %6
%18 = load i8, i8* %16
%19 = zext i8 %18 to i32
store i32 %19, i32* %7
%20 = icmp ne i32 %19, 0
br label %21
21: ; preds = %15, %11
%22 = phi i1 [ false, %11 ], [ %20, %15 ]
br i1 %22, label %23, label %49
23: ; preds = %21
%24 = load i32, i32* %7
%25 = and i32 %24, 128
switch i32 %25, label %46 [
i32 0, label %26
i32 64, label %31
i32 128, label %43
]
26: ; preds = %23
%27 = load i32, i32* %7
%28 = load i8*, i8** %6
%29 = zext i32 %27 to i64
%30 = getelementptr inbounds i8, i8* %28, i64 %29
store i8* %30, i8** %6
br label %11
31: ; preds = %23
%32 = load i8*, i8** %6
%33 = getelementptr inbounds i8, i8* %32, i64 -1
%34 = call i32 @local_ns_labellen(i8* %33)
store i32 %34, i32* %8
%35 = icmp slt i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %31
%37 = load i32, i32* @EMSGSIZE
store i32 %37, i32* @errno
store i32 -1, i32* %3
br label %58
38: ; preds = %31
%39 = load i32, i32* %8
%40 = load i8*, i8** %6
%41 = sext i32 %39 to i64
%42 = getelementptr inbounds i8, i8* %40, i64 %41
store i8* %42, i8** %6
br label %11
43: ; preds = %23
%44 = load i8*, i8** %6
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %6
br label %48
46: ; preds = %23
%47 = load i32, i32* @EMSGSIZE
store i32 %47, i32* @errno
store i32 -1, i32* %3
br label %58
48: ; preds = %43
br label %49
49: ; preds = %48, %21
%50 = load i8*, i8** %6
%51 = load i8*, i8** %5
%52 = icmp ugt i8* %50, %51
br i1 %52, label %53, label %55
53: ; preds = %49
%54 = load i32, i32* @EMSGSIZE
store i32 %54, i32* @errno
store i32 -1, i32* %3
br label %58
55: ; preds = %49
%56 = load i8*, i8** %6
%57 = load i8**, i8*** %4
store i8* %56, i8** %57
store i32 0, i32* %3
br label %58
58: ; preds = %55, %53, %46, %36
%59 = load i32, i32* %3
ret i32 %59
}

LLVM IR (-O2):
@EMSGSIZE = global i32 0
@errno = global i32 0
define i32 @local_ns_name_skip(i8** nocapture %0, i8* readnone %1) {
%3 = load i8*, i8** %0
%4 = icmp ult i8* %3, %1
br i1 %4, label %5, label %18
5: ; preds = %2, %12
%6 = phi i8* [ %14, %12 ], [ %3, %2 ]
%7 = getelementptr inbounds i8, i8* %6, i64 1
%8 = load i8, i8* %6
%9 = icmp eq i8 %8, 0
br i1 %9, label %18, label %10
10: ; preds = %5
%11 = icmp sgt i8 %8, -1
br i1 %11, label %12, label %16
12: ; preds = %10
%13 = zext i8 %8 to i64
%14 = getelementptr inbounds i8, i8* %7, i64 %13
%15 = icmp ult i8* %14, %1
br i1 %15, label %5, label %18
16: ; preds = %10
%17 = getelementptr inbounds i8, i8* %6, i64 2
br label %18
18: ; preds = %5, %12, %2, %16
%19 = phi i8* [ %17, %16 ], [ %3, %2 ], [ %7, %5 ], [ %14, %12 ]
%20 = icmp ugt i8* %19, %1
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = load i32, i32* @EMSGSIZE
store i32 %22, i32* @errno
br label %24
23: ; preds = %18
store i8* %19, i8** %0
br label %24
24: ; preds = %23, %21
%25 = phi i32 [ -1, %21 ], [ 0, %23 ]
ret i32 %25
}