#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, long);
main() {
  int c;
  long n_spaces, n_tabs, n_lines;
  n_spaces = n_tabs = n_lines = 0;
  while ((c = getchar()) != EOF) {
    if (c == ' ')
      n_spaces++;
    if (c == '\t')
      n_tabs++;
    if (c == '\n')
      n_lines++;
  }
  printf("Spaces: %ld\nTabs: %ld\nLines: %ld\n", n_spaces, n_tabs, n_lines);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e90(%rip),%rcx
cmp    (%rcx),%eax
je     11a7 <main+0x87>
cmpl   $0x20,-0x8(%rbp)
jne    1176 <main+0x56>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x9,-0x8(%rbp)
jne    118c <main+0x6c>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
cmpl   $0xa,-0x8(%rbp)
jne    11a2 <main+0x82>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1147 <main+0x27>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe46(%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    %r14d,%r14d
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eaf(%rip),%r12
cmp    (%r12),%eax
jne    1146 <main+0x26>
xor    %ebx,%ebx
xor    %r15d,%r15d
jmp    117e <main+0x5e>
xor    %r15d,%r15d
xor    %ebx,%ebx
xor    %r14d,%r14d
xchg   %ax,%ax
xor    %ecx,%ecx
cmp    $0x20,%eax
sete   %cl
add    %rcx,%r14
xor    %ecx,%ecx
cmp    $0x9,%eax
sete   %cl
add    %rcx,%rbx
xor    %ecx,%ecx
cmp    $0xa,%eax
sete   %cl
add    %rcx,%r15
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r12),%eax
jne    1150 <main+0x30>
lea    0xe7b(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %r15,%rcx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@EOF = global i32 0
@.str = [34 x i8] c"Spaces: %ld\0ATabs: %ld\0ALines: %ld\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 %21, label %4
4: ; preds = %0, %4
%5 = phi i32 [ %18, %4 ], [ %1, %0 ]
%6 = phi i64 [ %17, %4 ], [ 0, %0 ]
%7 = phi i64 [ %14, %4 ], [ 0, %0 ]
%8 = phi i64 [ %11, %4 ], [ 0, %0 ]
%9 = icmp eq i32 %5, 32
%10 = zext i1 %9 to i64
%11 = add nuw nsw i64 %8, %10
%12 = icmp eq i32 %5, 9
%13 = zext i1 %12 to i64
%14 = add nuw nsw i64 %7, %13
%15 = icmp eq i32 %5, 10
%16 = zext i1 %15 to i64
%17 = add nuw nsw i64 %6, %16
%18 = tail call i32 (...) @getchar()
%19 = load i32, i32* @EOF
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %4
21: ; preds = %4, %0
%22 = phi i64 [ 0, %0 ], [ %11, %4 ]
%23 = phi i64 [ 0, %0 ], [ %14, %4 ]
%24 = phi i64 [ 0, %0 ], [ %17, %4 ]
%25 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i64 %22, i64 %23, i64 %24)
ret i32 0
}