#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 getchar();
int /*<<< orphan*/ printf(char *, ...);
void count_1(void) {
  int c, i, nwhite, nother;
  int ndigit[10];
  nwhite = nother = 0;
  for (i = 0; i < 10; i++)
    ndigit[i] = 0;
  while ((c = getchar()) != '~') {
    if (c >= '0' && c <= '9') {
      ndigit[c - '0']++;
    } else if (c == ' ' || c == '\n' || c == '\t')
      ++nwhite;
    else
      ++nother;
  }
  printf("digits =");
  for (i = 0; i < 10; i++)
    printf(" %d", ndigit[i]);
  printf(", white space = %d, other = %d\n", nwhite, nother);
}


x86 assembly (clang, -O0):
<count_1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    1161 <count_1+0x41>
movslq -0x8(%rbp),%rax
movl   $0x0,-0x40(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113d <count_1+0x1d>
jmp    1166 <count_1+0x46>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x4(%rbp)
cmp    $0x7e,%eax
je     11e4 <count_1+0xc4>
cmpl   $0x30,-0x4(%rbp)
jl     11a5 <count_1+0x85>
cmpl   $0x39,-0x4(%rbp)
jg     11a5 <count_1+0x85>
mov    -0x4(%rbp),%eax
sub    $0x30,%eax
cltq
mov    -0x40(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x40(%rbp,%rax,4)
jmp    11df <count_1+0xbf>
cmpl   $0x20,-0x4(%rbp)
je     11c3 <count_1+0xa3>
cmpl   $0xa,-0x4(%rbp)
je     11c3 <count_1+0xa3>
cmpl   $0x9,-0x4(%rbp)
jne    11d1 <count_1+0xb1>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11da <count_1+0xba>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11df <count_1+0xbf>
jmp    1166 <count_1+0x46>
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    1227 <count_1+0x107>
movslq -0x8(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11f9 <count_1+0xd9>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_1>:
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    %r15d,%r15d
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x0,%ecx
mov    $0x0,%edx
mov    $0x0,%r8d
mov    $0x0,%edi
mov    $0x0,%r10d
mov    $0x0,%ebx
mov    $0x0,%r12d
mov    $0x0,%r13d
mov    $0x0,%r9d
mov    $0x0,%ebp
mov    $0x0,%esi
cmp    $0x7e,%eax
je     1204 <count_1+0xe4>
movabs $0x100000600,%rbx
xor    %r14d,%r14d
xor    %ebp,%ebp
jmp    11b3 <count_1+0x93>
mov    %ecx,%eax
addl   $0x1,0x20(%rsp,%rax,4)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0x7e,%eax
je     11d3 <count_1+0xb3>
lea    -0x30(%rax),%ecx
cmp    $0x9,%ecx
jbe    11a0 <count_1+0x80>
cmp    $0x20,%eax
ja     11cd <count_1+0xad>
mov    %eax,%eax
bt     %rax,%rbx
jae    11cd <count_1+0xad>
add    $0x1,%ebp
jmp    11a7 <count_1+0x87>
add    $0x1,%r14d
jmp    11a7 <count_1+0x87>
mov    0x20(%rsp),%r9d
mov    0x24(%rsp),%r13d
mov    0x28(%rsp),%r12d
mov    0x2c(%rsp),%ebx
mov    %r14d,%esi
mov    0x30(%rsp),%r10d
mov    0x34(%rsp),%edi
mov    0x38(%rsp),%r8d
mov    0x3c(%rsp),%edx
mov    0x40(%rsp),%ecx
mov    0x44(%rsp),%r15d
mov    %r10d,0x4(%rsp)
mov    %edi,0x8(%rsp)
mov    %r8d,0xc(%rsp)
mov    %edx,0x10(%rsp)
mov    %ecx,0x14(%rsp)
mov    %r15d,0x18(%rsp)
mov    %esi,0x1c(%rsp)
lea    0xdd6(%rip),%rdi
xor    %eax,%eax
mov    %r9d,%r14d
call   1030 <printf@plt>
lea    0xdce(%rip),%r15
mov    %r15,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    0x4(%rsp),%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    0x8(%rsp),%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    0xc(%rsp),%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    0x10(%rsp),%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    0x14(%rsp),%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    0x18(%rsp),%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xd44(%rip),%rdi
mov    %ebp,%esi
mov    0x1c(%rsp),%edx
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

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

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