#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 EOF;
int getchar();
int /*<<< orphan*/ printf(char *, long, long);
int main() {
  int c;
  long total = 0, whitespace = 0;
  while ((c = getchar()) != EOF) {
    if (c == '\n' || c == '\t' || c == ' ') {
      whitespace++;
    }
    total++;
  }
  printf("%ld whitespaces, %ld characters.\n", whitespace, total);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e98(%rip),%rcx
cmp    (%rcx),%eax
je     1193 <main+0x73>
cmpl   $0xa,-0x8(%rbp)
je     1176 <main+0x56>
cmpl   $0x9,-0x8(%rbp)
je     1176 <main+0x56>
cmpl   $0x20,-0x8(%rbp)
jne    1182 <main+0x62>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    113f <main+0x1f>
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe5e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb0(%rip),%r15
cmp    (%r15),%eax
jne    1160 <main+0x40>
xor    %r14d,%r14d
lea    0xeb9(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
movabs $0x100000600,%r12
xor    %r14d,%r14d
xor    %ebx,%ebx
jmp    1190 <main+0x70>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r15),%eax
je     1140 <main+0x20>
cmp    $0x20,%eax
ja     1180 <main+0x60>
mov    %eax,%eax
bt     %rax,%r12
jae    1180 <main+0x60>
add    $0x1,%r14
jmp    1180 <main+0x60>

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

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