#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__ isalpha(char);
scalar_t__ isdigit(char);
scalar_t__ isin(char *, int);
char nextChar();
int /*<<< orphan*/ printf(char *, char *);
char alphaprocess(char ch) {
  char buffer[1024];
  int bufPtr = 0;
  while (isalpha(ch) || isdigit(ch) || '_' == ch) {
    buffer[bufPtr++] = ch;
    ch = nextChar();
  }
  buffer[bufPtr] = '\0';
  if (isin(buffer, 1)) {
    printf("(1, \"%s\")\n", buffer);
  } else {
    printf("(2, \"%s\")\n", buffer);
  }
  return ch;
}


x86 assembly (clang, -O0):
<alphaprocess>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movl   $0x0,-0x414(%rbp)
movsbl -0x1(%rbp),%edi
call   1060 <isalpha@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x415(%rbp)
jne    11bb <alphaprocess+0x6b>
movsbl -0x1(%rbp),%edi
call   1030 <isdigit@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x415(%rbp)
jne    11bb <alphaprocess+0x6b>
movsbl -0x1(%rbp),%ecx
mov    $0x5f,%eax
cmp    %ecx,%eax
sete   %al
mov    %al,-0x415(%rbp)
mov    -0x415(%rbp),%al
test   $0x1,%al
jne    11ce <alphaprocess+0x7e>
jmp    11fa <alphaprocess+0xaa>
mov    -0x1(%rbp),%cl
mov    -0x414(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x414(%rbp)
cltq
mov    %cl,-0x410(%rbp,%rax,1)
mov    $0x0,%al
call   1040 <nextChar@plt>
mov    %al,-0x1(%rbp)
jmp    116b <alphaprocess+0x1b>
movslq -0x414(%rbp),%rax
movb   $0x0,-0x410(%rbp,%rax,1)
lea    -0x410(%rbp),%rdi
mov    $0x1,%esi
call   1070 <isin@plt>
cmp    $0x0,%rax
je     123c <alphaprocess+0xec>
lea    -0x410(%rbp),%rsi
lea    0xdce(%rip),%rdi
call   1050 <printf@plt>
jmp    124f <alphaprocess+0xff>
lea    -0x410(%rbp),%rsi
lea    0xdc1(%rip),%rdi
call   1050 <printf@plt>
movsbl -0x1(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alphaprocess>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %edi,%r14d
xor    %ebx,%ebx
jmp    1182 <alphaprocess+0x32>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14b,(%rsp,%rbx,1)
add    $0x1,%rbx
xor    %eax,%eax
call   1040 <nextChar@plt>
mov    %eax,%r14d
movsbl %r14b,%ebp
mov    %ebp,%edi
call   1060 <isalpha@plt>
test   %rax,%rax
jne    1170 <alphaprocess+0x20>
mov    %ebp,%edi
call   1030 <isdigit@plt>
cmp    $0x5f,%bpl
je     1170 <alphaprocess+0x20>
test   %rax,%rax
jne    1170 <alphaprocess+0x20>
mov    %ebx,%eax
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    $0x1,%esi
call   1070 <isin@plt>
test   %rax,%rax
lea    0xe47(%rip),%rax
lea    0xe35(%rip),%rdi
cmove  %rax,%rdi
mov    %rbp,%rsi
call   1050 <printf@plt>
mov    %r14d,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [11 x i8] c"(1, \22%s\22)\0A\00"
@.str.1 = [11 x i8] c"(2, \22%s\22)\0A\00"
define signext i8 @alphaprocess(i8 signext %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %14, %1
%5 = phi i64 [ %15, %14 ], [ 0, %1 ]
%6 = phi i8 [ %17, %14 ], [ %0, %1 ]
%7 = tail call i64 @isalpha(i8 signext %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %4
%10 = tail call i64 @isdigit(i8 signext %6)
%11 = icmp ne i64 %10, 0
%12 = icmp eq i8 %6, 95
%13 = or i1 %12, %11
br i1 %13, label %14, label %18
14: ; preds = %4, %9
%15 = add nuw i64 %5, 1
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %5
store i8 %6, i8* %16
%17 = tail call signext i8 (...) @nextChar()
br label %4
18: ; preds = %9
%19 = and i64 %5, 4294967295
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %19
store i8 0, i8* %20
%21 = call i64 @isin(i8* %3, i32 1)
%22 = icmp eq i64 %21, 0
%23 = select i1 %22, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0)
%24 = call i32 @printf(i8* %23, i8* %3)
ret i8 %6
}