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

/* Variables and functions */
dn_skipname(u_char *comp_dn, u_char *eom) {
  u_char *cp;
  int n;
  cp = comp_dn;
  while (cp < eom && (n = *cp++)) {
    switch (n & 0xc0) {
    case 0:
      cp += n;
      continue;
    default:
      return (-1);
    case 0xc0:
      cp++;
    }
    break;
  }
  return (cp - comp_dn);
}


x86 assembly (clang, -O0):
<dn_skipname>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
xor    %eax,%eax
cmp    -0x18(%rbp),%rcx
mov    %al,-0x25(%rbp)
jae    1144 <dn_skipname+0x44>
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    1154 <dn_skipname+0x54>
jmp    11b4 <dn_skipname+0xb4>
mov    -0x24(%rbp),%eax
and    $0xc0,%eax
mov    %eax,-0x2c(%rbp)
je     117d <dn_skipname+0x7d>
jmp    116a <dn_skipname+0x6a>
mov    -0x2c(%rbp),%eax
sub    $0xc0,%eax
je     11a3 <dn_skipname+0xa3>
jmp    1197 <dn_skipname+0x97>
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
jmp    1114 <dn_skipname+0x14>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c6 <dn_skipname+0xc6>
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
jmp    11b4 <dn_skipname+0xb4>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
sar    $0x2,%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<dn_skipname>:
mov    %rdi,%rax
cmp    %rsi,%rdi
jae    113c <dn_skipname+0x3c>
mov    %rdi,%rax
nopl   0x0(%rax,%rax,1)
lea    0x4(%rax),%r8
movslq (%rax),%rdx
test   %rdx,%rdx
je     1139 <dn_skipname+0x39>
mov    %edx,%ecx
and    $0xc0,%cl
jne    112e <dn_skipname+0x2e>
lea    (%r8,%rdx,4),%rax
cmp    %rsi,%rax
jb     1110 <dn_skipname+0x10>
jmp    113c <dn_skipname+0x3c>
cmp    $0xc0,%cl
jne    1144 <dn_skipname+0x44>
add    $0x8,%rax
jmp    113c <dn_skipname+0x3c>
mov    %r8,%rax
sub    %rdi,%rax
shr    $0x2,%rax
ret
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
define i32 @dn_skipname(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
store i32* %8, i32** %6
br label %9
9: ; preds = %23, %2
%10 = load i32*, i32** %6
%11 = load i32*, i32** %5
%12 = icmp ult i32* %10, %11
br i1 %12, label %13, label %18
13: ; preds = %9
%14 = load i32*, i32** %6
%15 = getelementptr inbounds i32, i32* %14, i32 1
store i32* %15, i32** %6
%16 = load i32, i32* %14
store i32 %16, i32* %7
%17 = icmp ne i32 %16, 0
br label %18
18: ; preds = %13, %9
%19 = phi i1 [ false, %9 ], [ %17, %13 ]
br i1 %19, label %20, label %33
20: ; preds = %18
%21 = load i32, i32* %7
%22 = and i32 %21, 192
switch i32 %22, label %28 [
i32 0, label %23
i32 192, label %29
]
23: ; preds = %20
%24 = load i32, i32* %7
%25 = load i32*, i32** %6
%26 = sext i32 %24 to i64
%27 = getelementptr inbounds i32, i32* %25, i64 %26
store i32* %27, i32** %6
br label %9
28: ; preds = %20
store i32 -1, i32* %3
br label %41
29: ; preds = %20
%30 = load i32*, i32** %6
%31 = getelementptr inbounds i32, i32* %30, i32 1
store i32* %31, i32** %6
br label %32
32: ; preds = %29
br label %33
33: ; preds = %32, %18
%34 = load i32*, i32** %6
%35 = load i32*, i32** %4
%36 = ptrtoint i32* %34 to i64
%37 = ptrtoint i32* %35 to i64
%38 = sub i64 %36, %37
%39 = sdiv exact i64 %38, 4
%40 = trunc i64 %39 to i32
store i32 %40, i32* %3
br label %41
41: ; preds = %33, %28
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
define i32 @dn_skipname(i32* %0, i32* readnone %1) {
%3 = icmp ult i32* %0, %1
br i1 %3, label %4, label %18
4: ; preds = %2, %12
%5 = phi i32* [ %14, %12 ], [ %0, %2 ]
%6 = getelementptr inbounds i32, i32* %5, i64 1
%7 = load i32, i32* %5
%8 = icmp eq i32 %7, 0
br i1 %8, label %18, label %9
9: ; preds = %4
%10 = trunc i32 %7 to i8
%11 = and i8 %10, -64
switch i8 %11, label %25 [
i8 0, label %12
i8 -64, label %16
]
12: ; preds = %9
%13 = sext i32 %7 to i64
%14 = getelementptr inbounds i32, i32* %6, i64 %13
%15 = icmp ult i32* %14, %1
br i1 %15, label %4, label %18
16: ; preds = %9
%17 = getelementptr inbounds i32, i32* %5, i64 2
br label %18
18: ; preds = %4, %12, %2, %16
%19 = phi i32* [ %17, %16 ], [ %0, %2 ], [ %6, %4 ], [ %14, %12 ]
%20 = ptrtoint i32* %19 to i64
%21 = ptrtoint i32* %0 to i64
%22 = sub i64 %20, %21
%23 = lshr exact i64 %22, 2
%24 = trunc i64 %23 to i32
br label %25
25: ; preds = %9, %18
%26 = phi i32 [ %24, %18 ], [ -1, %9 ]
ret i32 %26
}