#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);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int num, var, temp, digit[10];
  scanf("%d", &num);
  for (int i = 0; i < num; i++) {
    scanf("%d", &var);
    for (int j = 0; j < 10; j++)
      digit[j] = 0;
    for (int j = 0; j <= var; j++) {
      temp = j;
      while (temp) {
        digit[temp % 10]++;
        temp /= 10;
      }
    }
    for (int j = 0; j < 9; j++)
      printf("%d ", digit[j]);
    printf("%d\n", digit[9]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    123f <main+0x11f>
lea    0xea7(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x48(%rbp)
cmpl   $0xa,-0x48(%rbp)
jge    118d <main+0x6d>
movslq -0x48(%rbp),%rax
movl   $0x0,-0x40(%rbp,%rax,4)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1169 <main+0x49>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11ef <main+0xcf>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11dc <main+0xbc>
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    -0x40(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x40(%rbp,%rax,4)
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
jmp    11a6 <main+0x86>
jmp    11e1 <main+0xc1>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1194 <main+0x74>
movl   $0x0,-0x50(%rbp)
cmpl   $0x9,-0x50(%rbp)
jge    1222 <main+0x102>
movslq -0x50(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
lea    0xdf4(%rip),%rdi
call   1030 <printf@plt>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    11f6 <main+0xd6>
mov    -0x1c(%rbp),%esi
lea    0xddb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1146 <main+0x26>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
lea    0xecb(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    12f3 <main+0x1d3>
xor    %eax,%eax
jmp    1228 <main+0x108>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x20(%rsp),%esi
mov    0x24(%rsp),%r14d
mov    0x28(%rsp),%r15d
mov    0x2c(%rsp),%r8d
mov    0x30(%rsp),%r13d
mov    0x34(%rsp),%ebp
mov    0x38(%rsp),%edi
mov    0x3c(%rsp),%ebx
mov    0x40(%rsp),%edx
mov    0x44(%rsp),%ecx
mov    %edi,0x8(%rsp)
mov    %ebx,0xc(%rsp)
mov    %edx,0x10(%rsp)
mov    %ecx,0x14(%rsp)
lea    0xe60(%rip),%r12
mov    %r12,%rdi
mov    %r8d,%ebx
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %r13d,%esi
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %r12,%rdi
mov    0x8(%rsp),%esi
call   1030 <printf@plt>
mov    %r12,%rdi
mov    0xc(%rsp),%esi
call   1030 <printf@plt>
mov    %r12,%rdi
mov    0x10(%rsp),%esi
call   1030 <printf@plt>
lea    0xdf9(%rip),%rdi
mov    0x14(%rsp),%esi
call   1030 <printf@plt>
mov    0x18(%rsp),%eax
add    $0x1,%eax
cmp    0x4(%rsp),%eax
jge    12f3 <main+0x1d3>
mov    %eax,0x18(%rsp)
lea    0xdcd(%rip),%rdi
lea    0x1c(%rsp),%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movq   $0x0,0x40(%rsp)
mov    0x1c(%rsp),%eax
mov    $0x0,%ecx
mov    $0x0,%edx
mov    $0x0,%ebx
mov    $0x0,%edi
mov    $0x0,%ebp
mov    $0x0,%r13d
mov    $0x0,%r8d
mov    $0x0,%r15d
mov    $0x0,%r14d
mov    $0x0,%esi
test   %eax,%eax
js     118c <main+0x6c>
xor    %ecx,%ecx
jmp    12ad <main+0x18d>
nopl   0x0(%rax)
lea    0x1(%rcx),%edx
cmp    %eax,%ecx
mov    %edx,%ecx
je     1160 <main+0x40>
test   %ecx,%ecx
je     12a0 <main+0x180>
mov    %ecx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movslq %edx,%rsi
imul   $0x66666667,%rsi,%rdx
mov    %rdx,%rdi
shr    $0x3f,%rdi
sar    $0x22,%rdx
add    %edi,%edx
lea    (%rdx,%rdx,1),%edi
lea    (%rdi,%rdi,4),%edi
mov    %esi,%ebp
sub    %edi,%ebp
movslq %ebp,%rdi
addl   $0x1,0x20(%rsp,%rdi,4)
add    $0x9,%esi
cmp    $0x12,%esi
ja     12c0 <main+0x1a0>
jmp    12a0 <main+0x180>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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