#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 *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, count, c;
  scanf("%d", &n);
  getchar();
  while (n--) {
    count = 0;
    while ((c = getchar()) != '\n') {
      if (c >= '0' && c <= '9')
        count++;
    }
    printf("%d\n", count);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     11ba <main+0x8a>
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x10(%rbp)
cmp    $0xa,%eax
je     11a6 <main+0x76>
cmpl   $0x30,-0x10(%rbp)
jl     11a1 <main+0x71>
cmpl   $0x39,-0x10(%rbp)
jg     11a1 <main+0x71>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1171 <main+0x41>
mov    -0xc(%rbp),%esi
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
jmp    1156 <main+0x26>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
subl   $0x1,0x4(%rsp)
jae    115b <main+0x2b>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xea1(%rip),%rbx
jmp    1181 <main+0x51>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
subl   $0x1,0x4(%rsp)
jb     1152 <main+0x22>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x0,%ebp
cmp    $0xa,%eax
je     1170 <main+0x40>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0xffffffd0,%eax
cmp    $0xa,%eax
adc    $0x0,%ebp
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
jne    11a0 <main+0x70>
jmp    1170 <main+0x40>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = call i32 (...) @getchar()
%5 = load i32, i32* %1
%6 = add nsw i32 %5, -1
store i32 %6, i32* %1
%7 = icmp eq i32 %5, 0
br i1 %7, label %26, label %8
8: ; preds = %0, %20
%9 = call i32 (...) @getchar()
%10 = icmp eq i32 %9, 10
br i1 %10, label %20, label %11
11: ; preds = %8, %11
%12 = phi i32 [ %18, %11 ], [ %9, %8 ]
%13 = phi i32 [ %17, %11 ], [ 0, %8 ]
%14 = add i32 %12, -48
%15 = icmp ult i32 %14, 10
%16 = zext i1 %15 to i32
%17 = add nuw nsw i32 %13, %16
%18 = call i32 (...) @getchar()
%19 = icmp eq i32 %18, 10
br i1 %19, label %20, label %11
20: ; preds = %11, %8
%21 = phi i32 [ 0, %8 ], [ %17, %11 ]
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %1
%24 = add nsw i32 %23, -1
store i32 %24, i32* %1
%25 = icmp eq i32 %23, 0
br i1 %25, label %26, label %8
26: ; preds = %20, %0
ret i32 0
}