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

/* Variables and functions */
scalar_t__ get_label_len(int /*<<< orphan*/ const *);
scalar_t__ label_isend(int /*<<< orphan*/ const *);
scalar_t__ label_ispointer(int /*<<< orphan*/ const *);
scalar_t__ label_isstr(int /*<<< orphan*/ const *);
const uint8_t *skip_labels(const uint8_t *label) {
  int label_end;
  label_end = 0;
  while (!label_end) {
    if (label_isend(label)) {
      label++;
      label_end = 1;
    } else if (label_ispointer(label)) {
      label += 2;
      label_end = 1;
    } else if (label_isstr(label)) {
      label += get_label_len(label) + 1;
    } else {
      label = NULL;
      label_end = 1;
    }
  }
  return label;
}


x86 assembly (clang, -O0):
<skip_labels>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1169 <skip_labels+0x29>
jmp    120e <skip_labels+0xce>
mov    -0x8(%rbp),%rdi
call   1040 <label_isend@plt>
cmp    $0x0,%rax
je     1194 <skip_labels+0x54>
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
jmp    1209 <skip_labels+0xc9>
mov    -0x8(%rbp),%rdi
call   1060 <label_ispointer@plt>
cmp    $0x0,%rax
je     11bf <skip_labels+0x7f>
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
jmp    1204 <skip_labels+0xc4>
mov    -0x8(%rbp),%rdi
call   1030 <label_isstr@plt>
cmp    $0x0,%rax
je     11f0 <skip_labels+0xb0>
mov    -0x8(%rbp),%rdi
call   1050 <get_label_len@plt>
add    $0x1,%rax
shl    $0x2,%rax
add    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ff <skip_labels+0xbf>
movq   $0x0,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
jmp    1204 <skip_labels+0xc4>
jmp    1209 <skip_labels+0xc9>
jmp    1153 <skip_labels+0x13>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skip_labels>:
push   %rbx
mov    %rdi,%rbx
call   1040 <label_isend@plt>
test   %rax,%rax
jne    117d <skip_labels+0x3d>
mov    %rbx,%rdi
call   1060 <label_ispointer@plt>
test   %rax,%rax
jne    1186 <skip_labels+0x46>
mov    %rbx,%rdi
call   1030 <label_isstr@plt>
test   %rax,%rax
je     118c <skip_labels+0x4c>
mov    %rbx,%rdi
call   1050 <get_label_len@plt>
lea    (%rbx,%rax,4),%rbx
add    $0x4,%rbx
mov    %rbx,%rdi
jmp    1144 <skip_labels+0x4>
add    $0x4,%rbx
mov    %rbx,%rax
pop    %rbx
ret
add    $0x8,%rbx
jmp    1181 <skip_labels+0x41>
xor    %ebx,%ebx
jmp    1181 <skip_labels+0x41>

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

LLVM IR (-O2):
define i32* @skip_labels(i32* %0) {
%2 = tail call i64 @label_isend(i32* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %16, %1
%5 = phi i32* [ %0, %1 ], [ %19, %16 ]
%6 = getelementptr inbounds i32, i32* %5, i64 1
br label %22
7: ; preds = %1, %16
%8 = phi i32* [ %19, %16 ], [ %0, %1 ]
%9 = tail call i64 @label_ispointer(i32* %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = getelementptr inbounds i32, i32* %8, i64 2
br label %22
13: ; preds = %7
%14 = tail call i64 @label_isstr(i32* %8)
%15 = icmp eq i64 %14, 0
br i1 %15, label %22, label %16
16: ; preds = %13
%17 = tail call i64 @get_label_len(i32* %8)
%18 = add nsw i64 %17, 1
%19 = getelementptr inbounds i32, i32* %8, i64 %18
%20 = tail call i64 @label_isend(i32* %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %7, label %4
22: ; preds = %13, %4, %11
%23 = phi i32* [ %12, %11 ], [ %6, %4 ], [ null, %13 ]
ret i32* %23
}