#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 scalar_t__ uint8_t;
typedef int /*<<< orphan*/ uint16_t;

/* Variables and functions */
const char *_dns_skip_qname(const char *p) {
  if (p) {
    while (*p != 0) {
      if ((*p & 0xC0) == 0xC0) {
        p += sizeof(uint16_t);
        return p;
      } else
        p += (*(uint8_t *)p + 1);
    }
    p += 1;
  }
  return p;
}


x86 assembly (clang, -O0):
<_dns_skip_qname>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     117c <_dns_skip_qname+0x7c>
jmp    1118 <_dns_skip_qname+0x18>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1170 <_dns_skip_qname+0x70>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
and    $0xc0,%eax
cmp    $0xc0,%eax
jne    1158 <_dns_skip_qname+0x58>
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1184 <_dns_skip_qname+0x84>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
add    $0x1,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1118 <_dns_skip_qname+0x18>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_dns_skip_qname>:
test   %rdi,%rdi
je     1131 <_dns_skip_qname+0x31>
mov    (%rdi),%cl
test   %cl,%cl
je     1134 <_dns_skip_qname+0x34>
nopl   0x0(%rax,%rax,1)
cmp    $0xc0,%cl
jae    113c <_dns_skip_qname+0x3c>
mov    (%rdi),%rcx
lea    (%rcx,%rdi,1),%rax
add    $0x1,%rax
movzbl 0x1(%rcx,%rdi,1),%ecx
mov    %rax,%rdi
test   %cl,%cl
jne    1110 <_dns_skip_qname+0x10>
add    $0x1,%rax
ret
xor    %eax,%eax
ret
mov    %rdi,%rax
add    $0x1,%rax
ret
add    $0x4,%rdi
mov    %rdi,%rax
ret

LLVM IR (-O0):
define i8* @_dns_skip_qname(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %33
6: ; preds = %1
br label %7
7: ; preds = %29, %6
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %30
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = and i32 %15, 192
%17 = icmp eq i32 %16, 192
br i1 %17, label %18, label %22
18: ; preds = %12
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i64 4
store i8* %20, i8** %3
%21 = load i8*, i8** %3
store i8* %21, i8** %2
br label %35
22: ; preds = %12
%23 = load i8*, i8** %3
%24 = bitcast i8* %23 to i64*
%25 = load i64, i64* %24
%26 = add nsw i64 %25, 1
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i64 %26
store i8* %28, i8** %3
br label %29
29: ; preds = %22
br label %7
30: ; preds = %7
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i64 1
store i8* %32, i8** %3
br label %33
33: ; preds = %30, %1
%34 = load i8*, i8** %3
store i8* %34, i8** %2
br label %35
35: ; preds = %33, %18
%36 = load i8*, i8** %2
ret i8* %36
}

LLVM IR (-O2):
define i8* @_dns_skip_qname(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %22, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %19, label %6
6: ; preds = %3, %12
%7 = phi i8 [ %17, %12 ], [ %4, %3 ]
%8 = phi i8* [ %16, %12 ], [ %0, %3 ]
%9 = icmp ugt i8 %7, -65
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = getelementptr inbounds i8, i8* %8, i64 4
br label %22
12: ; preds = %6
%13 = bitcast i8* %8 to i64*
%14 = load i64, i64* %13
%15 = add nsw i64 %14, 1
%16 = getelementptr inbounds i8, i8* %8, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %6
19: ; preds = %12, %3
%20 = phi i8* [ %0, %3 ], [ %16, %12 ]
%21 = getelementptr inbounds i8, i8* %20, i64 1
br label %22
22: ; preds = %1, %19, %10
%23 = phi i8* [ %11, %10 ], [ %21, %19 ], [ null, %1 ]
ret i8* %23
}