#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 *, ...);
void sumNumSpaceAndOther() {
  int c, nSpace, nOther;
  int nDigit[10];
  nSpace = nOther = 0;
  for (int i = 0; i < 10; ++i) {
    nDigit[i] = 0;
  }
  while ((c = getchar()) != EOF) {
    if (c >= '0' && c <= '9') {
      ++nDigit[c - '0'];
    } else if (c == ' ' || c == '\n' || c == '\t') {
      ++nSpace;
    } else {
      ++nOther;
    }
  }
  printf("Digit: \n");
  for (int i = 0; i < 10; ++i) {
    printf("%d\t%3d\n", i, nDigit[i]);
  }
  printf("Number of space: %d\n", nSpace);
  printf("Number of other: %d\n", nOther);
}


x86 assembly (clang, -O0):
<sumNumSpaceAndOther>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0xa,-0x44(%rbp)
jge    1161 <sumNumSpaceAndOther+0x41>
movslq -0x44(%rbp),%rax
movl   $0x0,-0x40(%rbp,%rax,4)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    113d <sumNumSpaceAndOther+0x1d>
jmp    1166 <sumNumSpaceAndOther+0x46>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x4(%rbp)
mov    0x2e71(%rip),%rcx
cmp    (%rcx),%eax
je     11ea <sumNumSpaceAndOther+0xca>
cmpl   $0x30,-0x4(%rbp)
jl     11ab <sumNumSpaceAndOther+0x8b>
cmpl   $0x39,-0x4(%rbp)
jg     11ab <sumNumSpaceAndOther+0x8b>
mov    -0x4(%rbp),%eax
sub    $0x30,%eax
cltq
mov    -0x40(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x40(%rbp,%rax,4)
jmp    11e5 <sumNumSpaceAndOther+0xc5>
cmpl   $0x20,-0x4(%rbp)
je     11c9 <sumNumSpaceAndOther+0xa9>
cmpl   $0xa,-0x4(%rbp)
je     11c9 <sumNumSpaceAndOther+0xa9>
cmpl   $0x9,-0x4(%rbp)
jne    11d7 <sumNumSpaceAndOther+0xb7>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11e0 <sumNumSpaceAndOther+0xc0>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11e5 <sumNumSpaceAndOther+0xc5>
jmp    1166 <sumNumSpaceAndOther+0x46>
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x48(%rbp)
cmpl   $0xa,-0x48(%rbp)
jge    1230 <sumNumSpaceAndOther+0x110>
mov    -0x48(%rbp),%esi
movslq -0x48(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%edx
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    11ff <sumNumSpaceAndOther+0xdf>
mov    -0x8(%rbp),%esi
lea    0xdd7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sumNumSpaceAndOther>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movq   $0x0,0x40(%rsp)
xor    %r12d,%r12d
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e83(%rip),%rbx
mov    $0x0,%ecx
mov    $0x0,%edx
mov    $0x0,%r9d
mov    $0x0,%edi
mov    $0x0,%r8d
mov    $0x0,%r15d
mov    $0x0,%r14d
mov    $0x0,%r10d
mov    $0x0,%r13d
mov    $0x0,%ebp
mov    $0x0,%esi
cmp    (%rbx),%eax
je     1224 <sumNumSpaceAndOther+0xf4>
movabs $0x100000600,%r15
xor    %r14d,%r14d
xor    %ebp,%ebp
jmp    11d2 <sumNumSpaceAndOther+0xa2>
nopw   0x0(%rax,%rax,1)
mov    %ecx,%eax
addl   $0x1,0x20(%rsp,%rax,4)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%rbx),%eax
je     11f2 <sumNumSpaceAndOther+0xc2>
lea    -0x30(%rax),%ecx
cmp    $0x9,%ecx
jbe    11c0 <sumNumSpaceAndOther+0x90>
cmp    $0x20,%eax
ja     11ec <sumNumSpaceAndOther+0xbc>
mov    %eax,%eax
bt     %rax,%r15
jae    11ec <sumNumSpaceAndOther+0xbc>
add    $0x1,%ebp
jmp    11c7 <sumNumSpaceAndOther+0x97>
add    $0x1,%r14d
jmp    11c7 <sumNumSpaceAndOther+0x97>
mov    0x20(%rsp),%r13d
mov    0x24(%rsp),%r10d
mov    %r14d,%esi
mov    0x28(%rsp),%r14d
mov    0x2c(%rsp),%r15d
mov    0x30(%rsp),%r8d
mov    0x34(%rsp),%edi
mov    0x38(%rsp),%r9d
mov    0x3c(%rsp),%edx
mov    0x40(%rsp),%ecx
mov    0x44(%rsp),%r12d
mov    %r8d,0x4(%rsp)
mov    %edi,0x8(%rsp)
mov    %r9d,0xc(%rsp)
mov    %edx,0x10(%rsp)
mov    %esi,0x14(%rsp)
mov    %ecx,0x18(%rsp)
mov    %r12d,0x1c(%rsp)
lea    0xde8(%rip),%rdi
mov    %r10d,%ebx
call   1030 <puts@plt>
lea    0xda7(%rip),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    $0x2,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    $0x3,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    $0x4,%esi
mov    0x4(%rsp),%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    $0x5,%esi
mov    0x8(%rsp),%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    $0x6,%esi
mov    0xc(%rsp),%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    $0x7,%esi
mov    0x10(%rsp),%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    $0x8,%esi
mov    0x18(%rsp),%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    $0x9,%esi
mov    0x1c(%rsp),%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xcf2(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xcf7(%rip),%rdi
mov    0x14(%rsp),%esi
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [9 x i8] c"Digit: \0A\00"
@.str.1 = [8 x i8] c"%d\09%3d\0A\00"
@.str.2 = [21 x i8] c"Number of space: %d\0A\00"
@.str.3 = [21 x i8] c"Number of other: %d\0A\00"
define void @sumNumSpaceAndOther() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [10 x i32]
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %3
store i32 0, i32* %2
store i32 0, i32* %5
br label %7
7: ; preds = %14, %0
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 10
br i1 %9, label %10, label %17
10: ; preds = %7
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %12
store i32 0, i32* %13
br label %14
14: ; preds = %10
%15 = load i32, i32* %5
%16 = add nsw i32 %15, 1
store i32 %16, i32* %5
br label %7
17: ; preds = %7
br label %18
18: ; preds = %51, %17
%19 = call i32 (...) @getchar()
store i32 %19, i32* %1
%20 = load i32, i32* @EOF
%21 = icmp ne i32 %19, %20
br i1 %21, label %22, label %52
22: ; preds = %18
%23 = load i32, i32* %1
%24 = icmp sge i32 %23, 48
br i1 %24, label %25, label %35
25: ; preds = %22
%26 = load i32, i32* %1
%27 = icmp sle i32 %26, 57
br i1 %27, label %28, label %35
28: ; preds = %25
%29 = load i32, i32* %1
%30 = sub nsw i32 %29, 48
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = add nsw i32 %33, 1
store i32 %34, i32* %32
br label %51
35: ; preds = %25, %22
%36 = load i32, i32* %1
%37 = icmp eq i32 %36, 32
br i1 %37, label %44, label %38
38: ; preds = %35
%39 = load i32, i32* %1
%40 = icmp eq i32 %39, 10
br i1 %40, label %44, label %41
41: ; preds = %38
%42 = load i32, i32* %1
%43 = icmp eq i32 %42, 9
br i1 %43, label %44, label %47
44: ; preds = %41, %38, %35
%45 = load i32, i32* %2
%46 = add nsw i32 %45, 1
store i32 %46, i32* %2
br label %50
47: ; preds = %41
%48 = load i32, i32* %3
%49 = add nsw i32 %48, 1
store i32 %49, i32* %3
br label %50
50: ; preds = %47, %44
br label %51
51: ; preds = %50, %28
br label %18
52: ; preds = %18
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
br label %54
54: ; preds = %64, %52
%55 = load i32, i32* %6
%56 = icmp slt i32 %55, 10
br i1 %56, label %57, label %67
57: ; preds = %54
%58 = load i32, i32* %6
%59 = load i32, i32* %6
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %60
%62 = load i32, i32* %61
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %58, i32 %62)
br label %64
64: ; preds = %57
%65 = load i32, i32* %6
%66 = add nsw i32 %65, 1
store i32 %66, i32* %6
br label %54
67: ; preds = %54
%68 = load i32, i32* %2
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %68)
%70 = load i32, i32* %3
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %70)
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
@.str.1 = [8 x i8] c"%d\09%3d\0A\00"
@.str.2 = [21 x i8] c"Number of space: %d\0A\00"
@.str.3 = [21 x i8] c"Number of other: %d\0A\00"
@str = [8 x i8] c"Digit: \00"
define void @sumNumSpaceAndOther() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = tail call i32 (...) @getchar()
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %49, label %6
6: ; preds = %0, %22
%7 = phi i32 [ %25, %22 ], [ %3, %0 ]
%8 = phi i32 [ %24, %22 ], [ 0, %0 ]
%9 = phi i32 [ %23, %22 ], [ 0, %0 ]
%10 = add i32 %7, -48
%11 = icmp ult i32 %10, 10
br i1 %11, label %12, label %17
12: ; preds = %6
%13 = zext i32 %10 to i64
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %13
%15 = load i32, i32* %14
%16 = add nsw i32 %15, 1
store i32 %16, i32* %14
br label %22
17: ; preds = %6
switch i32 %7, label %20 [
i32 32, label %18
i32 10, label %18
i32 9, label %18
]
18: ; preds = %17, %17, %17
%19 = add nsw i32 %9, 1
br label %22
20: ; preds = %17
%21 = add nsw i32 %8, 1
br label %22
22: ; preds = %18, %20, %12
%23 = phi i32 [ %9, %12 ], [ %19, %18 ], [ %9, %20 ]
%24 = phi i32 [ %8, %12 ], [ %8, %18 ], [ %21, %20 ]
%25 = tail call i32 (...) @getchar()
%26 = load i32, i32* @EOF
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %6
28: ; preds = %22
%29 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%30 = load i32, i32* %29
%31 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
%32 = load i32, i32* %31
%33 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
%34 = load i32, i32* %33
%35 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
%36 = load i32, i32* %35
%37 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%38 = load i32, i32* %37
%39 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 5
%40 = load i32, i32* %39
%41 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 6
%42 = load i32, i32* %41
%43 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 7
%44 = load i32, i32* %43
%45 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
%46 = load i32, i32* %45
%47 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
%48 = load i32, i32* %47
br label %49
49: ; preds = %28, %0
%50 = phi i32 [ 0, %0 ], [ %48, %28 ]
%51 = phi i32 [ 0, %0 ], [ %46, %28 ]
%52 = phi i32 [ 0, %0 ], [ %44, %28 ]
%53 = phi i32 [ 0, %0 ], [ %42, %28 ]
%54 = phi i32 [ 0, %0 ], [ %40, %28 ]
%55 = phi i32 [ 0, %0 ], [ %38, %28 ]
%56 = phi i32 [ 0, %0 ], [ %36, %28 ]
%57 = phi i32 [ 0, %0 ], [ %34, %28 ]
%58 = phi i32 [ 0, %0 ], [ %32, %28 ]
%59 = phi i32 [ 0, %0 ], [ %30, %28 ]
%60 = phi i32 [ 0, %0 ], [ %23, %28 ]
%61 = phi i32 [ 0, %0 ], [ %24, %28 ]
%62 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%63 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %59)
%64 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %58)
%65 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 %57)
%66 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 %56)
%67 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 %55)
%68 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 %54)
%69 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 6, i32 %53)
%70 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 7, i32 %52)
%71 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 8, i32 %51)
%72 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 9, i32 %50)
%73 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %60)
%74 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %61)
ret void
}