#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 count_digits(int);
int /*<<< orphan*/ printf(char *, int);
int reverse(int, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main(void) {
  int t, n1, n2, dn1, dn2, sum = 0, dsum;
  scanf("%d", &t);
  while (t--) {
    scanf("%d %d", &n1, &n2);
    dn1 = count_digits(n1);
    dn2 = count_digits(n2);
    n1 = reverse(n1, dn1);
    n2 = reverse(n2, dn2);
    sum = n1 + n2;
    dsum = count_digits(sum);
    sum = reverse(sum, dsum);
    printf("%d\n", sum);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xea6(%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     11fa <main+0xba>
lea    0xe7d(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0xc(%rbp),%edi
call   1050 <count_digits@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
call   1050 <count_digits@plt>
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1030 <reverse@plt>
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <reverse@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <count_digits@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1030 <reverse@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe16(%rip),%rdi
call   1040 <printf@plt>
jmp    1168 <main+0x28>
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
sub    $0x18,%rsp
lea    0xeae(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
subl   $0x1,0x14(%rsp)
jb     11fb <main+0xbb>
lea    0xe8d(%rip),%r14
lea    0xc(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0xe82(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0xc(%rsp),%edi
call   1050 <count_digits@plt>
mov    %eax,%ebp
mov    0x10(%rsp),%edi
call   1050 <count_digits@plt>
mov    %eax,%ebx
mov    0xc(%rsp),%edi
mov    %ebp,%esi
call   1030 <reverse@plt>
mov    %eax,0xc(%rsp)
mov    0x10(%rsp),%edi
mov    %ebx,%esi
call   1030 <reverse@plt>
mov    %eax,%ebx
mov    %eax,0x10(%rsp)
add    0xc(%rsp),%ebx
mov    %ebx,%edi
call   1050 <count_digits@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1030 <reverse@plt>
mov    %r13,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
subl   $0x1,0x14(%rsp)
jae    1190 <main+0x50>
xor    %eax,%eax
add    $0x18,%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 = [6 x i8] c"%d %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 i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %7
%9 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %10
10: ; preds = %14, %0
%11 = load i32, i32* %2
%12 = add nsw i32 %11, -1
store i32 %12, i32* %2
%13 = icmp ne i32 %11, 0
br i1 %13, label %14, label %36
14: ; preds = %10
%15 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%16 = load i32, i32* %3
%17 = call i32 @count_digits(i32 %16)
store i32 %17, i32* %5
%18 = load i32, i32* %4
%19 = call i32 @count_digits(i32 %18)
store i32 %19, i32* %6
%20 = load i32, i32* %3
%21 = load i32, i32* %5
%22 = call i32 @reverse(i32 %20, i32 %21)
store i32 %22, i32* %3
%23 = load i32, i32* %4
%24 = load i32, i32* %6
%25 = call i32 @reverse(i32 %23, i32 %24)
store i32 %25, i32* %4
%26 = load i32, i32* %3
%27 = load i32, i32* %4
%28 = add nsw i32 %26, %27
store i32 %28, i32* %7
%29 = load i32, i32* %7
%30 = call i32 @count_digits(i32 %29)
store i32 %30, i32* %8
%31 = load i32, i32* %7
%32 = load i32, i32* %8
%33 = call i32 @reverse(i32 %31, i32 %32)
store i32 %33, i32* %7
%34 = load i32, i32* %7
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %34)
br label %10
36: ; preds = %10
ret i32 0
}

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