#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 */
typedef int /*<<< orphan*/ token_buf;

/* Variables and functions */
int /*<<< orphan*/ add_token(char *);
scalar_t__ is_alpha(char);
scalar_t__ is_keyword(char *);
scalar_t__ isdigit(char);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int do_alpha(int cur_first_index, char *readbuf) {
  int cur_index;
  char cur_char;
  char token_buf[80];
  char temp[80 + 8];
  cur_index = cur_first_index;
  while (1) {
    cur_char = readbuf[cur_index];
    if (is_alpha(cur_char) || isdigit(cur_char) || cur_char == '_') {
      cur_index++;
      continue;
    } else
      break;
  }
  memset(token_buf, 0, sizeof(token_buf));
  strncpy(token_buf, &(readbuf[cur_first_index]), cur_index - cur_first_index);
  if (is_keyword(token_buf)) {
    temp[0] = '<';
    strcpy(temp + 1, token_buf);
    strcpy(temp + strlen(token_buf) + 1, ",KEY>");
    add_token(temp);
  } else {
    temp[0] = '<';
    strcpy(temp + 1, token_buf);
    strcpy(temp + strlen(token_buf) + 1, ",IDF>");
    add_token(temp);
  }
  return cur_index;
}


x86 assembly (clang, -O0):
<do_alpha>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x15(%rbp)
movsbl -0x15(%rbp),%edi
call   10a0 <is_alpha@plt>
cmp    $0x0,%rax
jne    11d9 <do_alpha+0x59>
movsbl -0x15(%rbp),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%rax
jne    11d9 <do_alpha+0x59>
movsbl -0x15(%rbp),%eax
cmp    $0x5f,%eax
jne    11e7 <do_alpha+0x67>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1198 <do_alpha+0x18>
jmp    11ec <do_alpha+0x6c>
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1080 <memset@plt>
lea    -0x70(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x4(%rbp),%rax
add    %rax,%rsi
mov    -0x14(%rbp),%edx
sub    -0x4(%rbp),%edx
call   1030 <strncpy@plt>
lea    -0x70(%rbp),%rdi
call   1060 <is_keyword@plt>
cmp    $0x0,%rax
je     1288 <do_alpha+0x108>
movb   $0x3c,-0xd0(%rbp)
lea    -0xd0(%rbp),%rdi
add    $0x1,%rdi
lea    -0x70(%rbp),%rsi
call   1050 <strcpy@plt>
lea    -0xd0(%rbp),%rax
mov    %rax,-0xd8(%rbp)
lea    -0x70(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0xd8(%rbp),%rdi
cltq
add    %rax,%rdi
add    $0x1,%rdi
lea    0xd8e(%rip),%rsi
call   1050 <strcpy@plt>
lea    -0xd0(%rbp),%rdi
call   1090 <add_token@plt>
jmp    12e2 <do_alpha+0x162>
movb   $0x3c,-0xd0(%rbp)
lea    -0xd0(%rbp),%rdi
add    $0x1,%rdi
lea    -0x70(%rbp),%rsi
call   1050 <strcpy@plt>
lea    -0xd0(%rbp),%rax
mov    %rax,-0xe0(%rbp)
lea    -0x70(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0xe0(%rbp),%rdi
cltq
add    %rax,%rdi
add    $0x1,%rdi
lea    0xd35(%rip),%rsi
call   1050 <strcpy@plt>
lea    -0xd0(%rbp),%rdi
call   1090 <add_token@plt>
mov    -0x14(%rbp),%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_alpha>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xb8,%rsp
mov    %edi,%r14d
movslq %edi,%r15
add    %rsi,%r15
xor    %ebp,%ebp
jmp    11a4 <do_alpha+0x24>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbp
movzbl (%r15,%rbp,1),%eax
movsbl %al,%ebx
mov    %ebx,%edi
call   10a0 <is_alpha@plt>
test   %rax,%rax
jne    11a0 <do_alpha+0x20>
mov    %ebx,%edi
call   1040 <isdigit@plt>
cmp    $0x5f,%bl
je     11a0 <do_alpha+0x20>
test   %rax,%rax
jne    11a0 <do_alpha+0x20>
add    %ebp,%r14d
lea    0x60(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1080 <memset@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
call   1060 <is_keyword@plt>
mov    %rax,%rbp
movb   $0x3c,(%rsp)
lea    0x1(%rsp),%rdi
mov    %rbx,%rsi
call   1050 <strcpy@plt>
mov    %rbx,%rdi
call   1070 <strlen@plt>
test   %rbp,%rbp
cltq
lea    0x1(%rsp,%rax,1),%rdi
lea    0xde4(%rip),%rax
lea    0xdd7(%rip),%rsi
cmove  %rax,%rsi
call   1050 <strcpy@plt>
mov    %rsp,%rdi
call   1090 <add_token@plt>
mov    %r14d,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c",KEY>\00"
@.str.1 = [6 x i8] c",IDF>\00"
define i32 @do_alpha(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8
%7 = alloca [80 x i8]
%8 = alloca [88 x i8]
store i32 %0, i32* %3
store i8* %1, i8** %4
%9 = load i32, i32* %3
store i32 %9, i32* %5
br label %10
10: ; preds = %2, %27
%11 = load i8*, i8** %4
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
store i8 %15, i8* %6
%16 = load i8, i8* %6
%17 = call i64 @is_alpha(i8 signext %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %27, label %19
19: ; preds = %10
%20 = load i8, i8* %6
%21 = call i64 @isdigit(i8 signext %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %19
%24 = load i8, i8* %6
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 95
br i1 %26, label %27, label %30
27: ; preds = %23, %19, %10
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %10
30: ; preds = %23
br label %31
31: ; preds = %30
%32 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%33 = call i32 @memset(i8* %32, i32 0, i32 80)
%34 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%35 = load i8*, i8** %4
%36 = load i32, i32* %3
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i32, i32* %5
%40 = load i32, i32* %3
%41 = sub nsw i32 %39, %40
%42 = call i32 @strncpy(i8* %34, i8* %38, i32 %41)
%43 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%44 = call i64 @is_keyword(i8* %43)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %61
46: ; preds = %31
%47 = getelementptr inbounds [88 x i8], [88 x i8]* %8, i64 0, i64 0
store i8 60, i8* %47
%48 = getelementptr inbounds [88 x i8], [88 x i8]* %8, i64 0, i64 0
%49 = getelementptr inbounds i8, i8* %48, i64 1
%50 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%51 = call i32 @strcpy(i8* %49, i8* %50)
%52 = getelementptr inbounds [88 x i8], [88 x i8]* %8, i64 0, i64 0
%53 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%54 = call i32 @strlen(i8* %53)
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %52, i64 %55
%57 = getelementptr inbounds i8, i8* %56, i64 1
%58 = call i32 @strcpy(i8* %57, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%59 = getelementptr inbounds [88 x i8], [88 x i8]* %8, i64 0, i64 0
%60 = call i32 @add_token(i8* %59)
br label %76
61: ; preds = %31
%62 = getelementptr inbounds [88 x i8], [88 x i8]* %8, i64 0, i64 0
store i8 60, i8* %62
%63 = getelementptr inbounds [88 x i8], [88 x i8]* %8, i64 0, i64 0
%64 = getelementptr inbounds i8, i8* %63, i64 1
%65 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%66 = call i32 @strcpy(i8* %64, i8* %65)
%67 = getelementptr inbounds [88 x i8], [88 x i8]* %8, i64 0, i64 0
%68 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%69 = call i32 @strlen(i8* %68)
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %67, i64 %70
%72 = getelementptr inbounds i8, i8* %71, i64 1
%73 = call i32 @strcpy(i8* %72, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%74 = getelementptr inbounds [88 x i8], [88 x i8]* %8, i64 0, i64 0
%75 = call i32 @add_token(i8* %74)
br label %76
76: ; preds = %61, %46
%77 = load i32, i32* %5
ret i32 %77
}

LLVM IR (-O2):
@.str = [6 x i8] c",KEY>\00"
@.str.1 = [6 x i8] c",IDF>\00"
define i32 @do_alpha(i32 %0, i8* %1) {
%3 = alloca [80 x i8]
%4 = alloca [88 x i8]
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [88 x i8], [88 x i8]* %4, i64 0, i64 0
%7 = sext i32 %0 to i64
br label %8
8: ; preds = %19, %2
%9 = phi i64 [ %20, %19 ], [ %7, %2 ]
%10 = getelementptr inbounds i8, i8* %1, i64 %9
%11 = load i8, i8* %10
%12 = tail call i64 @is_alpha(i8 signext %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %8
%15 = tail call i64 @isdigit(i8 signext %11)
%16 = icmp ne i64 %15, 0
%17 = icmp eq i8 %11, 95
%18 = or i1 %17, %16
br i1 %18, label %19, label %21
19: ; preds = %14, %8
%20 = add i64 %9, 1
br label %8
21: ; preds = %14
%22 = trunc i64 %9 to i32
%23 = call i32 @memset(i8* %5, i32 0, i32 80)
%24 = getelementptr inbounds i8, i8* %1, i64 %7
%25 = sub nsw i32 %22, %0
%26 = call i32 @strncpy(i8* %5, i8* %24, i32 %25)
%27 = call i64 @is_keyword(i8* %5)
%28 = icmp eq i64 %27, 0
store i8 60, i8* %6
%29 = getelementptr inbounds [88 x i8], [88 x i8]* %4, i64 0, i64 1
%30 = call i32 @strcpy(i8* %29, i8* %5)
%31 = call i32 @strlen(i8* %5)
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [88 x i8], [88 x i8]* %4, i64 0, i64 %32
%34 = getelementptr inbounds i8, i8* %33, i64 1
%35 = select i1 %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0)
%36 = call i32 @strcpy(i8* %34, i8* %35)
%37 = call i32 @add_token(i8* %6)
ret i32 %22
}