#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 const);
int /*<<< orphan*/ isspace(char const);
int /*<<< orphan*/ *strchr(char *, char const);
unsigned SymbolLength(const char *string) {
  const char *stringPtr = string;
  if (strchr("#_-", *stringPtr) || isalnum(*stringPtr)) {
    stringPtr++;
    while (*stringPtr && !isspace(*stringPtr) &&
           strchr("()\"", *stringPtr) == NULL)
      stringPtr++;
  }
  return (unsigned)(stringPtr - string);
}


x86 assembly (clang, -O0):
<SymbolLength>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
lea    0xeb1(%rip),%rdi
movsbl (%rax),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
jne    1177 <SymbolLength+0x47>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isalnum@plt>
cmp    $0x0,%rax
je     11f7 <SymbolLength+0xc7>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     11d1 <SymbolLength+0xa1>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isspace@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
jne    11d1 <SymbolLength+0xa1>
mov    -0x10(%rbp),%rax
lea    0xe45(%rip),%rdi
movsbl (%rax),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    11e1 <SymbolLength+0xb1>
jmp    11f2 <SymbolLength+0xc2>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1183 <SymbolLength+0x53>
jmp    11f7 <SymbolLength+0xc7>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SymbolLength>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
movsbl (%rdi),%esi
lea    0xebe(%rip),%rdi
call   1030 <strchr@plt>
test   %rax,%rax
jne    115d <SymbolLength+0x2d>
movsbl (%r14),%edi
call   1040 <isalnum@plt>
mov    %r14,%rbx
test   %rax,%rax
je     119a <SymbolLength+0x6a>
lea    0x1(%r14),%rcx
lea    0xe9c(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %rcx,%rbx
movzbl (%rcx),%eax
test   %al,%al
je     119a <SymbolLength+0x6a>
movsbl %al,%edi
call   1050 <isspace@plt>
test   %eax,%eax
jne    119a <SymbolLength+0x6a>
movsbl (%rbx),%esi
mov    %r15,%rdi
call   1030 <strchr@plt>
lea    0x1(%rbx),%rcx
test   %rax,%rax
je     1170 <SymbolLength+0x40>
sub    %r14d,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"#_-\00"
@.str.1 = [4 x i8] c"()\22\00"
define i32 @SymbolLength(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
store i8* %4, i8** %3
%5 = load i8*, i8** %3
%6 = load i8, i8* %5
%7 = call i32* @strchr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %6)
%8 = icmp ne i32* %7, null
br i1 %8, label %14, label %9
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = call i64 @isalnum(i8 signext %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %38
14: ; preds = %9, %1
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %3
br label %17
17: ; preds = %34, %14
%18 = load i8*, i8** %3
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %32
22: ; preds = %17
%23 = load i8*, i8** %3
%24 = load i8, i8* %23
%25 = call i32 @isspace(i8 signext %24)
%26 = icmp ne i32 %25, 0
br i1 %26, label %32, label %27
27: ; preds = %22
%28 = load i8*, i8** %3
%29 = load i8, i8* %28
%30 = call i32* @strchr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8 signext %29)
%31 = icmp eq i32* %30, null
br label %32
32: ; preds = %27, %22, %17
%33 = phi i1 [ false, %22 ], [ false, %17 ], [ %31, %27 ]
br i1 %33, label %34, label %37
34: ; preds = %32
%35 = load i8*, i8** %3
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %3
br label %17
37: ; preds = %32
br label %38
38: ; preds = %37, %9
%39 = load i8*, i8** %3
%40 = load i8*, i8** %2
%41 = ptrtoint i8* %39 to i64
%42 = ptrtoint i8* %40 to i64
%43 = sub i64 %41, %42
%44 = trunc i64 %43 to i32
ret i32 %44
}

LLVM IR (-O2):
@.str = [4 x i8] c"#_-\00"
@.str.1 = [4 x i8] c"()\22\00"
define i32 @SymbolLength(i8* %0) {
%2 = load i8, i8* %0
%3 = tail call i32* @strchr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %2)
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = load i8, i8* %0
%7 = tail call i64 @isalnum(i8 signext %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %22, label %9
9: ; preds = %5, %1
br label %10
10: ; preds = %9, %18
%11 = phi i8* [ %12, %18 ], [ %0, %9 ]
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %22, label %15
15: ; preds = %10
%16 = tail call i32 @isspace(i8 signext %13)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i8, i8* %12
%20 = tail call i32* @strchr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8 signext %19)
%21 = icmp eq i32* %20, null
br i1 %21, label %10, label %22
22: ; preds = %18, %15, %10, %5
%23 = phi i8* [ %0, %5 ], [ %12, %10 ], [ %12, %15 ], [ %12, %18 ]
%24 = ptrtoint i8* %23 to i64
%25 = ptrtoint i8* %0 to i64
%26 = sub i64 %24, %25
%27 = trunc i64 %26 to i32
ret i32 %27
}