#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();
scalar_t__ isupper(char);
int /*<<< orphan*/ putchar(char);
int symbol_filter() {
  char input_symbol = -1;
  int previous_is_space = 0;
  while ((input_symbol = getchar()) != EOF) {
    if (input_symbol == '.' || input_symbol == ',' || input_symbol == '!' ||
        input_symbol == '?') {
      previous_is_space = 0;
    } else if (input_symbol == ' ' || input_symbol == '\t') {
      if (!previous_is_space) {
        putchar(' ');
      }
      previous_is_space = 1;
    } else if (isupper(input_symbol)) {
      putchar(input_symbol + ('a' - 'A'));
      previous_is_space = 0;
    } else if (input_symbol >= '0' && input_symbol <= '9') {
      putchar('#');
      previous_is_space = 0;
    } else {
      putchar(input_symbol);
      previous_is_space = 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<symbol_filter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movb   $0xff,-0x1(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x1(%rbp)
movsbl %al,%eax
mov    0x2e91(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     125e <symbol_filter+0x12e>
movsbl -0x1(%rbp),%eax
cmp    $0x2e,%eax
je     1196 <symbol_filter+0x66>
movsbl -0x1(%rbp),%eax
cmp    $0x2c,%eax
je     1196 <symbol_filter+0x66>
movsbl -0x1(%rbp),%eax
cmp    $0x21,%eax
je     1196 <symbol_filter+0x66>
movsbl -0x1(%rbp),%eax
cmp    $0x3f,%eax
jne    11a2 <symbol_filter+0x72>
movl   $0x0,-0x8(%rbp)
jmp    1259 <symbol_filter+0x129>
movsbl -0x1(%rbp),%eax
cmp    $0x20,%eax
je     11bc <symbol_filter+0x8c>
movsbl -0x1(%rbp),%eax
cmp    $0x9,%eax
jne    11dc <symbol_filter+0xac>
cmpl   $0x0,-0x8(%rbp)
jne    11d0 <symbol_filter+0xa0>
mov    $0x20,%edi
call   1030 <putchar@plt>
movl   $0x1,-0x8(%rbp)
jmp    1254 <symbol_filter+0x124>
movsbl -0x1(%rbp),%edi
call   1050 <isupper@plt>
cmp    $0x0,%rax
je     120a <symbol_filter+0xda>
movsbl -0x1(%rbp),%eax
add    $0x20,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x8(%rbp)
jmp    124f <symbol_filter+0x11f>
movsbl -0x1(%rbp),%eax
cmp    $0x30,%eax
jl     123a <symbol_filter+0x10a>
movsbl -0x1(%rbp),%eax
cmp    $0x39,%eax
jg     123a <symbol_filter+0x10a>
mov    $0x23,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x8(%rbp)
jmp    124a <symbol_filter+0x11a>
movsbl -0x1(%rbp),%edi
call   1030 <putchar@plt>
movl   $0x0,-0x8(%rbp)
jmp    124f <symbol_filter+0x11f>
jmp    1254 <symbol_filter+0x124>
jmp    1259 <symbol_filter+0x129>
jmp    1143 <symbol_filter+0x13>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<symbol_filter>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2e9f(%rip),%r14
cmp    (%r14),%al
jne    115f <symbol_filter+0x2f>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebx
movabs $0x8000500200000000,%r13
movabs $0x100000200,%r12
xor    %eax,%eax
jmp    11a5 <symbol_filter+0x75>
add    $0xd0,%bl
cmp    $0xa,%bl
mov    $0x23,%eax
cmovb  %eax,%r15d
xor    %ebp,%ebp
mov    %r15d,%ebx
movsbl %bl,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%ebx
mov    %ebp,%eax
cmp    (%r14),%bl
je     114e <symbol_filter+0x1e>
movzbl %bl,%r15d
cmp    $0x3f,%r15b
ja     11ca <symbol_filter+0x9a>
xor    %ebp,%ebp
bt     %r15,%r13
jb     1195 <symbol_filter+0x65>
bt     %r15,%r12
jae    11ca <symbol_filter+0x9a>
mov    $0x1,%ebp
test   %eax,%eax
jne    1195 <symbol_filter+0x65>
mov    $0x20,%bl
jmp    118d <symbol_filter+0x5d>
movsbl %bl,%edi
call   1050 <isupper@plt>
test   %rax,%rax
je     1179 <symbol_filter+0x49>
add    $0x20,%bl
xor    %ebp,%ebp
jmp    118d <symbol_filter+0x5d>

LLVM IR (-O0):
@EOF = global i8 0
define i32 @symbol_filter() {
%1 = alloca i8
%2 = alloca i32
store i8 -1, i8* %1
store i32 0, i32* %2
br label %3
3: ; preds = %66, %0
%4 = call signext i8 (...) @getchar()
store i8 %4, i8* %1
%5 = sext i8 %4 to i32
%6 = load i8, i8* @EOF
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %5, %7
br i1 %8, label %9, label %67
9: ; preds = %3
%10 = load i8, i8* %1
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 46
br i1 %12, label %25, label %13
13: ; preds = %9
%14 = load i8, i8* %1
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 44
br i1 %16, label %25, label %17
17: ; preds = %13
%18 = load i8, i8* %1
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 33
br i1 %20, label %25, label %21
21: ; preds = %17
%22 = load i8, i8* %1
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 63
br i1 %24, label %25, label %26
25: ; preds = %21, %17, %13, %9
store i32 0, i32* %2
br label %66
26: ; preds = %21
%27 = load i8, i8* %1
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 32
br i1 %29, label %34, label %30
30: ; preds = %26
%31 = load i8, i8* %1
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 9
br i1 %33, label %34, label %40
34: ; preds = %30, %26
%35 = load i32, i32* %2
%36 = icmp ne i32 %35, 0
br i1 %36, label %39, label %37
37: ; preds = %34
%38 = call i32 @putchar(i8 signext 32)
br label %39
39: ; preds = %37, %34
store i32 1, i32* %2
br label %65
40: ; preds = %30
%41 = load i8, i8* %1
%42 = call i64 @isupper(i8 signext %41)
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %50
44: ; preds = %40
%45 = load i8, i8* %1
%46 = sext i8 %45 to i32
%47 = add nsw i32 %46, 32
%48 = trunc i32 %47 to i8
%49 = call i32 @putchar(i8 signext %48)
store i32 0, i32* %2
br label %64
50: ; preds = %40
%51 = load i8, i8* %1
%52 = sext i8 %51 to i32
%53 = icmp sge i32 %52, 48
br i1 %53, label %54, label %60
54: ; preds = %50
%55 = load i8, i8* %1
%56 = sext i8 %55 to i32
%57 = icmp sle i32 %56, 57
br i1 %57, label %58, label %60
58: ; preds = %54
%59 = call i32 @putchar(i8 signext 35)
store i32 0, i32* %2
br label %63
60: ; preds = %54, %50
%61 = load i8, i8* %1
%62 = call i32 @putchar(i8 signext %61)
store i32 0, i32* %2
br label %63
63: ; preds = %60, %58
br label %64
64: ; preds = %63, %44
br label %65
65: ; preds = %64, %39
br label %66
66: ; preds = %65, %25
br label %3
67: ; preds = %3
ret i32 0
}

LLVM IR (-O2):
@EOF = global i8 0
define i32 @symbol_filter() {
%1 = tail call signext i8 (...) @getchar()
%2 = load i8, i8* @EOF
%3 = icmp eq i8 %1, %2
br i1 %3, label %27, label %4
4: ; preds = %0, %22
%5 = phi i8 [ %24, %22 ], [ %1, %0 ]
%6 = phi i32 [ %23, %22 ], [ 0, %0 ]
switch i8 %5, label %9 [
i8 63, label %22
i8 46, label %22
i8 44, label %22
i8 33, label %22
i8 32, label %7
i8 9, label %7
]
7: ; preds = %4, %4
%8 = icmp eq i32 %6, 0
br i1 %8, label %18, label %22
9: ; preds = %4
%10 = tail call i64 @isupper(i8 signext %5)
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = add i8 %5, 32
br label %18
14: ; preds = %9
%15 = add i8 %5, -48
%16 = icmp ult i8 %15, 10
%17 = select i1 %16, i8 35, i8 %5
br label %18
18: ; preds = %14, %7, %12
%19 = phi i8 [ %13, %12 ], [ 32, %7 ], [ %17, %14 ]
%20 = phi i32 [ 0, %12 ], [ 1, %7 ], [ 0, %14 ]
%21 = tail call i32 @putchar(i8 signext %19)
br label %22
22: ; preds = %18, %4, %4, %4, %4, %7
%23 = phi i32 [ 0, %4 ], [ 0, %4 ], [ 0, %4 ], [ 0, %4 ], [ 1, %7 ], [ %20, %18 ]
%24 = tail call signext i8 (...) @getchar()
%25 = load i8, i8* @EOF
%26 = icmp eq i8 %24, %25
br i1 %26, label %27, label %4
27: ; preds = %22, %0
ret i32 0
}