#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*/ isalpha(char);
scalar_t__ isspace(char);
int check_label(char *str) {
  if (!isalpha(*str) && *str != '_')
    return -1;
  while (*str != '\0') {
    if (isspace(*str))
      return -1;
    str++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<check_label>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%eax
jne    115d <check_label+0x3d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     115d <check_label+0x3d>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ac <check_label+0x8c>
jmp    1162 <check_label+0x42>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11a5 <check_label+0x85>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     1194 <check_label+0x74>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ac <check_label+0x8c>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1162 <check_label+0x42>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_label>:
push   %rbx
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1040 <isalpha@plt>
mov    (%rbx),%cl
test   %eax,%eax
je     1138 <check_label+0x18>
test   %cl,%cl
jne    1144 <check_label+0x24>
jmp    1168 <check_label+0x48>
mov    $0xffffffff,%eax
cmp    $0x5f,%cl
mov    $0x5f,%cl
jne    116a <check_label+0x4a>
add    $0x1,%rbx
nopl   0x0(%rax,%rax,1)
movsbl %cl,%edi
call   1030 <isspace@plt>
test   %rax,%rax
jne    116c <check_label+0x4c>
movzbl (%rbx),%ecx
add    $0x1,%rbx
test   %cl,%cl
jne    1150 <check_label+0x30>
xor    %eax,%eax
pop    %rbx
ret
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @check_label(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = load i8, i8* %4
%6 = call i32 @isalpha(i8 signext %5)
%7 = icmp ne i32 %6, 0
br i1 %7, label %14, label %8
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 95
br i1 %12, label %13, label %14
13: ; preds = %8
store i32 -1, i32* %2
br label %30
14: ; preds = %8, %1
br label %15
15: ; preds = %26, %14
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %29
20: ; preds = %15
%21 = load i8*, i8** %3
%22 = load i8, i8* %21
%23 = call i64 @isspace(i8 signext %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %20
store i32 -1, i32* %2
br label %30
26: ; preds = %20
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %3
br label %15
29: ; preds = %15
store i32 0, i32* %2
br label %30
30: ; preds = %29, %25, %13
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
define i32 @check_label(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = tail call i32 @isalpha(i8 signext %2)
%4 = icmp eq i32 %3, 0
%5 = load i8, i8* %0
br i1 %4, label %6, label %8
6: ; preds = %1
%7 = icmp eq i8 %5, 95
br i1 %7, label %10, label %21
8: ; preds = %1
%9 = icmp eq i8 %5, 0
br i1 %9, label %21, label %10
10: ; preds = %6, %8
%11 = phi i8 [ 95, %6 ], [ %5, %8 ]
br label %15
12: ; preds = %15
%13 = load i8, i8* %20
%14 = icmp eq i8 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %10, %12
%16 = phi i8 [ %13, %12 ], [ %11, %10 ]
%17 = phi i8* [ %20, %12 ], [ %0, %10 ]
%18 = tail call i64 @isspace(i8 signext %16)
%19 = icmp eq i64 %18, 0
%20 = getelementptr inbounds i8, i8* %17, i64 1
br i1 %19, label %12, label %21
21: ; preds = %15, %12, %8, %6
%22 = phi i32 [ -1, %6 ], [ 0, %8 ], [ -1, %15 ], [ 0, %12 ]
ret i32 %22
}