#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 EOF;
char fgetc(int /*<<< orphan*/);
scalar_t__ isalnum(char);
scalar_t__ isspace(char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  unsigned int c_count, s_count;
  char c;
  c_count = s_count = 0;
  while ((c = fgetc(stdin)) != EOF) {
    if (isalnum(c))
      ++c_count;
    else if (isspace(c))
      ++s_count;
    else {
      printf("ERROR: Invalid character\n");
      return 1;
    }
  }
  if (c_count == 0 && s_count == 0) {
    printf("ERROR: No input entered\n");
    return 1;
  }
  printf("Alphanumeric: %d\nWhitespace: %d\n", c_count, s_count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
call   1050 <fgetc@plt>
mov    %al,-0x19(%rbp)
movsbl %al,%eax
mov    0x2e61(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11f0 <main+0xb0>
movsbl -0x19(%rbp),%edi
call   1040 <isalnum@plt>
cmp    $0x0,%rax
je     11ab <main+0x6b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11eb <main+0xab>
movsbl -0x19(%rbp),%edi
call   1060 <isspace@plt>
cmp    $0x0,%rax
je     11cc <main+0x8c>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e6 <main+0xa6>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1239 <main+0xf9>
jmp    11eb <main+0xab>
jmp    1164 <main+0x24>
cmpl   $0x0,-0x14(%rbp)
jne    121e <main+0xde>
cmpl   $0x0,-0x18(%rbp)
jne    121e <main+0xde>
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1239 <main+0xf9>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    0x2e89(%rip),%r14
mov    (%r14),%edi
call   1060 <fgetc@plt>
mov    0x2e72(%rip),%r12
xor    %ebp,%ebp
mov    $0x0,%r15d
cmp    (%r12),%al
jne    118c <main+0x3c>
mov    %ebp,%eax
or     %r15d,%eax
jne    11d2 <main+0x82>
lea    0xe97(%rip),%rdi
jmp    11f1 <main+0xa1>
xor    %r15d,%r15d
xor    %ebp,%ebp
jmp    11b1 <main+0x61>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%ebp
mov    (%r14),%edi
call   1060 <fgetc@plt>
cmp    (%r12),%al
je     117c <main+0x2c>
movsbl %al,%ebx
mov    %ebx,%edi
call   1050 <isalnum@plt>
test   %rax,%rax
jne    11a0 <main+0x50>
mov    %ebx,%edi
call   1070 <isspace@plt>
test   %rax,%rax
je     11ea <main+0x9a>
add    $0x1,%r15d
jmp    11a3 <main+0x53>
lea    0xe27(%rip),%rdi
xor    %r14d,%r14d
mov    %ebp,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11fc <main+0xac>
lea    0xe48(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@EOF = global i8 0
@.str = [26 x i8] c"ERROR: Invalid character\0A\00"
@.str.1 = [25 x i8] c"ERROR: No input entered\0A\00"
@.str.2 = [33 x i8] c"Alphanumeric: %d\0AWhitespace: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %6
br label %9
9: ; preds = %33, %2
%10 = load i32, i32* @stdin
%11 = call signext i8 @fgetc(i32 %10)
store i8 %11, i8* %8
%12 = sext i8 %11 to i32
%13 = load i8, i8* @EOF
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %12, %14
br i1 %15, label %16, label %34
16: ; preds = %9
%17 = load i8, i8* %8
%18 = call i64 @isalnum(i8 signext %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = load i32, i32* %6
%22 = add i32 %21, 1
store i32 %22, i32* %6
br label %33
23: ; preds = %16
%24 = load i8, i8* %8
%25 = call i64 @isspace(i8 signext %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i32, i32* %7
%29 = add i32 %28, 1
store i32 %29, i32* %7
br label %32
30: ; preds = %23
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %46
32: ; preds = %27
br label %33
33: ; preds = %32, %20
br label %9
34: ; preds = %9
%35 = load i32, i32* %6
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %42
37: ; preds = %34
%38 = load i32, i32* %7
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %46
42: ; preds = %37, %34
%43 = load i32, i32* %6
%44 = load i32, i32* %7
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %43, i32 %44)
store i32 0, i32* %3
br label %46
46: ; preds = %42, %40, %30
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@stdin = global i32 0
@EOF = global i8 0
@.str.2 = [33 x i8] c"Alphanumeric: %d\0AWhitespace: %d\0A\00"
@str = [24 x i8] c"ERROR: No input entered\00"
@str.3 = [25 x i8] c"ERROR: Invalid character\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @stdin
%4 = tail call signext i8 @fgetc(i32 %3)
%5 = load i8, i8* @EOF
%6 = icmp eq i8 %4, %5
br i1 %6, label %29, label %7
7: ; preds = %2, %22
%8 = phi i8 [ %26, %22 ], [ %4, %2 ]
%9 = phi i32 [ %24, %22 ], [ 0, %2 ]
%10 = phi i32 [ %23, %22 ], [ 0, %2 ]
%11 = tail call i64 @isalnum(i8 signext %8)
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %7
%14 = add i32 %10, 1
br label %22
15: ; preds = %7
%16 = tail call i64 @isspace(i8 signext %8)
%17 = icmp eq i64 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = add i32 %9, 1
br label %22
20: ; preds = %15
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.3, i64 0, i64 0))
br label %39
22: ; preds = %18, %13
%23 = phi i32 [ %14, %13 ], [ %10, %18 ]
%24 = phi i32 [ %9, %13 ], [ %19, %18 ]
%25 = load i32, i32* @stdin
%26 = tail call signext i8 @fgetc(i32 %25)
%27 = load i8, i8* @EOF
%28 = icmp eq i8 %26, %27
br i1 %28, label %29, label %7
29: ; preds = %22, %2
%30 = phi i32 [ 0, %2 ], [ %23, %22 ]
%31 = phi i32 [ 0, %2 ], [ %24, %22 ]
%32 = icmp eq i32 %30, 0
%33 = icmp eq i32 %31, 0
%34 = select i1 %32, i1 %33, i1 false
br i1 %34, label %35, label %37
35: ; preds = %29
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
br label %39
37: ; preds = %29
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %30, i32 %31)
br label %39
39: ; preds = %37, %35, %20
%40 = phi i32 [ 1, %20 ], [ 1, %35 ], [ 0, %37 ]
ret i32 %40
}