#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();
int /*<<< orphan*/ printf(char *, int, int, int);
int main(void) {
  char ch;
  int space = 0, newl = 0, others = 0;
  while ((ch = getchar()) != '#') {
    if (ch == ' ')
      space++;
    else if (ch == '\n')
      newl++;
    else
      others++;
  }
  printf("Space: %d\nNewline: %d\nOthers: %d\n", space, newl, others);
  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)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0x23,%eax
je     11a3 <main+0x83>
movsbl -0x5(%rbp),%eax
cmp    $0x20,%eax
jne    1175 <main+0x55>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    119e <main+0x7e>
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
jne    1190 <main+0x70>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1199 <main+0x79>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119e <main+0x7e>
jmp    1144 <main+0x24>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe4d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %r14d,%r14d
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
je     1148 <main+0x28>
cmp    $0x23,%al
je     1153 <main+0x33>
cmp    $0x20,%al
je     114d <main+0x2d>
add    $0x1,%ebp
jmp    1130 <main+0x10>
add    $0x1,%ebx
jmp    1130 <main+0x10>
add    $0x1,%r14d
jmp    1130 <main+0x10>
lea    0xea6(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Space: %d\0ANewline: %d\0AOthers: %d\0A\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
br label %6
6: ; preds = %28, %0
%7 = call signext i8 (...) @getchar()
store i8 %7, i8* %2
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 35
br i1 %9, label %10, label %29
10: ; preds = %6
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 32
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %28
17: ; preds = %10
%18 = load i8, i8* %2
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 10
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %27
24: ; preds = %17
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %27
27: ; preds = %24, %21
br label %28
28: ; preds = %27, %14
br label %6
29: ; preds = %6
%30 = load i32, i32* %3
%31 = load i32, i32* %4
%32 = load i32, i32* %5
%33 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %30, i32 %31, i32 %32)
ret i32 0
}

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