#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 getchar();
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  int i, cnt = 0;
  for (i = 0; i < 256; i++) {
    char k;
    k = getchar();
    if (k == '\n')
      break;
    if (k >= '0' && k <= '9')
      cnt++;
  }
  printf("%i", cnt);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x100,-0x14(%rbp)
jge    11a3 <main+0x83>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0xa,%eax
jne    116d <main+0x4d>
jmp    11a3 <main+0x83>
movsbl -0x19(%rbp),%eax
cmp    $0x30,%eax
jl     1190 <main+0x70>
movsbl -0x19(%rbp),%eax
cmp    $0x39,%eax
jg     1190 <main+0x70>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1195 <main+0x75>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1144 <main+0x24>
mov    -0x18(%rbp),%esi
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0x100,%ebp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
je     1147 <main+0x27>
add    $0xd0,%al
cmp    $0xa,%al
adc    $0x0,%ebx
add    $0xffffffff,%ebp
jne    1130 <main+0x10>
lea    0xeb2(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%i\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %6
br label %9
9: ; preds = %30, %2
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 256
br i1 %11, label %12, label %33
12: ; preds = %9
%13 = call signext i8 (...) @getchar()
store i8 %13, i8* %8
%14 = load i8, i8* %8
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 10
br i1 %16, label %17, label %18
17: ; preds = %12
br label %33
18: ; preds = %12
%19 = load i8, i8* %8
%20 = sext i8 %19 to i32
%21 = icmp sge i32 %20, 48
br i1 %21, label %22, label %29
22: ; preds = %18
%23 = load i8, i8* %8
%24 = sext i8 %23 to i32
%25 = icmp sle i32 %24, 57
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %29
29: ; preds = %26, %22, %18
br label %30
30: ; preds = %29
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %9
33: ; preds = %17, %9
%34 = load i32, i32* %7
%35 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %8
%4 = phi i32 [ 0, %2 ], [ %12, %8 ]
%5 = phi i32 [ 0, %2 ], [ %13, %8 ]
%6 = tail call signext i8 (...) @getchar()
%7 = icmp eq i8 %6, 10
br i1 %7, label %15, label %8
8: ; preds = %3
%9 = add i8 %6, -48
%10 = icmp ult i8 %9, 10
%11 = zext i1 %10 to i32
%12 = add nuw nsw i32 %4, %11
%13 = add nuw nsw i32 %5, 1
%14 = icmp eq i32 %13, 256
br i1 %14, label %15, label %3
15: ; preds = %3, %8
%16 = phi i32 [ %4, %3 ], [ %12, %8 ]
%17 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %16)
ret i32 0
}