#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__ isdigit(char const);
scalar_t__ islower(char const);
size_t read_identifier(const char *s, size_t pos, size_t len) {
  while (islower(s[pos]) || isdigit(s[pos]) || s[pos] == '_') {
    if (++pos >= len) {
      pos = len + 1;
      break;
    }
  }
  return pos;
}


x86 assembly (clang, -O0):
<read_identifier>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <islower@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x19(%rbp)
jne    118f <read_identifier+0x6f>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x19(%rbp)
jne    118f <read_identifier+0x6f>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5f,%eax
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    119f <read_identifier+0x7f>
jmp    11cb <read_identifier+0xab>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
cmp    -0x18(%rbp),%rax
jb     11c6 <read_identifier+0xa6>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11cb <read_identifier+0xab>
jmp    1134 <read_identifier+0x14>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_identifier>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
jmp    1139 <read_identifier+0x19>
add    $0x1,%rbx
cmp    %r14,%rbx
jae    1160 <read_identifier+0x40>
movsbl (%r15,%rbx,1),%edi
call   1040 <islower@plt>
test   %rax,%rax
jne    1130 <read_identifier+0x10>
movsbl (%r15,%rbx,1),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1130 <read_identifier+0x10>
cmpb   $0x5f,(%r15,%rbx,1)
je     1130 <read_identifier+0x10>
jmp    1167 <read_identifier+0x47>
add    $0x1,%r14
mov    %r14,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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