#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 */
typedef int u_int;
typedef int /*<<< orphan*/ u_char;

/* Variables and functions */
int /*<<< orphan*/ EMSGSIZE;
#define NS_CMPRSFLGS 128
int /*<<< orphan*/ errno;
int ns_name_skip(const u_char **ptrptr, const u_char *eom) {
  const u_char *cp;
  u_int n;
  cp = *ptrptr;
  while (cp < eom && (n = *cp++) != 0) {
    switch (n & NS_CMPRSFLGS) {
    case 0:
      cp += n;
      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):
<ns_name_skip>:
push   %rbp
mov    %rsp,%rbp
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,-0x25(%rbp)
jae    1147 <ns_name_skip+0x47>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    1157 <ns_name_skip+0x57>
jmp    11ce <ns_name_skip+0xce>
mov    -0x24(%rbp),%eax
and    $0x80,%eax
mov    %eax,-0x2c(%rbp)
je     1180 <ns_name_skip+0x80>
jmp    116d <ns_name_skip+0x6d>
mov    -0x2c(%rbp),%eax
sub    $0x80,%eax
je     119a <ns_name_skip+0x9a>
jmp    11ab <ns_name_skip+0xab>
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
jmp    1117 <ns_name_skip+0x17>
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
jmp    11c9 <ns_name_skip+0xc9>
mov    0x2e36(%rip),%rax
mov    (%rax),%ecx
mov    0x2e1d(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    120c <ns_name_skip+0x10c>
jmp    11ce <ns_name_skip+0xce>
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    11fa <ns_name_skip+0xfa>
mov    0x2e05(%rip),%rax
mov    (%rax),%ecx
mov    0x2dec(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    120c <ns_name_skip+0x10c>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ns_name_skip>:
mov    (%rdi),%rax
cmp    %rsi,%rax
jae    112f <ns_name_skip+0x2f>
nopl   0x0(%rax,%rax,1)
lea    0x4(%rax),%rcx
movslq (%rax),%rdx
test   %rdx,%rdx
je     112c <ns_name_skip+0x2c>
test   $0x80,%dl
jne    114c <ns_name_skip+0x4c>
lea    (%rcx,%rdx,4),%rax
cmp    %rsi,%rax
jb     1110 <ns_name_skip+0x10>
jmp    112f <ns_name_skip+0x2f>
mov    %rcx,%rax
cmp    %rsi,%rax
jbe    1155 <ns_name_skip+0x55>
mov    0x2ead(%rip),%rax
mov    (%rax),%eax
mov    0x2e94(%rip),%rcx
mov    %eax,(%rcx)
mov    $0xffffffff,%eax
ret
add    $0x8,%rax
cmp    %rsi,%rax
ja     1134 <ns_name_skip+0x34>
mov    %rax,(%rdi)
xor    %eax,%eax
ret

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

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