#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*/ err_log(int, int, char *, int, char const *);
scalar_t__ isalpha(char const);
int get_field_name(const char **pcursor, const char *query, char *name,
                   int len) {
  const char *cursor = *pcursor;
  if (!isalpha(*cursor))
    return 0;
  while (isalpha(*cursor) || *cursor == '.') {
    if (--len <= 0) {
      {
        err_log(1, 0x00000010, "token length exceeded at offset %d: %s\n",
                cursor - query, query);
      };
      return 0;
    }
    *name++ = *cursor++;
  }
  *pcursor = cursor;
  *name = 0;
  return 1;
}


x86 assembly (clang, -O0):
<get_field_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%rax
jne    1164 <get_field_name+0x44>
movl   $0x0,-0x4(%rbp)
jmp    122c <get_field_name+0x10c>
jmp    1169 <get_field_name+0x49>
mov    -0x30(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isalpha@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x31(%rbp)
jne    1197 <get_field_name+0x77>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
sete   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    11a7 <get_field_name+0x87>
jmp    1213 <get_field_name+0xf3>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jg     11ec <get_field_name+0xcc>
mov    -0x30(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%ecx
mov    -0x18(%rbp),%r8
mov    $0x1,%edi
mov    $0x10,%esi
lea    0xe25(%rip),%rdx
call   1030 <err_log@plt>
movl   $0x0,-0x4(%rbp)
jmp    122c <get_field_name+0x10c>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
jmp    1169 <get_field_name+0x49>
mov    -0x30(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_field_name>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %rdx,%rbx
mov    %rsi,%r13
mov    %rdi,%r12
mov    (%rdi),%r14
movsbl (%r14),%edi
call   1040 <isalpha@plt>
xor    %r15d,%r15d
test   %rax,%rax
je     11bc <get_field_name+0x9c>
mov    %r13,%rax
mov    %r14d,%r13d
mov    %rax,(%rsp)
sub    %eax,%r13d
nopw   0x0(%rax,%rax,1)
movsbl (%r14),%edi
call   1040 <isalpha@plt>
test   %rax,%rax
jne    1174 <get_field_name+0x54>
cmpb   $0x2e,(%r14)
jne    11af <get_field_name+0x8f>
cmp    $0x1,%ebp
jle    1190 <get_field_name+0x70>
add    $0xffffffff,%ebp
movzbl (%r14),%eax
add    $0x1,%r14
mov    %al,(%rbx)
add    $0x1,%rbx
add    $0x1,%r13d
jmp    1160 <get_field_name+0x40>
lea    0xe69(%rip),%rdx
mov    $0x1,%edi
mov    $0x10,%esi
mov    %r13d,%ecx
mov    (%rsp),%r8
call   1030 <err_log@plt>
jmp    11bc <get_field_name+0x9c>
mov    %r14,(%r12)
movb   $0x0,(%rbx)
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c"token length exceeded at offset %d: %s\0A\00"
define i32 @get_field_name(i8** %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
store i8** %0, i8*** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%11 = load i8**, i8*** %6
%12 = load i8*, i8** %11
store i8* %12, i8** %10
%13 = load i8*, i8** %10
%14 = load i8, i8* %13
%15 = call i64 @isalpha(i8 signext %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %4
store i32 0, i32* %5
br label %54
18: ; preds = %4
br label %19
19: ; preds = %44, %18
%20 = load i8*, i8** %10
%21 = load i8, i8* %20
%22 = call i64 @isalpha(i8 signext %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %29, label %24
24: ; preds = %19
%25 = load i8*, i8** %10
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 46
br label %29
29: ; preds = %24, %19
%30 = phi i1 [ true, %19 ], [ %28, %24 ]
br i1 %30, label %31, label %50
31: ; preds = %29
%32 = load i32, i32* %9
%33 = add nsw i32 %32, -1
store i32 %33, i32* %9
%34 = icmp sle i32 %33, 0
br i1 %34, label %35, label %44
35: ; preds = %31
%36 = load i8*, i8** %10
%37 = load i8*, i8** %7
%38 = ptrtoint i8* %36 to i64
%39 = ptrtoint i8* %37 to i64
%40 = sub i64 %38, %39
%41 = trunc i64 %40 to i32
%42 = load i8*, i8** %7
%43 = call i32 @err_log(i32 1, i32 16, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %41, i8* %42)
store i32 0, i32* %5
br label %54
44: ; preds = %31
%45 = load i8*, i8** %10
%46 = getelementptr inbounds i8, i8* %45, i32 1
store i8* %46, i8** %10
%47 = load i8, i8* %45
%48 = load i8*, i8** %8
%49 = getelementptr inbounds i8, i8* %48, i32 1
store i8* %49, i8** %8
store i8 %47, i8* %48
br label %19
50: ; preds = %29
%51 = load i8*, i8** %10
%52 = load i8**, i8*** %6
store i8* %51, i8** %52
%53 = load i8*, i8** %8
store i8 0, i8* %53
store i32 1, i32* %5
br label %54
54: ; preds = %50, %35, %17
%55 = load i32, i32* %5
ret i32 %55
}

LLVM IR (-O2):
@.str = [40 x i8] c"token length exceeded at offset %d: %s\0A\00"
define i32 @get_field_name(i8** nocapture %0, i8* %1, i8* nocapture writeonly %2, i32 %3) {
%5 = load i8*, i8** %0
%6 = load i8, i8* %5
%7 = tail call i64 @isalpha(i8 signext %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %33, label %9
9: ; preds = %4, %27
%10 = phi i8* [ %31, %27 ], [ %2, %4 ]
%11 = phi i32 [ %28, %27 ], [ %3, %4 ]
%12 = phi i8* [ %29, %27 ], [ %5, %4 ]
%13 = load i8, i8* %12
%14 = tail call i64 @isalpha(i8 signext %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %9
%17 = load i8, i8* %12
%18 = icmp eq i8 %17, 46
br i1 %18, label %19, label %32
19: ; preds = %9, %16
%20 = icmp slt i32 %11, 2
br i1 %20, label %21, label %27
21: ; preds = %19
%22 = ptrtoint i8* %12 to i64
%23 = ptrtoint i8* %1 to i64
%24 = sub i64 %22, %23
%25 = trunc i64 %24 to i32
%26 = tail call i32 @err_log(i32 1, i32 16, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %25, i8* %1)
br label %33
27: ; preds = %19
%28 = add nsw i32 %11, -1
%29 = getelementptr inbounds i8, i8* %12, i64 1
%30 = load i8, i8* %12
%31 = getelementptr inbounds i8, i8* %10, i64 1
store i8 %30, i8* %10
br label %9
32: ; preds = %16
store i8* %12, i8** %0
store i8 0, i8* %10
br label %33
33: ; preds = %4, %32, %21
%34 = phi i32 [ 0, %21 ], [ 1, %32 ], [ 0, %4 ]
ret i32 %34
}