#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 */
scalar_t__ isalnum(char);
scalar_t__ isalpha(char);
int valid_symbol(char *tkn) {
  if (!tkn || !(isalpha(*tkn) || (*tkn) == '_'))
    return 0;
  for (++tkn; *tkn; ++tkn)
    if (!(isalnum(*tkn) || (*tkn) == '_'))
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<valid_symbol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     115d <valid_symbol+0x3d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%rax
jne    1169 <valid_symbol+0x49>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     1169 <valid_symbol+0x49>
movl   $0x0,-0x4(%rbp)
jmp    11d1 <valid_symbol+0xb1>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11ca <valid_symbol+0xaa>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%rax
jne    11b4 <valid_symbol+0x94>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     11b4 <valid_symbol+0x94>
movl   $0x0,-0x4(%rbp)
jmp    11d1 <valid_symbol+0xb1>
jmp    11b9 <valid_symbol+0x99>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1175 <valid_symbol+0x55>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<valid_symbol>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
test   %rdi,%rdi
je     1175 <valid_symbol+0x55>
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1040 <isalpha@plt>
test   %rax,%rax
jne    113f <valid_symbol+0x1f>
cmpb   $0x5f,(%rbx)
jne    1175 <valid_symbol+0x55>
mov    0x1(%rbx),%al
test   %al,%al
je     1170 <valid_symbol+0x50>
add    $0x2,%rbx
jmp    115b <valid_symbol+0x3b>
nopl   0x0(%rax)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1170 <valid_symbol+0x50>
movsbl %al,%edi
call   1030 <isalnum@plt>
test   %rax,%rax
jne    1150 <valid_symbol+0x30>
cmpb   $0x5f,-0x1(%rbx)
je     1150 <valid_symbol+0x30>
jmp    1175 <valid_symbol+0x55>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @valid_symbol(i8* %0) {
%2 = alloca i32
%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 %16
6: ; preds = %1
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = call i64 @isalpha(i8 signext %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %6
%12 = load i8*, i8** %3
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 95
br i1 %15, label %17, label %16
16: ; preds = %11, %1
store i32 0, i32* %2
br label %40
17: ; preds = %11, %6
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %3
br label %20
20: ; preds = %36, %17
%21 = load i8*, i8** %3
%22 = load i8, i8* %21
%23 = icmp ne i8 %22, 0
br i1 %23, label %24, label %39
24: ; preds = %20
%25 = load i8*, i8** %3
%26 = load i8, i8* %25
%27 = call i64 @isalnum(i8 signext %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %35, label %29
29: ; preds = %24
%30 = load i8*, i8** %3
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 95
br i1 %33, label %35, label %34
34: ; preds = %29
store i32 0, i32* %2
br label %40
35: ; preds = %29, %24
br label %36
36: ; preds = %35
%37 = load i8*, i8** %3
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %3
br label %20
39: ; preds = %20
store i32 1, i32* %2
br label %40
40: ; preds = %39, %34, %16
%41 = load i32, i32* %2
ret i32 %41
}

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