#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__ is_literal_char(char const);
int /*<<< orphan*/ isalpha(char const);
size_t get_literal_length(const char *literal) {
  if (!isalpha(*literal) || *literal == '_')
    return 0;
  size_t len;
  for (len = 1; literal[len] && is_literal_char(literal[len]); ++len)
    ;
  return len;
}


x86 assembly (clang, -O0):
<get_literal_length>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%eax
je     1151 <get_literal_length+0x31>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
jne    115e <get_literal_length+0x3e>
movq   $0x0,-0x8(%rbp)
jmp    11c9 <get_literal_length+0xa9>
movq   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     119b <get_literal_length+0x7b>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <is_literal_char@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11ab <get_literal_length+0x8b>
jmp    11c1 <get_literal_length+0xa1>
jmp    11b0 <get_literal_length+0x90>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1166 <get_literal_length+0x46>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_literal_length>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
movsbl (%rdi),%edi
call   1040 <isalpha@plt>
test   %eax,%eax
je     1139 <get_literal_length+0x19>
cmpb   $0x5f,(%r14)
jne    1146 <get_literal_length+0x26>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x1(%r14),%al
mov    $0x1,%ebx
test   %al,%al
je     113b <get_literal_length+0x1b>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl %al,%edi
call   1030 <is_literal_char@plt>
test   %rax,%rax
je     113b <get_literal_length+0x1b>
movzbl 0x1(%r14,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1160 <get_literal_length+0x40>
jmp    113b <get_literal_length+0x1b>

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

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