#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 main(void) {
  char c;
  int spaces, lines, other;
  spaces = lines = other = 0;
  printf("Please enter something (ends with #)\n");
  while ((c = getchar()) != '#') {
    if (' ' == c)
      spaces++;
    else if ('\n' == c)
      lines++;
    else
      other++;
  }
  printf("Space: %d\nLine:%d\nOther:%d\n", spaces, lines, other);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0x23,%eax
je     11b9 <main+0x99>
movsbl -0x5(%rbp),%ecx
mov    $0x20,%eax
cmp    %ecx,%eax
jne    1187 <main+0x67>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11b4 <main+0x94>
movsbl -0x5(%rbp),%ecx
mov    $0xa,%eax
cmp    %ecx,%eax
jne    11a6 <main+0x86>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11af <main+0x8f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b4 <main+0x94>
jmp    1152 <main+0x32>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xee1(%rip),%rdi
call   1030 <puts@plt>
xor    %r14d,%r14d
xor    %ebx,%ebx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     1168 <main+0x38>
cmp    $0x23,%al
je     1173 <main+0x43>
cmp    $0x20,%al
je     116d <main+0x3d>
add    $0x1,%ebp
jmp    1150 <main+0x20>
add    $0x1,%ebx
jmp    1150 <main+0x20>
add    $0x1,%r14d
jmp    1150 <main+0x20>
lea    0xe86(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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