int main() {
  int num, testcases, rem;
  int i = 1;
  scanf("%d", &testcases);
  int result, sum = 0, carry = 0, lastDigit = 0, value = 0, temp_sum = 0, rem2;
  int multiplier = 1;
  while (testcases--) {
    scanf("%d", &num);
    while (num != 0) {
      rem = (num % 10);
      lastDigit = rem + 1 + carry;
      carry = 0;
      if (lastDigit > 10) {
        carry++;
        lastDigit = 0;
      }
      sum = sum + (lastDigit)*multiplier;
      multiplier = multiplier * 10;
      num = num / 10;
    }
    printf("%d\n", sum);
    sum = 0;
    lastDigit = 0;
    multiplier = 1;
    carry = 0;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x14(%rbp)
lea    0xec3(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     1238 <main+0x118>
lea    0xe73(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
je     1206 <main+0xe6>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0xa,-0x24(%rbp)
jle    11dd <main+0xbd>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x24(%rbp),%ecx
imul   -0x34(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
imul   $0xa,-0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    1198 <main+0x78>
mov    -0x1c(%rbp),%esi
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x1,-0x34(%rbp)
movl   $0x0,-0x20(%rbp)
jmp    1172 <main+0x52>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xed1(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,(%rsp)
jae    114d <main+0x2d>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xeac(%rip),%r14
lea    0x4(%rsp),%r15
lea    0xea3(%rip),%r12
jmp    1180 <main+0x60>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
subl   $0x1,(%rsp)
jb     113f <main+0x1f>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
mov    $0x0,%esi
test   %eax,%eax
je     1170 <main+0x50>
xor    %esi,%esi
mov    $0x1,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %eax,%edx
movslq %eax,%rdi
imul   $0x66666667,%rdi,%rax
mov    %rax,%rbx
shr    $0x3f,%rbx
sar    $0x22,%rax
add    %ebx,%eax
lea    (%rax,%rax,1),%ebx
lea    (%rbx,%rbx,4),%ebx
neg    %ebx
add    %ebx,%edx
add    $0x1,%edx
imul   %ecx,%edx
add    %edx,%esi
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
add    $0x9,%edi
cmp    $0x12,%edi
ja     11b0 <main+0x90>
mov    %eax,0x4(%rsp)
jmp    1170 <main+0x50>

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
%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 1, i32* %5
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
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 1, i32* %13
br label %15
15: ; preds = %46, %0
%16 = load i32, i32* %3
%17 = add nsw i32 %16, -1
store i32 %17, i32* %3
%18 = icmp ne i32 %16, 0
br i1 %18, label %19, label %49
19: ; preds = %15
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %21
21: ; preds = %36, %19
%22 = load i32, i32* %2
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %46
24: ; preds = %21
%25 = load i32, i32* %2
%26 = srem i32 %25, 10
store i32 %26, i32* %4
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
%29 = load i32, i32* %8
%30 = add nsw i32 %28, %29
store i32 %30, i32* %9
store i32 0, i32* %8
%31 = load i32, i32* %9
%32 = icmp sgt i32 %31, 10
br i1 %32, label %33, label %36
33: ; preds = %24
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
store i32 0, i32* %9
br label %36
36: ; preds = %33, %24
%37 = load i32, i32* %7
%38 = load i32, i32* %9
%39 = load i32, i32* %13
%40 = mul nsw i32 %38, %39
%41 = add nsw i32 %37, %40
store i32 %41, i32* %7
%42 = load i32, i32* %13
%43 = mul nsw i32 %42, 10
store i32 %43, i32* %13
%44 = load i32, i32* %2
%45 = sdiv i32 %44, 10
store i32 %45, i32* %2
br label %21
46: ; preds = %21
%47 = load i32, i32* %7
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %47)
store i32 0, i32* %7
store i32 0, i32* %9
store i32 1, i32* %13
store i32 0, i32* %8
br label %15
49: ; preds = %15
%50 = load i32, i32* %1
ret i32 %50
}

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 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = add nsw i32 %6, -1
store i32 %7, i32* %2
%8 = icmp eq i32 %6, 0
br i1 %8, label %32, label %9
9: ; preds = %0, %26
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, 0
br i1 %12, label %26, label %13
13: ; preds = %9, %13
%14 = phi i32 [ %21, %13 ], [ 1, %9 ]
%15 = phi i32 [ %20, %13 ], [ 0, %9 ]
%16 = phi i32 [ %22, %13 ], [ %11, %9 ]
%17 = srem i32 %16, 10
%18 = add nsw i32 %17, 1
%19 = mul nsw i32 %18, %14
%20 = add nsw i32 %19, %15
%21 = mul nsw i32 %14, 10
%22 = sdiv i32 %16, 10
%23 = add i32 %16, 9
%24 = icmp ult i32 %23, 19
br i1 %24, label %25, label %13
25: ; preds = %13
store i32 %22, i32* %1
br label %26
26: ; preds = %25, %9
%27 = phi i32 [ %20, %25 ], [ 0, %9 ]
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %2
%30 = add nsw i32 %29, -1
store i32 %30, i32* %2
%31 = icmp eq i32 %29, 0
br i1 %31, label %32, label %9
32: ; preds = %26, %0
ret i32 0
}