#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 */
unsigned int addReverse(unsigned int);
int /*<<< orphan*/ palindrome(unsigned int);
int /*<<< orphan*/ printf(char *, unsigned int, unsigned int);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int num;
  scanf("%d", &num);
  unsigned int added, c;
  while (num--) {
    c = 0;
    scanf("%d", &added);
    do {
      added = addReverse(added);
      c++;
    } while (!palindrome(added));
    printf("%d %d\n", c, added);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     11d1 <main+0x91>
movl   $0x0,-0x10(%rbp)
lea    0xe7d(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0xc(%rbp),%edi
call   1030 <addReverse@plt>
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <palindrome@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    118e <main+0x4e>
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe3c(%rip),%rdi
call   1040 <printf@plt>
jmp    1161 <main+0x21>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xeb2(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
subl   $0x1,0x4(%rsp)
jb     11bd <main+0x7d>
lea    0xe98(%rip),%r14
mov    %rsp,%r15
lea    0xe91(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
nop
mov    (%rsp),%edi
call   1030 <addReverse@plt>
mov    %eax,(%rsp)
add    $0x1,%ebp
mov    %eax,%edi
call   1050 <palindrome@plt>
test   %eax,%eax
je     1190 <main+0x50>
mov    (%rsp),%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
subl   $0x1,0x4(%rsp)
jae    1180 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
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
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %6
6: ; preds = %22, %0
%7 = load i32, i32* %2
%8 = add nsw i32 %7, -1
store i32 %8, i32* %2
%9 = icmp ne i32 %7, 0
br i1 %9, label %10, label %26
10: ; preds = %6
store i32 0, i32* %4
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
br label %12
12: ; preds = %17, %10
%13 = load i32, i32* %3
%14 = call i32 @addReverse(i32 %13)
store i32 %14, i32* %3
%15 = load i32, i32* %4
%16 = add i32 %15, 1
store i32 %16, i32* %4
br label %17
17: ; preds = %12
%18 = load i32, i32* %3
%19 = call i32 @palindrome(i32 %18)
%20 = icmp ne i32 %19, 0
%21 = xor i1 %20, true
br i1 %21, label %12, label %22
22: ; preds = %17
%23 = load i32, i32* %4
%24 = load i32, i32* %3
%25 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %23, i32 %24)
br label %6
26: ; preds = %6
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 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = bitcast i32* %2 to i8*
%6 = load i32, i32* %1
%7 = add nsw i32 %6, -1
store i32 %7, i32* %1
%8 = icmp eq i32 %6, 0
br i1 %8, label %24, label %9
9: ; preds = %0, %18
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %11
11: ; preds = %11, %9
%12 = phi i32 [ 0, %9 ], [ %15, %11 ]
%13 = load i32, i32* %2
%14 = call i32 @addReverse(i32 %13)
store i32 %14, i32* %2
%15 = add i32 %12, 1
%16 = call i32 @palindrome(i32 %14)
%17 = icmp eq i32 %16, 0
br i1 %17, label %11, label %18
18: ; preds = %11
%19 = load i32, i32* %2
%20 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %19)
%21 = load i32, i32* %1
%22 = add nsw i32 %21, -1
store i32 %22, i32* %1
%23 = icmp eq i32 %21, 0
br i1 %23, label %24, label %9
24: ; preds = %18, %0
ret i32 0
}