#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*/ gets(char *);
scalar_t__ isalpha(char);
int /*<<< orphan*/ isdigit(char);
int /*<<< orphan*/ printf(char *);
int main() {
  char a[10];
  int flag, i = 1;
  printf("\n Enter an identifier:\n");
  gets(a);
  if (isalpha(a[0]))
    flag = 1;
  else
    printf("\n Not a valid identifier\n");
  while (a[i] != '\0') {
    if (!isdigit(a[i]) && !isalpha(a[i])) {
      flag = 0;
      break;
    }
    i++;
  }
  if (flag == 1)
    printf("Valid identifier\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x18(%rbp)
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
lea    -0xe(%rbp),%rdi
call   1050 <gets@plt>
movsbl -0xe(%rbp),%edi
call   1060 <isalpha@plt>
cmp    $0x0,%rax
je     118a <main+0x4a>
movl   $0x1,-0x14(%rbp)
jmp    1196 <main+0x56>
lea    0xe87(%rip),%rdi
call   1040 <printf@plt>
jmp    119b <main+0x5b>
movslq -0x18(%rbp),%rax
movsbl -0xe(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11f6 <main+0xb6>
movslq -0x18(%rbp),%rax
movsbl -0xe(%rbp,%rax,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11e8 <main+0xa8>
movslq -0x18(%rbp),%rax
movsbl -0xe(%rbp,%rax,1),%edi
call   1060 <isalpha@plt>
cmp    $0x0,%rax
jne    11e8 <main+0xa8>
movl   $0x0,-0x14(%rbp)
jmp    11f6 <main+0xb6>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    119b <main+0x5b>
cmpl   $0x1,-0x14(%rbp)
jne    120c <main+0xcc>
lea    0xe2b(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
call   1040 <puts@plt>
lea    0x6(%rsp),%rdi
call   1050 <gets@plt>
movsbl 0x6(%rsp),%edi
call   1060 <isalpha@plt>
test   %rax,%rax
jne    1176 <main+0x36>
lea    0xea6(%rip),%rdi
call   1040 <puts@plt>
mov    0x7(%rsp),%al
test   %al,%al
je     11b7 <main+0x77>
lea    0x8(%rsp),%rbx
jmp    119b <main+0x5b>
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11b7 <main+0x77>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
jne    1190 <main+0x50>
movsbl -0x1(%rbx),%edi
call   1060 <isalpha@plt>
test   %rax,%rax
jne    1190 <main+0x50>
jmp    11c3 <main+0x83>
lea    0xe72(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"\0A Enter an identifier:\0A\00"
@.str.1 = [26 x i8] c"\0A Not a valid identifier\0A\00"
@.str.2 = [18 x i8] c"Valid identifier\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %4
%5 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%7 = call i32 @gets(i8* %6)
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%9 = load i8, i8* %8
%10 = call i64 @isalpha(i8 signext %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %0
store i32 1, i32* %3
br label %15
13: ; preds = %0
%14 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %12
br label %16
16: ; preds = %38, %15
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, 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 %41
23: ; preds = %16
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = call i32 @isdigit(i8 signext %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %38, label %30
30: ; preds = %23
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = call i64 @isalpha(i8 signext %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %38, label %37
37: ; preds = %30
store i32 0, i32* %3
br label %41
38: ; preds = %30, %23
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
br label %16
41: ; preds = %37, %16
%42 = load i32, i32* %3
%43 = icmp eq i32 %42, 1
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %46
46: ; preds = %44, %41
ret i32 0
}

LLVM IR (-O2):
@str = [23 x i8] c"\0A Enter an identifier:\00"
@str.3 = [25 x i8] c"\0A Not a valid identifier\00"
@str.4 = [17 x i8] c"Valid identifier\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%4 = call i32 @gets(i8* %2)
%5 = load i8, i8* %2
%6 = call i64 @isalpha(i8 signext %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.3, i64 0, i64 0))
br label %10
10: ; preds = %0, %8
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %29, label %14
14: ; preds = %10, %24
%15 = phi i64 [ %25, %24 ], [ 1, %10 ]
%16 = phi i8 [ %27, %24 ], [ %12, %10 ]
%17 = phi i8* [ %26, %24 ], [ %11, %10 ]
%18 = call i32 @isdigit(i8 signext %16)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %14
%21 = load i8, i8* %17
%22 = call i64 @isalpha(i8 signext %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %31, label %24
24: ; preds = %20, %14
%25 = add nuw i64 %15, 1
%26 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 0
br i1 %28, label %29, label %14
29: ; preds = %24, %10
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.4, i64 0, i64 0))
br label %31
31: ; preds = %20, %29
ret i32 0
}