#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 inverte(int);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int a, b, i, n, cont = 0;
  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    scanf("%d", &a);
    if (a < 10)
      printf("%d %d\n", cont, a);
    else if (a == inverte(a))
      printf("%d %d\n", cont, a);
    else {
      while (1) {
        ++cont;
        b = inverte(a);
        if ((a + b) == inverte((a + b)))
          break;
        else
          a = a + b;
      }
      printf("%d %d\n", cont, (a + b));
      cont = 0;
      a = 0;
      b = 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xeb3(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    125b <main+0x12b>
lea    0xe90(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0xa,-0x8(%rbp)
jge    119a <main+0x6a>
mov    -0x18(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe73(%rip),%rdi
call   1040 <printf@plt>
jmp    1248 <main+0x118>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <inverte@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jne    11cc <main+0x9c>
mov    -0x18(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe41(%rip),%rdi
call   1040 <printf@plt>
jmp    1243 <main+0x113>
jmp    11d1 <main+0xa1>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <inverte@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
add    -0xc(%rbp),%edi
call   1030 <inverte@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jne    120b <main+0xdb>
jmp    1219 <main+0xe9>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11d1 <main+0xa1>
mov    -0x18(%rbp),%esi
mov    -0x8(%rbp),%edx
add    -0xc(%rbp),%edx
lea    0xdda(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
jmp    1248 <main+0x118>
jmp    124d <main+0x11d>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115d <main+0x2d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebe(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    1236 <main+0x106>
xor    %r14d,%r14d
lea    0xe9f(%rip),%r12
mov    %rsp,%rbp
lea    0xe98(%rip),%r15
jmp    118b <main+0x5b>
nopl   (%rax)
mov    %r15,%rdi
xor    %esi,%esi
mov    %ebx,%edx
call   1040 <printf@plt>
add    $0x1,%r14d
cmp    0x4(%rsp),%r14d
jge    1236 <main+0x106>
mov    %r12,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
mov    (%rsp),%ebx
cmp    $0x9,%ebx
jle    1170 <main+0x40>
mov    %ebx,%edi
call   1030 <inverte@plt>
mov    (%rsp),%edx
cmp    %eax,%ebx
jne    11c0 <main+0x90>
mov    %r15,%rdi
xor    %esi,%esi
jmp    1177 <main+0x47>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %edx,%edi
call   1030 <inverte@plt>
mov    %eax,%r13d
mov    %eax,%ebp
add    (%rsp),%ebp
mov    %ebp,%edi
call   1030 <inverte@plt>
mov    $0x1,%ebx
cmp    %eax,%ebp
je     1216 <main+0xe6>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    (%rsp),%r13d
mov    %r13d,(%rsp)
add    $0x1,%ebx
mov    %r13d,%edi
call   1030 <inverte@plt>
mov    %eax,%r13d
mov    %eax,%ebp
add    (%rsp),%ebp
mov    %ebp,%edi
call   1030 <inverte@plt>
cmp    %eax,%ebp
jne    11f0 <main+0xc0>
add    (%rsp),%r13d
mov    %r15,%rdi
mov    %ebx,%esi
mov    %r13d,%edx
call   1040 <printf@plt>
movl   $0x0,(%rsp)
mov    %rsp,%rbp
jmp    117c <main+0x4c>
xor    %eax,%eax
add    $0x8,%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 = [7 x i8] c"%d %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
store i32 0, i32* %4
br label %8
8: ; preds = %57, %0
%9 = load i32, i32* %4
%10 = load i32, i32* %5
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %60
12: ; preds = %8
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
%15 = icmp slt i32 %14, 10
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i32, i32* %6
%18 = load i32, i32* %2
%19 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %17, i32 %18)
br label %56
20: ; preds = %12
%21 = load i32, i32* %2
%22 = load i32, i32* %2
%23 = call i32 @inverte(i32 %22)
%24 = icmp eq i32 %21, %23
br i1 %24, label %25, label %29
25: ; preds = %20
%26 = load i32, i32* %6
%27 = load i32, i32* %2
%28 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %26, i32 %27)
br label %55
29: ; preds = %20
br label %30
30: ; preds = %29, %48
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
%33 = load i32, i32* %2
%34 = call i32 @inverte(i32 %33)
store i32 %34, i32* %3
%35 = load i32, i32* %2
%36 = load i32, i32* %3
%37 = add nsw i32 %35, %36
%38 = load i32, i32* %2
%39 = load i32, i32* %3
%40 = add nsw i32 %38, %39
%41 = call i32 @inverte(i32 %40)
%42 = icmp eq i32 %37, %41
br i1 %42, label %43, label %44
43: ; preds = %30
br label %49
44: ; preds = %30
%45 = load i32, i32* %2
%46 = load i32, i32* %3
%47 = add nsw i32 %45, %46
store i32 %47, i32* %2
br label %48
48: ; preds = %44
br label %30
49: ; preds = %43
%50 = load i32, i32* %6
%51 = load i32, i32* %2
%52 = load i32, i32* %3
%53 = add nsw i32 %51, %52
%54 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %50, i32 %53)
store i32 0, i32* %6
store i32 0, i32* %2
store i32 0, i32* %3
br label %55
55: ; preds = %49, %25
br label %56
56: ; preds = %55, %16
br label %57
57: ; preds = %56
%58 = load i32, i32* %4
%59 = add nsw i32 %58, 1
store i32 %59, i32* %4
br label %8
60: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [7 x i8] c"%d %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 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %48
8: ; preds = %0, %44
%9 = phi i32 [ %45, %44 ], [ 0, %0 ]
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
%12 = icmp slt i32 %11, 10
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %11)
br label %44
15: ; preds = %8
%16 = call i32 @inverte(i32 %11)
%17 = icmp eq i32 %11, %16
%18 = load i32, i32* %1
br i1 %17, label %25, label %19
19: ; preds = %15
%20 = call i32 @inverte(i32 %18)
%21 = load i32, i32* %1
%22 = add nsw i32 %21, %20
%23 = call i32 @inverte(i32 %22)
%24 = icmp eq i32 %22, %23
br i1 %24, label %38, label %27
25: ; preds = %15
%26 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %18)
br label %44
27: ; preds = %19, %27
%28 = phi i32 [ %33, %27 ], [ %20, %19 ]
%29 = phi i32 [ %32, %27 ], [ 1, %19 ]
%30 = load i32, i32* %1
%31 = add nsw i32 %30, %28
store i32 %31, i32* %1
%32 = add nuw nsw i32 %29, 1
%33 = call i32 @inverte(i32 %31)
%34 = load i32, i32* %1
%35 = add nsw i32 %34, %33
%36 = call i32 @inverte(i32 %35)
%37 = icmp eq i32 %35, %36
br i1 %37, label %38, label %27
38: ; preds = %27, %19
%39 = phi i32 [ 1, %19 ], [ %32, %27 ]
%40 = phi i32 [ %20, %19 ], [ %33, %27 ]
%41 = load i32, i32* %1
%42 = add nsw i32 %41, %40
%43 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %39, i32 %42)
store i32 0, i32* %1
br label %44
44: ; preds = %13, %38, %25
%45 = add nuw nsw i32 %9, 1
%46 = load i32, i32* %2
%47 = icmp slt i32 %45, %46
br i1 %47, label %8, label %48
48: ; preds = %44, %0
ret i32 0
}