#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i, n;
  int number0 = 0, number1 = 0, number2 = 0, number3 = 0, number4 = 0,
      number5 = 0, number6 = 0, number7 = 0, number8 = 0, number9 = 0;
  do {
    printf("Enter number below or equal to 1 billion: \n");
    scanf("%d", &i);
  } while (i > 1000000000);
  while (i != 0) {
    n = i % 10;
    i = i / 10;
    if (n == 0)
      number0++;
    if (n == 1)
      number1++;
    if (n == 2)
      number2++;
    if (n == 3)
      number3++;
    if (n == 4)
      number4++;
    if (n == 5)
      number5++;
    if (n == 6)
      number6++;
    if (n == 7)
      number7++;
    if (n == 8)
      number8++;
    if (n == 9)
      number9++;
  }
  printf("The number 0 was seen %d times \n", number0);
  printf("The number 1 was seen %d times \n", number1);
  printf("The number 2 was seen %d times \n", number2);
  printf("The number 3 was seen %d times \n", number3);
  printf("The number 4 was seen %d times \n", number4);
  printf("The number 5 was seen %d times \n", number5);
  printf("The number 6 was seen %d times \n", number6);
  printf("The number 7 was seen %d times \n", number7);
  printf("The number 8 was seen %d times \n", number8);
  printf("The number 9 was seen %d times \n", number9);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea2(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x3b9aca00,-0x8(%rbp)
jg     1175 <main+0x55>
jmp    11a5 <main+0x85>
cmpl   $0x0,-0x8(%rbp)
je     128e <main+0x16e>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    11de <main+0xbe>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    11f1 <main+0xd1>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x2,-0xc(%rbp)
jne    1204 <main+0xe4>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x3,-0xc(%rbp)
jne    1217 <main+0xf7>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x4,-0xc(%rbp)
jne    122a <main+0x10a>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x5,-0xc(%rbp)
jne    123d <main+0x11d>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x6,-0xc(%rbp)
jne    1250 <main+0x130>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x7,-0xc(%rbp)
jne    1263 <main+0x143>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x8,-0xc(%rbp)
jne    1276 <main+0x156>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
cmpl   $0x9,-0xc(%rbp)
jne    1289 <main+0x169>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11a5 <main+0x85>
mov    -0x10(%rbp),%esi
lea    0xd97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xdb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xdd7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%esi
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%esi
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%esi
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%esi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%esi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
lea    0x102e(%rip),%r14
lea    0xeda(%rip),%rbp
lea    0xc(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x3b9aca00,%eax
jg     1150 <main+0x20>
pxor   %xmm5,%xmm5
test   %eax,%eax
je     1206 <main+0xd6>
xor    %ebx,%ebx
movdqa 0xe7c(%rip),%xmm0
movdqa 0xe84(%rip),%xmm1
xor    %ebp,%ebp
pxor   %xmm4,%xmm4
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
lea    (%rax,%rax,1),%edx
lea    (%rdx,%rdx,4),%edx
mov    %ecx,%esi
sub    %edx,%esi
movd   %esi,%xmm2
pshufd $0x0,%xmm2,%xmm2
movdqa %xmm2,%xmm3
pcmpeqd %xmm0,%xmm3
psubd  %xmm3,%xmm5
pcmpeqd %xmm1,%xmm2
psubd  %xmm2,%xmm4
xor    %edx,%edx
cmp    $0x8,%esi
sete   %dl
add    %edx,%ebp
xor    %edx,%edx
cmp    $0x9,%esi
sete   %dl
add    %edx,%ebx
add    $0x9,%ecx
cmp    $0x12,%ecx
ja     11a0 <main+0x70>
mov    %eax,0xc(%rsp)
movdqa %xmm4,0x10(%rsp)
jmp    1214 <main+0xe4>
xor    %ebp,%ebp
xor    %ebx,%ebx
pxor   %xmm0,%xmm0
movdqa %xmm0,0x10(%rsp)
movdqa %xmm5,0x20(%rsp)
movd   %xmm5,%esi
lea    0xdfe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
pshufd $0x55,0x20(%rsp),%xmm0
movd   %xmm0,%esi
lea    0xe06(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
pshufd $0xee,0x20(%rsp),%xmm0
movd   %xmm0,%esi
lea    0xe0e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
pshufd $0xff,0x20(%rsp),%xmm0
movd   %xmm0,%esi
lea    0xe16(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movdqa 0x10(%rsp),%xmm0
movd   %xmm0,%esi
lea    0xe1f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
pshufd $0x55,0x10(%rsp),%xmm0
movd   %xmm0,%esi
lea    0xe27(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
pshufd $0xee,0x10(%rsp),%xmm0
movd   %xmm0,%esi
lea    0xe2f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
pshufd $0xff,0x10(%rsp),%xmm0
movd   %xmm0,%esi
lea    0xe37(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe4a(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe5b(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [44 x i8] c"Enter number below or equal to 1 billion: \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"The number 0 was seen %d times \0A\00"
@.str.3 = [33 x i8] c"The number 1 was seen %d times \0A\00"
@.str.4 = [33 x i8] c"The number 2 was seen %d times \0A\00"
@.str.5 = [33 x i8] c"The number 3 was seen %d times \0A\00"
@.str.6 = [33 x i8] c"The number 4 was seen %d times \0A\00"
@.str.7 = [33 x i8] c"The number 5 was seen %d times \0A\00"
@.str.8 = [33 x i8] c"The number 6 was seen %d times \0A\00"
@.str.9 = [33 x i8] c"The number 7 was seen %d times \0A\00"
@.str.10 = [33 x i8] c"The number 8 was seen %d times \0A\00"
@.str.11 = [33 x i8] c"The number 9 was seen %d times \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
br label %14
14: ; preds = %17, %0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %17
17: ; preds = %14
%18 = load i32, i32* %2
%19 = icmp sgt i32 %18, 1000000000
br i1 %19, label %14, label %20
20: ; preds = %17
br label %21
21: ; preds = %88, %20
%22 = load i32, i32* %2
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %89
24: ; preds = %21
%25 = load i32, i32* %2
%26 = srem i32 %25, 10
store i32 %26, i32* %3
%27 = load i32, i32* %2
%28 = sdiv i32 %27, 10
store i32 %28, i32* %2
%29 = load i32, i32* %3
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %24
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %34
34: ; preds = %31, %24
%35 = load i32, i32* %3
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %40
40: ; preds = %37, %34
%41 = load i32, i32* %3
%42 = icmp eq i32 %41, 2
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
br label %46
46: ; preds = %43, %40
%47 = load i32, i32* %3
%48 = icmp eq i32 %47, 3
br i1 %48, label %49, label %52
49: ; preds = %46
%50 = load i32, i32* %7
%51 = add nsw i32 %50, 1
store i32 %51, i32* %7
br label %52
52: ; preds = %49, %46
%53 = load i32, i32* %3
%54 = icmp eq i32 %53, 4
br i1 %54, label %55, label %58
55: ; preds = %52
%56 = load i32, i32* %8
%57 = add nsw i32 %56, 1
store i32 %57, i32* %8
br label %58
58: ; preds = %55, %52
%59 = load i32, i32* %3
%60 = icmp eq i32 %59, 5
br i1 %60, label %61, label %64
61: ; preds = %58
%62 = load i32, i32* %9
%63 = add nsw i32 %62, 1
store i32 %63, i32* %9
br label %64
64: ; preds = %61, %58
%65 = load i32, i32* %3
%66 = icmp eq i32 %65, 6
br i1 %66, label %67, label %70
67: ; preds = %64
%68 = load i32, i32* %10
%69 = add nsw i32 %68, 1
store i32 %69, i32* %10
br label %70
70: ; preds = %67, %64
%71 = load i32, i32* %3
%72 = icmp eq i32 %71, 7
br i1 %72, label %73, label %76
73: ; preds = %70
%74 = load i32, i32* %11
%75 = add nsw i32 %74, 1
store i32 %75, i32* %11
br label %76
76: ; preds = %73, %70
%77 = load i32, i32* %3
%78 = icmp eq i32 %77, 8
br i1 %78, label %79, label %82
79: ; preds = %76
%80 = load i32, i32* %12
%81 = add nsw i32 %80, 1
store i32 %81, i32* %12
br label %82
82: ; preds = %79, %76
%83 = load i32, i32* %3
%84 = icmp eq i32 %83, 9
br i1 %84, label %85, label %88
85: ; preds = %82
%86 = load i32, i32* %13
%87 = add nsw i32 %86, 1
store i32 %87, i32* %13
br label %88
88: ; preds = %85, %82
br label %21
89: ; preds = %21
%90 = load i32, i32* %4
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %90)
%92 = load i32, i32* %5
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %92)
%94 = load i32, i32* %6
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %94)
%96 = load i32, i32* %7
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i32 %96)
%98 = load i32, i32* %8
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 %98)
%100 = load i32, i32* %9
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i32 %100)
%102 = load i32, i32* %10
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i32 %102)
%104 = load i32, i32* %11
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i32 %104)
%106 = load i32, i32* %12
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), i32 %106)
%108 = load i32, i32* %13
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0), i32 %108)
%110 = load i32, i32* %1
ret i32 %110
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"The number 0 was seen %d times \0A\00"
@.str.3 = [33 x i8] c"The number 1 was seen %d times \0A\00"
@.str.4 = [33 x i8] c"The number 2 was seen %d times \0A\00"
@.str.5 = [33 x i8] c"The number 3 was seen %d times \0A\00"
@.str.6 = [33 x i8] c"The number 4 was seen %d times \0A\00"
@.str.7 = [33 x i8] c"The number 5 was seen %d times \0A\00"
@.str.8 = [33 x i8] c"The number 6 was seen %d times \0A\00"
@.str.9 = [33 x i8] c"The number 7 was seen %d times \0A\00"
@.str.10 = [33 x i8] c"The number 8 was seen %d times \0A\00"
@.str.11 = [33 x i8] c"The number 9 was seen %d times \0A\00"
@str = [43 x i8] c"Enter number below or equal to 1 billion: \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %3, %0
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp sgt i32 %6, 1000000000
br i1 %7, label %3, label %8
8: ; preds = %3
%9 = icmp eq i32 %6, 0
br i1 %9, label %31, label %10
10: ; preds = %8, %10
%11 = phi i32 [ %27, %10 ], [ 0, %8 ]
%12 = phi i32 [ %24, %10 ], [ 0, %8 ]
%13 = phi i32 [ %16, %10 ], [ %6, %8 ]
%14 = phi <8 x i32> [ %21, %10 ], [ zeroinitializer, %8 ]
%15 = srem i32 %13, 10
%16 = sdiv i32 %13, 10
%17 = insertelement <8 x i32> poison, i32 %15, i64 0
%18 = shufflevector <8 x i32> %17, <8 x i32> poison, <8 x i32> zeroinitializer
%19 = icmp eq <8 x i32> %18, <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
%20 = zext <8 x i1> %19 to <8 x i32>
%21 = add nuw nsw <8 x i32> %14, %20
%22 = icmp eq i32 %15, 8
%23 = zext i1 %22 to i32
%24 = add nuw nsw i32 %12, %23
%25 = icmp eq i32 %15, 9
%26 = zext i1 %25 to i32
%27 = add nuw nsw i32 %11, %26
%28 = add i32 %13, 9
%29 = icmp ult i32 %28, 19
br i1 %29, label %30, label %10
30: ; preds = %10
store i32 %16, i32* %1
br label %31
31: ; preds = %30, %8
%32 = phi i32 [ %24, %30 ], [ 0, %8 ]
%33 = phi i32 [ %27, %30 ], [ 0, %8 ]
%34 = phi <8 x i32> [ %21, %30 ], [ zeroinitializer, %8 ]
%35 = extractelement <8 x i32> %34, i64 0
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %35)
%37 = extractelement <8 x i32> %34, i64 1
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %37)
%39 = extractelement <8 x i32> %34, i64 2
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %39)
%41 = extractelement <8 x i32> %34, i64 3
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i32 %41)
%43 = extractelement <8 x i32> %34, i64 4
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 %43)
%45 = extractelement <8 x i32> %34, i64 5
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i32 %45)
%47 = extractelement <8 x i32> %34, i64 6
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i32 %47)
%49 = extractelement <8 x i32> %34, i64 7
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i32 %49)
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), i32 %32)
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0), i32 %33)
ret i32 0
}