#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 */
char getchar();
scalar_t__ isalpha(char);
scalar_t__ isdigit(char);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char input;
  int count = 0, alpha = 0, num = 0;
  printf("Enter a word: ");
  while ((input = getchar()) != '\n') {
    count++;
    if (isalpha(input))
      alpha++;
    if (isdigit(input))
      num++;
  }
  printf("\n%d characters including %d letters and %d numbers", count, alpha,
         num);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     11ce <main+0x8e>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
movsbl -0x5(%rbp),%edi
call   1060 <isalpha@plt>
cmp    $0x0,%rax
je     11ad <main+0x6d>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
movsbl -0x5(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11c9 <main+0x89>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1172 <main+0x32>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xeb2(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    $0x0,%ebx
mov    $0x0,%r15d
cmp    $0xa,%al
je     11af <main+0x6f>
xor    %r15d,%r15d
xor    %ebx,%ebx
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r14d
movsbl %al,%ebp
mov    %ebp,%edi
call   1060 <isalpha@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebx
mov    %ebp,%edi
call   1030 <isdigit@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%r15d
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    1180 <main+0x40>
lea    0xe59(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Enter a word: \00"
@.str.1 = [51 x i8] c"\0A%d characters including %d letters and %d numbers\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %27, %0
%8 = call signext i8 (...) @getchar()
store i8 %8, i8* %2
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 10
br i1 %10, label %11, label %28
11: ; preds = %7
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 1
store i32 %13, i32* %3
%14 = load i8, i8* %2
%15 = call i64 @isalpha(i8 signext %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
br label %20
20: ; preds = %17, %11
%21 = load i8, i8* %2
%22 = call i64 @isdigit(i8 signext %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %27
27: ; preds = %24, %20
br label %7
28: ; preds = %7
%29 = load i32, i32* %3
%30 = load i32, i32* %4
%31 = load i32, i32* %5
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i32 %29, i32 %30, i32 %31)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"Enter a word: \00"
@.str.1 = [51 x i8] c"\0A%d characters including %d letters and %d numbers\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%2 = tail call signext i8 (...) @getchar()
%3 = icmp eq i8 %2, 10
br i1 %3, label %20, label %4
4: ; preds = %0, %4
%5 = phi i8 [ %18, %4 ], [ %2, %0 ]
%6 = phi i32 [ %17, %4 ], [ 0, %0 ]
%7 = phi i32 [ %13, %4 ], [ 0, %0 ]
%8 = phi i32 [ %9, %4 ], [ 0, %0 ]
%9 = add nuw nsw i32 %8, 1
%10 = tail call i64 @isalpha(i8 signext %5)
%11 = icmp ne i64 %10, 0
%12 = zext i1 %11 to i32
%13 = add nuw nsw i32 %7, %12
%14 = tail call i64 @isdigit(i8 signext %5)
%15 = icmp ne i64 %14, 0
%16 = zext i1 %15 to i32
%17 = add nuw nsw i32 %6, %16
%18 = tail call signext i8 (...) @getchar()
%19 = icmp eq i8 %18, 10
br i1 %19, label %20, label %4
20: ; preds = %4, %0
%21 = phi i32 [ 0, %0 ], [ %9, %4 ]
%22 = phi i32 [ 0, %0 ], [ %13, %4 ]
%23 = phi i32 [ 0, %0 ], [ %17, %4 ]
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %22, i32 %23)
ret i32 0
}