#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 getchar();
int /*<<< orphan*/ printf(char *, int);
int main() {
  int char_count = 0;
  char read_character;
  while ((read_character = getchar()) != EOF) {
    if (!(read_character == '\n' || read_character == ' ')) {
      char_count++;
    }
  }
  printf("\nThe number of characters read: %d\n", char_count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x9(%rbp)
movsbl %al,%eax
mov    0x2e9e(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     117d <main+0x5d>
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
je     1178 <main+0x58>
movsbl -0x9(%rbp),%eax
cmp    $0x20,%eax
je     1178 <main+0x58>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1136 <main+0x16>
mov    -0x8(%rbp),%esi
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb4(%rip),%r14
cmp    (%r14),%al
jne    1151 <main+0x31>
lea    0xec0(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %ebx,%ebx
jmp    116c <main+0x4c>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r14),%al
je     1139 <main+0x19>
cmp    $0xa,%al
je     1160 <main+0x40>
cmp    $0x20,%al
je     1160 <main+0x40>
add    $0x1,%ebx
jmp    1160 <main+0x40>

LLVM IR (-O0):
@EOF = global i8 0
@.str = [36 x i8] c"\0AThe number of characters read: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %2
br label %4
4: ; preds = %21, %0
%5 = call signext i8 (...) @getchar()
store i8 %5, i8* %3
%6 = sext i8 %5 to i32
%7 = load i8, i8* @EOF
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %6, %8
br i1 %9, label %10, label %22
10: ; preds = %4
%11 = load i8, i8* %3
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 10
br i1 %13, label %21, label %14
14: ; preds = %10
%15 = load i8, i8* %3
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 32
br i1 %17, label %21, label %18
18: ; preds = %14
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 1
store i32 %20, i32* %2
br label %21
21: ; preds = %18, %14, %10
br label %4
22: ; preds = %4
%23 = load i32, i32* %2
%24 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %23)
ret i32 0
}

LLVM IR (-O2):
@EOF = global i8 0
@.str = [36 x i8] c"\0AThe number of characters read: %d\0A\00"
define i32 @main() {
%1 = tail call signext i8 (...) @getchar()
%2 = load i8, i8* @EOF
%3 = icmp eq i8 %1, %2
br i1 %3, label %14, label %4
4: ; preds = %0, %9
%5 = phi i8 [ %11, %9 ], [ %1, %0 ]
%6 = phi i32 [ %10, %9 ], [ 0, %0 ]
switch i8 %5, label %7 [
i8 32, label %9
i8 10, label %9
]
7: ; preds = %4
%8 = add nsw i32 %6, 1
br label %9
9: ; preds = %4, %4, %7
%10 = phi i32 [ %6, %4 ], [ %8, %7 ], [ %6, %4 ]
%11 = tail call signext i8 (...) @getchar()
%12 = load i8, i8* @EOF
%13 = icmp eq i8 %11, %12
br i1 %13, label %14, label %4
14: ; preds = %9, %0
%15 = phi i32 [ 0, %0 ], [ %10, %9 ]
%16 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %15)
ret i32 0
}