#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 *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main(void) {
  int cb, cn, ct, unknown;
  cb = cn = ct = unknown = 0;
  char *str = malloc(1000);
  printf("Enter any string: ");
  scanf("%[^'!']", str);
  while (*str) {
    if (*str == ' ') {
      cb++;
    } else if (*str == '\t') {
      ct++;
    } else if (*str == '\n') {
      cn++;
    } else
      unknown++;
    str++;
  }
  printf("The Result: \n");
  printf("\tBlank:   %d\n", cb);
  printf("\tTab:     %d\n", ct);
  printf("\tNewline: %d\n", cn);
  printf("\tUnknow:  %d\n", unknown);
  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)
movl   $0x0,-0x8(%rbp)
mov    $0x3e8,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe91(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     1212 <main+0xe2>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    11b2 <main+0x82>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1201 <main+0xd1>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
jne    11d0 <main+0xa0>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11fc <main+0xcc>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    11ee <main+0xbe>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11f7 <main+0xc7>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11fc <main+0xcc>
jmp    1201 <main+0xd1>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1187 <main+0x57>
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xdf6(%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   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x3e8,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xf28(%rip),%rdi
xor    %r12d,%r12d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf2a(%rip),%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
lea    0xe84(%rip),%rax
xor    %r15d,%r15d
xor    %ebp,%ebp
xor    %r14d,%r14d
jmp    1198 <main+0x58>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r15d
add    $0x1,%rbx
movzbl (%rbx),%ecx
cmp    $0x20,%rcx
ja     11c0 <main+0x80>
movslq (%rax,%rcx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
add    $0x1,%ebp
add    $0x1,%rbx
jmp    1198 <main+0x58>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r14d
add    $0x1,%rbx
jmp    1198 <main+0x58>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r12d
add    $0x1,%rbx
jmp    1198 <main+0x58>
lea    0xef6(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb2(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeaf(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xead(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeaa(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Enter any string: \00"
@.str.1 = [8 x i8] c"%[^'!']\00"
@.str.2 = [14 x i8] c"The Result: \0A\00"
@.str.3 = [14 x i8] c"\09Blank: %d\0A\00"
@.str.4 = [14 x i8] c"\09Tab: %d\0A\00"
@.str.5 = [14 x i8] c"\09Newline: %d\0A\00"
@.str.6 = [14 x i8] c"\09Unknow: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %4
store i32 0, i32* %3
store i32 0, i32* %2
%7 = call i8* @malloc(i32 1000)
store i8* %7, i8** %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%9 = load i8*, i8** %6
%10 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %9)
br label %11
11: ; preds = %44, %0
%12 = load i8*, i8** %6
%13 = load i8, i8* %12
%14 = icmp ne i8 %13, 0
br i1 %14, label %15, label %47
15: ; preds = %11
%16 = load i8*, i8** %6
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 32
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %44
23: ; preds = %15
%24 = load i8*, i8** %6
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 9
br i1 %27, label %28, label %31
28: ; preds = %23
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %43
31: ; preds = %23
%32 = load i8*, i8** %6
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 10
br i1 %35, label %36, label %39
36: ; preds = %31
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %42
39: ; preds = %31
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
br label %42
42: ; preds = %39, %36
br label %43
43: ; preds = %42, %28
br label %44
44: ; preds = %43, %20
%45 = load i8*, i8** %6
%46 = getelementptr inbounds i8, i8* %45, i32 1
store i8* %46, i8** %6
br label %11
47: ; preds = %11
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%49 = load i32, i32* %2
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %49)
%51 = load i32, i32* %4
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %51)
%53 = load i32, i32* %3
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %53)
%55 = load i32, i32* %5
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %55)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Enter any string: \00"
@.str.1 = [8 x i8] c"%[^'!']\00"
@.str.3 = [14 x i8] c"\09Blank: %d\0A\00"
@.str.4 = [14 x i8] c"\09Tab: %d\0A\00"
@.str.5 = [14 x i8] c"\09Newline: %d\0A\00"
@.str.6 = [14 x i8] c"\09Unknow: %d\0A\00"
@str = [13 x i8] c"The Result: \00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(1000) i8* @malloc(i32 1000)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %4
4: ; preds = %19, %0
%5 = phi i32 [ 0, %0 ], [ %20, %19 ]
%6 = phi i32 [ 0, %0 ], [ %21, %19 ]
%7 = phi i32 [ 0, %0 ], [ %22, %19 ]
%8 = phi i32 [ 0, %0 ], [ %23, %19 ]
%9 = phi i8* [ %1, %0 ], [ %24, %19 ]
%10 = load i8, i8* %9
switch i8 %10, label %17 [
i8 0, label %25
i8 32, label %11
i8 9, label %13
i8 10, label %15
]
11: ; preds = %4
%12 = add nsw i32 %5, 1
br label %19
13: ; preds = %4
%14 = add nsw i32 %7, 1
br label %19
15: ; preds = %4
%16 = add nsw i32 %6, 1
br label %19
17: ; preds = %4
%18 = add nsw i32 %8, 1
br label %19
19: ; preds = %13, %17, %15, %11
%20 = phi i32 [ %12, %11 ], [ %5, %13 ], [ %5, %15 ], [ %5, %17 ]
%21 = phi i32 [ %6, %11 ], [ %6, %13 ], [ %16, %15 ], [ %6, %17 ]
%22 = phi i32 [ %7, %11 ], [ %14, %13 ], [ %7, %15 ], [ %7, %17 ]
%23 = phi i32 [ %8, %11 ], [ %8, %13 ], [ %8, %15 ], [ %18, %17 ]
%24 = getelementptr inbounds i8, i8* %9, i64 1
br label %4
25: ; preds = %4
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %5)
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %7)
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %6)
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %8)
ret i32 0
}